- mazeR.R has the original script in https://github.com/matfmc/mazegenerator.
- It has been modified to make the maze narrower.
- Purpose: To simulate a player's random step in the maze.
Objects of interest
- N: Total number of simulations.
- xx e yy: Board size.
- ini: Initial game conditions (simple random sampling without replacement).
- first_plot: Starting plot of the board.
- results: Outputs of the simulations already organized to be used in Machine Learning.
- game: Conditions played.
- Red: Player's position.
- Green: Entrance to the maze.
- Blue: Exit the maze.
Functions:
get_game(nb, input, exit, position)
- Purpose: To create the maze by adding input, output and position of the player.
- nb: Simplified maze board.
- input: Coordinate of entrance of the labyrinth.
- exit: Coordinate of exit from the labyrinth.
- position: Character's current position.
- Inside get_game() has fobj(), an objective function, which scores the reward.
get_result_state(results)
- Purpose: To organize game information.
- results: Collection of some matches for the same board.
plot_maze(board_cells, input, exit, boxes)
- Purpose: Plot the game using ggplot. In the generated graph the lines are in reverse coordinate of the board. X axis represents columns and y axis lines.
- board_cells: Board generated by mazeR.R.
- entrance: Coordinate of entrance of the labyrinth.
- exit: Coordinate of exit from the labyrinth.
- boxes: Matrix containing valid coordinates in random walk.
plot_update(first_plot, position)
- Purpose: Update the player's position on the graph.
- first_plot: Object that stores the first plot_maze().
- position: Player's current position.
get_pos(position)
- Purpose: Returns the current position.
get_moves(position, nb)
- Purpose: Given the current position, return the possible movements.
- position: Character's current position.
- nb: Simplified maze board.
nb_update(nb, input, exit, position)
- Purpose: Update the player's position on the board.
- nb: Simplified maze board.
- input: Coordinate of entrance of the labyrinth.
- exit: Coordinate of exit from the labyrinth.
- position: Character's current position.