Skip to content

TahaRha/AI-chessboard-agent

Repository files navigation

Colosseum Survival!

Setup

To setup the game, clone this repository and install the dependencies:

pip install -r requirements.txt

Playing a game

To start playing a game, we will run the simulator and specify which agents should complete against eachother. To start, several agents are given to you, and you will add your own following the same game interface. For example, to play the game using two copies of the provided random agent (which takes a random action every turn), run the following:

python simulator.py --player_1 random_agent --player_2 random_agent

This will spawn a random game board of size NxN, and run the two agents of class RandomAgent. You will be able to see their moves in the console.

Visualizing a game

To visualize the moves within a game, use the --display flag. You can set the delay (in seconds) using --display_delay argument to better visualize the steps the agents take to win a game.

python simulator.py --player_1 random_agent --player_2 random_agent --display

Play on your own!

To take control of one side of the game and compete against the random agent yourself, use a human_agent to play the game.

python simulator.py --player_1 human_agent --player_2 random_agent --display

Autoplaying multiple games

There is some randomness (coming from the initial game setup and potentially agent logic), so go fairly evaluate agents, we will run them against eachother multiple times, alternating their roles as player_1 and player_2, and on boards are drawn randomly (between size 6 and 12). The aggregate win % will determine a fair winner. Use the --autoplay flag to run $n$ games sequentially, where $n$ can be set using --autoplay_runs.

python simulator.py --player_1 random_agent --player_2 random_agent --autoplay

During autoplay, boards are drawn randomly between size --board_size_min and --board_size_max for each iteration. You may try various ranges for your own information and development by providing these variables on the command-line. However, the defaults (to be used during grading) are 6 and 12, so ensure the timing limits are satisfied for every board in this size range.

Notes

  • Not all agents supports autoplay. The variable self.autoplay in Agent can be set to True to allow the agent to be autoplayed. Typically this flag is set to false for a human_agent.
  • UI display will be disabled in an autoplay.

Full API

python simulator.py -h       
usage: simulator.py [-h] [--player_1 PLAYER_1] [--player_2 PLAYER_2]
                    [--board_size BOARD_SIZE] [--display]
                    [--display_delay DISPLAY_DELAY]

optional arguments:
  -h, --help            show this help message and exit
  --player_1 PLAYER_1
  --player_2 PLAYER_2
  --board_size BOARD_SIZE
  --display
  --display_delay DISPLAY_DELAY
  --autoplay
  --autoplay_runs AUTOPLAY_RUNS

About

AI chessboard agent

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published