XCSF
1.4.7
XCSF learning classifier system
|
The discrete maze problem environment module. More...
Go to the source code of this file.
Macros | |
#define | MAX_PAYOFF (1.) |
The payoff provided at a food position. More... | |
Functions | |
static double | env_maze_sensor (const struct XCSF *xcsf, const char s) |
Returns a float encoding of a sensor perception. More... | |
void | env_maze_init (struct XCSF *xcsf, const char *filename) |
Initialises a maze environment from a specified file. More... | |
void | env_maze_free (const struct XCSF *xcsf) |
Frees the maze environment. More... | |
void | env_maze_reset (const struct XCSF *xcsf) |
Resets the animat to a random empty position in the maze. More... | |
bool | env_maze_is_done (const struct XCSF *xcsf) |
Returns whether the maze is in a terminal state. More... | |
const double * | env_maze_get_state (const struct XCSF *xcsf) |
Returns the current animat perceptions in the maze. More... | |
double | env_maze_execute (const struct XCSF *xcsf, const int action) |
Executes the specified action and returns the payoff. More... | |
double | env_maze_maxpayoff (const struct XCSF *xcsf) |
Returns the maximum payoff value possible in the maze. More... | |
bool | env_maze_multistep (const struct XCSF *xcsf) |
Returns whether the environment is a multistep problem. More... | |
Variables | |
static const int | x_moves [] = { 0, +1, +1, +1, 0, -1, -1, -1 } |
Maze x-axis moves. More... | |
static const int | y_moves [] = { -1, -1, 0, +1, +1, +1, 0, -1 } |
Maze y-axis moves. More... | |
The discrete maze problem environment module.
Reads in the chosen maze from a file where each entry specifies a distinct position in the maze. The maze is toroidal and if the animat reaches one edge it can reenter the maze from the other side. Obstacles are coded as 'O' and 'Q', empty positions as '*', and food as 'F' or 'G'. The 8 adjacent cells are perceived (encoded as reals) and 8 movements are possible to the adjacent cells (if not blocked.) The animat is initially placed at a random empty position. The goal is to find the shortest path to the food.
Some mazes require a form of memory to be solved optimally. The optimal average number of steps for each maze is:
Woods 1: 1.7
Woods 2: 1.7
Woods 14: 9.5
Maze 4: 3.5
Maze 5: 4.61
Maze 6: 5.19
Maze 7: 4.33
Maze 10: 5.11
Woods 101: 2.9
Woods 101 1/2: 3.1
Woods 102: 3.31
Maze F1: 1.8
Maze F2: 2.5
Maze F3: 3.375
Maze F4: 4.5
Definition in file env_maze.c.
#define MAX_PAYOFF (1.) |
The payoff provided at a food position.
Definition at line 55 of file env_maze.c.
double env_maze_execute | ( | const struct XCSF * | xcsf, |
const int | action | ||
) |
Executes the specified action and returns the payoff.
[in] | xcsf | The XCSF data structure. |
[in] | action | The action to perform. |
Definition at line 217 of file env_maze.c.
References EnvMaze::done, MAX_PAYOFF, EnvMaze::maze, x_moves, EnvMaze::xpos, EnvMaze::xsize, y_moves, EnvMaze::ypos, and EnvMaze::ysize.
void env_maze_free | ( | const struct XCSF * | xcsf | ) |
Frees the maze environment.
[in] | xcsf | The XCSF data structure. |
Definition at line 147 of file env_maze.c.
References EnvMaze::state.
const double* env_maze_get_state | ( | const struct XCSF * | xcsf | ) |
Returns the current animat perceptions in the maze.
[in] | xcsf | The XCSF data structure. |
Definition at line 187 of file env_maze.c.
References env_maze_sensor(), EnvMaze::maze, EnvMaze::state, EnvMaze::xpos, EnvMaze::xsize, EnvMaze::ypos, and EnvMaze::ysize.
void env_maze_init | ( | struct XCSF * | xcsf, |
const char * | filename | ||
) |
Initialises a maze environment from a specified file.
[in] | xcsf | The XCSF data structure. |
[in] | filename | The file name of the specified maze environment. |
Definition at line 100 of file env_maze.c.
References MAX_SIZE, EnvMaze::maze, param_init(), EnvMaze::state, EnvMaze::xsize, and EnvMaze::ysize.
Referenced by env_init().
bool env_maze_is_done | ( | const struct XCSF * | xcsf | ) |
Returns whether the maze is in a terminal state.
[in] | xcsf | The XCSF data structure. |
Definition at line 175 of file env_maze.c.
References EnvMaze::done.
double env_maze_maxpayoff | ( | const struct XCSF * | xcsf | ) |
Returns the maximum payoff value possible in the maze.
[in] | xcsf | The XCSF data structure. |
Definition at line 259 of file env_maze.c.
References MAX_PAYOFF.
bool env_maze_multistep | ( | const struct XCSF * | xcsf | ) |
Returns whether the environment is a multistep problem.
[in] | xcsf | The XCSF data structure. |
Definition at line 271 of file env_maze.c.
void env_maze_reset | ( | const struct XCSF * | xcsf | ) |
Resets the animat to a random empty position in the maze.
[in] | xcsf | The XCSF data structure. |
Definition at line 159 of file env_maze.c.
References EnvMaze::done, EnvMaze::maze, rand_uniform_int(), EnvMaze::xpos, EnvMaze::xsize, EnvMaze::ypos, and EnvMaze::ysize.
|
static |
Returns a float encoding of a sensor perception.
[in] | xcsf | The XCSF data structure. |
[in] | s | The char value of the sensor. |
Definition at line 74 of file env_maze.c.
Referenced by env_maze_get_state().
|
static |
|
static |