[][src]Trait ggpf::game::Features

pub trait Features: Game {
    type StateDim: Dimension;
    type ActionDim: Dimension;
    type Descriptor: Send + Sync + Clone;
    fn get_features(&self) -> Self::Descriptor;
fn state_dimension(descr: &Self::Descriptor) -> Self::StateDim;
fn action_dimension(descr: &Self::Descriptor) -> Self::ActionDim;
fn state_to_feature(&self, pov: Self::Player) -> Array<f32, Self::StateDim>;
fn moves_to_feature(
        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>;
fn all_possible_moves(descr: &Self::Descriptor) -> Vec<Self::Move>;
fn all_feature_to_moves(
        descr: &Self::Descriptor,
        features: &Array<f32, Self::ActionDim>
    ) -> HashMap<Self::Move, f32>; fn move_to_feature(
        descr: &Self::Descriptor,
        action: Self::Move
    ) -> Array<f32, Self::ActionDim> { ... } }

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.

Loading content...

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>

Converts an action probability distribution to the action features.

fn feature_to_moves(
    &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>

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.

Loading content...

Provided methods

fn move_to_feature(
    descr: &Self::Descriptor,
    action: Self::Move
) -> Array<f32, Self::ActionDim>

Converts a single move to a one-hot feature encoding of the move.

Loading content...

Implementors

impl Features for Breakthrough[src]

type StateDim = Ix3

type ActionDim = Ix3

type Descriptor = usize

impl Features for Gym[src]

type StateDim = Ix3

type ActionDim = Ix1

type Descriptor = (Vec<usize>, Ix3, Ix1)

impl<G> Features for Simulated<G> where
    G: Features + 'static, 
[src]

type StateDim = Ix3

type ActionDim = G::ActionDim

type Descriptor = (Ix3, G::Descriptor)

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)

Loading content...