AIToolbox
A library that offers tools for AI problem solving.
AIToolbox::MDP::GridWorld Class Reference

This class represents a simple rectangular gridworld. More...

#include <AIToolbox/MDP/Environments/Utils/GridWorld.hpp>

Classes

struct  State
 

Public Types

using Direction = GridWorldUtils::Direction
 

Public Member Functions

 GridWorld (unsigned width, unsigned height, bool torus=false)
 Basic constructor. More...
 
State getAdjacent (Direction d, State s) const
 This function returns the state next to the input in the chosen Direction. More...
 
State getAdjacent (size_t d, State s) const
 This function uses size_t to pass the direction. More...
 
unsigned distance (const State &s1, const State &s2) const
 This function returns the Manhattan distance between the two states. More...
 
State operator() (int x, int y) const
 This function returns the State at the selected position. More...
 
State operator() (const size_t s) const
 This function returns the State with the input numerical representation. More...
 
unsigned getWidth () const
 This function returns the width of the GridWorld. More...
 
unsigned getHeight () const
 This function returns the height of the GridWorld. More...
 
bool isTorus () const
 This function returns whether the GridWorld represents a torus. More...
 
size_t getS () const
 This function returns the number of cells in the grid. More...
 

Detailed Description

This class represents a simple rectangular gridworld.

Member Typedef Documentation

◆ Direction

Constructor & Destructor Documentation

◆ GridWorld()

AIToolbox::MDP::GridWorld::GridWorld ( unsigned  width,
unsigned  height,
bool  torus = false 
)

Basic constructor.

Parameters
widthThe number of columns in the world.
heightThe number of rows in the world.
torusWhether to join the edges of the grid as in a torus.

Member Function Documentation

◆ distance()

unsigned AIToolbox::MDP::GridWorld::distance ( const State s1,
const State s2 
) const

This function returns the Manhattan distance between the two states.

Returns
The distance between the input states.

◆ getAdjacent() [1/2]

State AIToolbox::MDP::GridWorld::getAdjacent ( Direction  d,
State  s 
) const

This function returns the state next to the input in the chosen Direction.

This function returns the same state if the Direction goes outside the Grid boundaries.

Parameters
dThe Direction to look for.
sThe initial State.
Returns
The State next to the input.

◆ getAdjacent() [2/2]

State AIToolbox::MDP::GridWorld::getAdjacent ( size_t  d,
State  s 
) const

This function uses size_t to pass the direction.

Parameters
dThe Direction to look for.
sThe initial State.
Returns
The State next to the input.

◆ getHeight()

unsigned AIToolbox::MDP::GridWorld::getHeight ( ) const

This function returns the height of the GridWorld.

◆ getS()

size_t AIToolbox::MDP::GridWorld::getS ( ) const

This function returns the number of cells in the grid.

◆ getWidth()

unsigned AIToolbox::MDP::GridWorld::getWidth ( ) const

This function returns the width of the GridWorld.

◆ isTorus()

bool AIToolbox::MDP::GridWorld::isTorus ( ) const

This function returns whether the GridWorld represents a torus.

◆ operator()() [1/2]

State AIToolbox::MDP::GridWorld::operator() ( const size_t  s) const

This function returns the State with the input numerical representation.

Parameters
sThe State numerical representation.

◆ operator()() [2/2]

State AIToolbox::MDP::GridWorld::operator() ( int  x,
int  y 
) const

This function returns the State at the selected position.

Coordinates are bound to the size of the GridWorld.

Parameters
xThe x of the output State.
yThe y of the output State.

The documentation for this class was generated from the following file: