[−][src]Trait ggpf::game::Features
Games that can be represented as multi-dimensional arrays.
These games are the ones that can be played by neural network-based policies, such as PUCT or Muz.
Associated Types
type StateDim: Dimension
Type dimension of the game state feature space.
type ActionDim: Dimension
Type dimension of the action feature space.
type Descriptor: Send + Sync + Clone
Game features descriptor, that can be used to retrieve dimensions without having access to a game instance.
Required methods
fn get_features(&self) -> Self::Descriptor
Obtain game descriptor.
fn state_dimension(descr: &Self::Descriptor) -> Self::StateDim
Deduce state shape from game descriptor.
fn action_dimension(descr: &Self::Descriptor) -> Self::ActionDim
Deduce action shape from game descriptor.
fn state_to_feature(&self, pov: Self::Player) -> Array<f32, Self::StateDim>
Converts the game state to features (multi-dimensional array).
These features may be relative to a particular player but they should contain the same amount of information.
fn moves_to_feature(
descr: &Self::Descriptor,
moves: &HashMap<Self::Move, f32>
) -> Array<f32, Self::ActionDim>
descr: &Self::Descriptor,
moves: &HashMap<Self::Move, f32>
) -> Array<f32, Self::ActionDim>
Converts an action probability distribution to the action features.
fn feature_to_moves(
&self,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
&self,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
Converts a move distribution feature to the corresponding set of move probabilities, relative to the game state.
Invalid moves relative to the game state are discarded. To keep all moves, see
all_feature_to_moves
.
fn all_possible_moves(descr: &Self::Descriptor) -> Vec<Self::Move>
Returns action space
fn all_feature_to_moves(
descr: &Self::Descriptor,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
descr: &Self::Descriptor,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
Converts a move distribution feature to the corresponding set of move probabilities, independently from the game state.
To consider only valid moves, see feature_to_moves
.
Provided methods
fn move_to_feature(
descr: &Self::Descriptor,
action: Self::Move
) -> Array<f32, Self::ActionDim>
descr: &Self::Descriptor,
action: Self::Move
) -> Array<f32, Self::ActionDim>
Converts a single move to a one-hot feature encoding of the move.
Implementors
impl Features for Breakthrough
[src]
type StateDim = Ix3
type ActionDim = Ix3
type Descriptor = usize
fn get_features(&self) -> Self::Descriptor
[src]
fn state_dimension(K: &Self::Descriptor) -> Self::StateDim
[src]
fn action_dimension(K: &Self::Descriptor) -> Self::ActionDim
[src]
fn state_to_feature(&self, pov: Self::Player) -> Array<f32, Self::StateDim>
[src]
fn moves_to_feature(
descr: &Self::Descriptor,
moves: &HashMap<Self::Move, f32>
) -> Array<f32, Self::ActionDim>
[src]
descr: &Self::Descriptor,
moves: &HashMap<Self::Move, f32>
) -> Array<f32, Self::ActionDim>
fn feature_to_moves(
&self,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
[src]
&self,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
fn all_feature_to_moves(
descr: &Self::Descriptor,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
[src]
descr: &Self::Descriptor,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
fn all_possible_moves(K: &Self::Descriptor) -> Vec<Self::Move>
[src]
impl Features for Gym
[src]
type StateDim = Ix3
type ActionDim = Ix1
type Descriptor = (Vec<usize>, Ix3, Ix1)
fn get_features(&self) -> Self::Descriptor
[src]
fn state_dimension(descr: &Self::Descriptor) -> Self::StateDim
[src]
fn action_dimension(descr: &Self::Descriptor) -> Self::ActionDim
[src]
fn state_to_feature(&self, _pov: Self::Player) -> Array<f32, Self::StateDim>
[src]
fn all_possible_moves(descr: &Self::Descriptor) -> Vec<Self::Move>
[src]
fn moves_to_feature(
descr: &Self::Descriptor,
moves: &HashMap<Self::Move, f32>
) -> Array<f32, Self::ActionDim>
[src]
descr: &Self::Descriptor,
moves: &HashMap<Self::Move, f32>
) -> Array<f32, Self::ActionDim>
fn all_feature_to_moves(
_descr: &Self::Descriptor,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
[src]
_descr: &Self::Descriptor,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
fn feature_to_moves(
&self,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
[src]
&self,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
impl<G> Features for Simulated<G> where
G: Features + 'static,
[src]
G: Features + 'static,
type StateDim = Ix3
type ActionDim = G::ActionDim
type Descriptor = (Ix3, G::Descriptor)
fn get_features(&self) -> Self::Descriptor
[src]
fn state_dimension(descr: &Self::Descriptor) -> Self::StateDim
[src]
fn action_dimension(descr: &Self::Descriptor) -> Self::ActionDim
[src]
fn state_to_feature(&self, _pov: Self::Player) -> Array<f32, Self::StateDim>
[src]
fn moves_to_feature(
descr: &Self::Descriptor,
moves: &HashMap<Self::Move, f32>
) -> Array<f32, Self::ActionDim>
[src]
descr: &Self::Descriptor,
moves: &HashMap<Self::Move, f32>
) -> Array<f32, Self::ActionDim>
fn feature_to_moves(
&self,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
[src]
&self,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
fn all_possible_moves(descr: &Self::Descriptor) -> Vec<Self::Move>
[src]
fn all_feature_to_moves(
descr: &Self::Descriptor,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
[src]
descr: &Self::Descriptor,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
impl<G: Features + Clone + Sync + Send> Features for WithHistory<G>
[src]
type StateDim = <G::StateDim as Dimension>::Larger
type ActionDim = G::ActionDim
type Descriptor = (<G::StateDim as Dimension>::Larger, G::Descriptor)
fn get_features(&self) -> Self::Descriptor
[src]
fn state_dimension(descr: &Self::Descriptor) -> Self::StateDim
[src]
fn action_dimension(descr: &Self::Descriptor) -> Self::ActionDim
[src]
fn state_to_feature(&self, pov: Self::Player) -> Array<f32, Self::StateDim>
[src]
fn moves_to_feature(
descr: &Self::Descriptor,
moves: &HashMap<Self::Move, f32>
) -> Array<f32, Self::ActionDim>
[src]
descr: &Self::Descriptor,
moves: &HashMap<Self::Move, f32>
) -> Array<f32, Self::ActionDim>
fn feature_to_moves(
&self,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
[src]
&self,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
fn all_feature_to_moves(
descr: &Self::Descriptor,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>
[src]
descr: &Self::Descriptor,
features: &Array<f32, Self::ActionDim>
) -> HashMap<Self::Move, f32>