Skip to content

danielvogler/rl_maze

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RL_maze

Escape a maze using (deep) reinforcement learning

Generates a grid maze, with start, finish and walls, which an agent has to navigate. The agent can move through the maze by performing actions and learning from them.

How-to

Pre-requisites

  • Install poetry for dependency management and install venv: poetry install
  • Open poetry shell: poetry shell Then run the desired Python commands.

Configuration

A complete configuration should be in root/config/ and consists of:

  • Config file: Maze settings, parameters, training
  • Maze file: Text file containing a maze with walls (1) and hallways (0) and other features.

Choose settings in root/config/<config_file>:

  • epochs
  • learning rate $\alpha$
  • discount rate $\gamma$
  • exploration vs. exploitation $\epsilon$
  • rewards

Custom mazes and configurations can easily be added.

Run

RLMaze can easily be used as follows:

from rlmaze.rlmaze import RLMaze
RLMaze(<config_file>).escape_maze()

to train on a maze. The maze can be visualized with:

Utils().visualize_maze(<config_file>)

Some test cases can be found in `root/tests/' and run with:

python tests/test_maze_diagonal.py

or

python tests/test_maze_13x13.py

Figures

Diagonal maze

Example image
Fig 1: Diagonal maze layout with start (S) and finish (F).

Example image
Fig 2: Diagonal maze training (deep RL). Convergence to optimal number of steps (8).

Example image
Fig 2: Diagonal maze training (Classic Q-learning). Convergence to optimal number of steps (8).

13x13 maze

Example image
Fig 3: Diagonal maze layout with start (S) and finish (F).

Example image
Fig 4: 13x13 maze training (Classic Q-learning). Convergence to optimal number of steps (20).

Releases

No releases published

Packages

 
 
 

Contributors

Languages