In this project, I implemented various AI algorithms for Gomoku, an extension of Tic Tac Toe. I have also completed a previous project on Tic Tac Toe, which can be found here: TicTacToe.
To set up the environment for this project, follow these steps:
- Install and setup conda.
- Create environment.
conda create --name tictactoe python=3.8.19
conda activate tictactoe
pip install -r requirements.txt
- game.py: Contains the core game logic.
- gameplay.py: Manages game interactions between players, including both AI and human players.
- player.py: Defines an abstract class from which custom agents will be implemented.
- gomoku: Contains the AI agents that are to be developed and customized.
- bots: Includes pre-built Gomoku bots that can be used to evaluate the performance of agents.
- Example usage
python main.py -p1 master -p2 intermediate -n 4 -m ui
- Options
python main.py -p1 [PLAYER_1] -p2 [PLAYER_2] -m [VISUALIZATION] -n [NUM_GAMES] -t [TIMEOUT] -s [SIZE]
-
--player1or-p1: Choose player 1. -
--player1or-p1: Choose player 2.- Choices of player: 'minimax', 'alphabeta', 'mcts', 'qlearning', 'human', 'random'.
-
--modeor-m: Choose visualization mode ('silent', 'plain', or 'ui').- 'silent' only shows game result (not possible for human player).
- 'plain' shows the game state in terminal.
- 'ui' shows the game with integrated UI.
-
--num_gamesor-n: Number of games for evaluations. Not that players will be assigned 'X' and 'O' alternately between games. -
--timeoutor-t: Set timeout for each AI move. No timeout is set for Human move. Default is 10 seconds per move. -
--no_timeoutor-nt: No timeout for AI move. -
--sizeor-s: Size of the board for Gomoku (default=15). -
--loador-l: Load the Q table for Tabular Q-Learning agent, for weights for the features in Approximate Q-Learning agent. You should give only the file name of the weight to this argument. -
--no_train: No training for Q-Learning agents.
- Evaluation
python evaluation.py -p [PLAYER]
To evaluate AI agents using hand-crafted test cases, the output of the evaluation is saved in the evaluation folder.
--loador-l: Loads the Q table for the Tabular Q-Learning agent or weights for the features in the Approximate Q-Learning agent. Only the file name of the weights should be provided for this argument.--no_train: Disables training for the Q-Learning agents.
