This project demonstrates a reinforcement learning environment for a Cops and Robbers game using Python. The environment simulates a simple grid world where a cop tries to catch a robber.
The Cops and Robbers project simulates a grid world environment where agents (cops and robbers) interact. The cop's goal is to catch the robber, while the robber aims to evade capture. The project utilizes reinforcement learning techniques to train agents in this environment.
- Python 3.11
- Required Python libraries are listed in
requirements.txt
-
Clone the repository:
git clone https://github.com/chirag1701/cops_and_robbers_rl.git cd cops_and_robbers_rl
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
To run the environment test, execute the following command:
python cop_robbers_RL.ipynb
The script will initialize the environment, run a test episode, and print the results to the console.
Step 1
=======================
| . . . . . . . . . . |
| . . . . . . . . . . |
| . . . . . . . . . . |
| . . . . . . . . . . |
| C . . . . . . . . . |
| . . . . . . . . . . |
| . . . . . . . . . . |
| . . . . . . . . . . |
| . . . . . . . . . R |
| . . . . . . . . . . |
=======================
Actions: {'cop': 2, 'robber': 3}, Rewards: {'cop': -1, 'robber': 1}
...
The training results are logged and displayed during the simulation, showing various metrics such as episode length mean, reward mean, and loss values. The environment visualization updates at each step, showing the positions of the cop and robber.
Chirag Sindhwani
Dept of Electrical Engineering
IIT BHU , Varanasi, India