Final project for CS4100: Artificial Intelligence. Contains code for various AI agents that use the minimax algorithm with alpha-beta pruning and a neural network to play a game of Reversi.
Run pip install pygame==2.1.2
or pip install -r requirements.txt
from the root directory.
The available agents are:
manual
: the player manually chooses each moverandom
: randomly select a move from the list of possible movesmost_disks
: select a move resulting in flipping the most number of the opponent's disksmobility
: select a move that maximizes the number of moves for the playerpositional
: select a move based on a grid of weights, with moves with higher total values more likely to be selectedstability
: select a move that maximizes the number of immovable disks on the boardradius
: randomly select a move, weighted by distance from center of board (moves farther away from the center of the board are more likely to be selected)superior
: acts similar to a mobility agent in the beginning phase of the game and switches first to a positional agent, thena a most disks agent based on the number of disks on the boardneural
: uses a convolutional neural network using TensorFlow to output the optimal move from the given game state
Required options:
-b _agent_ [_minimax_agent_ _minimax_depth_]
or--black _agent_ [_minimax_agent_ _minimax_depth_]
: specifies the agent that black should use in the game-w _agent_ [_minimax_agent_ _minimax_depth_]
or--white _agent_ [_minimax_agent_ _minimax_depth_]
: specifies the agent that white should use in the game
If using a minimax agent, then two additional arguments need to be passed in in addition to minimax
to specify which agent's evaluation function to use the minimax algorithm for as well as the maximum depth to reach in the minimax tree before applying the evaluation function to the game states.
Additional options:
-r _num_rounds_
or--repeat _num_rounds_
: specifies the number of rounds of the game to run. Default is 1-i
or--interactive
: whether to run the game(s) in interactive mode (using a graphical user interface) or on the command line-s
or--slow
: whether to run the game(s) in slow mode (stops the program execution for 1 second in between moves). Ignored when the-i
option is passed in
For example, python src/main.py -b most_disks -w minimax random 3 -i
or python src/main.py -b stability -w superior -r 100