Skip to content

A Wumpus World game with an AI agent that plays it.

Notifications You must be signed in to change notification settings

Evozone/wumpus-AI-agent

Repository files navigation

👻 Wumpus AI Agent

This is a Wumpus World game with an AI agent that plays it. The game is based on the classic Wumpus World game, where the player navigates a maze-like cave system to find gold while avoiding deadly pits and the Wumpus monster.

Table of Contents

Specifications

  • The game is played on a 4x4 grid of rooms (traditional Wumpus World is 4x4, but you can change this if you want).
  • This project has both a human playable version and an AI agent that plays the game.
  • Currently only a CLI version is available, but a GUI version is planned for the future.

Installation

You will need Python 3.7 or higher to run this project. You can download Python here.

To install the game, follow these steps:

  1. Fork the repository
  2. Clone the repository: git clone https://github.com/your-username/wumpus-AI-agent.git
  3. Navigate to the project directory: cd wumpus-AI-agent
  4. Install the dependencies: pip install -r requirements.txt

To learn more about forking and cloning repositories, see this article on GitHub.

Usage

  • Run the command python.exe main.py in the project root to start the application.
  • Follow the on-screen instructions to either
    1. Play the game yourself
    2. Watch the AI agent play the game
    3. Train the AI agent according to your own specifications

Playing the game yourself

  • The instructions for playing the game are displayed on-screen, and are pretty self-explanatory.

Watching the AI play

  • The AI agent cannot be watched until it has been trained.
  • If there is a trained AI agent available, then a winner_genome.pkl file will be present in the root directory.
  • If there is no trained AI agent available, then read Training the AI to learn how to train the AI agent, and generate a winner_genome.pkl file.

Training the AI

  • The AI agent is trained using NEAT.
  • The training parameters can be changed in the ai/config/neat_config.txt file.
  • More information about the NEAT configuration file can be found here.
  • To change the number of generations the AI agent is trained for, change the GENERATIONS parameter in the ai/neat_evo_process.py file.
...agent as ai_agent
import game.game as WuGame

# Number of generations to run the NEAT evolution process
GENERATIONS = 300

def run_neat(config_f...
  • To train the AI agent, run the command python.exe main.py in the project root.
    • Then select the option to train the AI agent.
    • Depending on the number of generations specified, the training process may take a while.
    • Here's an example of what the training process looks like:
   ****** Running generation 10 ******

Population's average fitness: -1103.15000 stdev: 64.57411
Best fitness: -1010.00000 - size: (10, 4) - species 1 - id 4994
Average adjusted fitness: 0.810
Mean genetic distance 2.058, standard deviation 0.305
Population of 500 members in 1 species:
   ID   age  size  fitness  adj fit  stag
  ====  ===  ====  =======  =======  ====
     1   10   500  -1010.0    0.810    10
Total extinctions: 0
Generation time: 0.098 sec (0.102 average)

 ****** Running generation 11 ******

Population's average fitness: -1196.99000 stdev: 203.35683
Best fitness: -1010.00000 - size: (10, 4) - species 1 - id 4994
Average adjusted fitness: 0.635
Mean genetic distance 2.114, standard deviation 0.216
Population of 500 members in 1 species:
   ID   age  size  fitness  adj fit  stag
  ====  ===  ====  =======  =======  ====
     1   11   500  -1010.0    0.635    11
Total extinctions: 0
Generation time: 0.130 sec (0.105 average)

  ****** Running generation 12 ******
  (And so on...)

At the end of the training process, a winner_genome.pkl file will be generated in the root directory. You may then proceed to Watching the AI play.

Contributing

If you would like to contribute to the project, please follow these steps:

  1. Fork the repository
  2. Create a new branch: git checkout -b my-new-feature
  3. Make your changes and commit them: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

To learn more about forking and cloning repositories, see this article on GitHub.

To learn more about creating pull requests, see this article on GitHub.

Project Contributors

Bhargav Modak
Bhargav Modak
Vishal Shinde
Vishal Shinde
E-Mail ↗️ E-Mail ↗️
Twitter Twitter