Welcome to the Practicum Repo for the Fall 2021 AI 4701 Course. Authored by Yoona Chang, Junho Kim-Lee and Ashley Park.
This repo contains an AI checkers program that supports player v player, player v computer and computer v computer game modes. The computer can utilize either a minimax algorithm with customizable depth or a different minimax algorithm with custom-buitl heuristics, designed to make it smarter with less computational time.
Run make install
to install requirements.
Run python3 main.py
to play the game. This command requires 2 input args and optionally 5 additional input args. For example, both commands are valid:
python3 main.py a b
python3 main.py a b c d e f g
a
can be any int between 0 and 19. This arg determines the type of player controlling the red pieces. 0 indicates that red will be a human player. Any int between 1 and 9 inclusive indicates that red will be a computer player utilizing the base minimax algorithm with a depth ofa
. Any int between 10 and 19 inclusive indicates that red will be a computer play utilizing the minimax algorithm with custom heuristics at a depth equal to the second digit ofa
. So, a value ofa
=14 will represent the minimax algorithm with custom heuristics at a depth of 4.b
can be any int between 0 and 19. This arg determines the type of player controlling the white pieces. The input arg is interpreted the same asa
but for white.c
can be any int. This arg determines how the king advantage factor is weighted in the board evaluation for the custom heuristic minimax algorithm. The formula for convertingc
to a weight isc
/4. That means that ifc
=3, then the king advantage factor is multiplied by 3/4.d
can be any int. This is the same as forc
but it weights the move advantage factor.e
can be any int. This is the same as forc
but it weights the board control factor.f
can be any int. This is the same as forc
but it weights the vulnerability factor.g
can be any int. This is the same as forc
but it weights the home row control factor.
The base heuristic takes into account the following factors when evaluating the board state:
- Piece advantage - how many pieces each player has
- King advantage - how many kings each player has
The custom heuristic additionally takes into account the following factors:
- Move advantage - how many valid moves are available to each player
- Board control - how many squares are in range of each player's pieces
- Vulnerability - how many of each player's pieces are presently vulnerable to capture on the next move
- Home row control - how many squares on each player's home row are occupied by that player's piece
Run make zip
to zip the program.
depth_experimenter.sh
is a program that simulates games at different depth values and heuristic parameters. It outputs the results to a CSV called output.csv
. To run the test file, enter the test
directory and run ./depth_experimenter.sh
. The output file contains rows of data. Each row possesses 7 values. In order, they represent:
- Red depth
- Red heuristic #
- White depth
- White heuristic #
- Number of red wins
- Number of white wins
- Number of draws.
parameter_finder.sh
is used to calculate optimal tuning parameters for the AI minimax algorithm with custom heuristics. To run the test file, enter the test
directory and run ./parameter_finder.sh
. The output.csv
file it produces contains rows where each row corresponds to the 5 heuristic parameters in order followed by an integer score that represents how successful those parameter weights were. The last line repeats the row of data that contains the highest score. The 5 heuristic parameters in order are the last 5 parameters listed above, in that order (starting with king advantage).