To setup the game, clone this repository and install the dependencies:
pip install -r requirements.txt
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.
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
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
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 --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 toTrue
to allow the agent to be autoplayed. Typically this flag is set to false for ahuman_agent
. - UI display will be disabled in an autoplay.
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