ICS3U Independant Study Unit at Villanova College - Tic-Tac-Toe
- A universal board framework with high extensibility
- Scalable rendering
- Score counter
- Input error detection
- A robust bot
- Optional real AI (not if-else)
- Extremely standardized code formatting
See CSISU23.md.
Make sure you set the working directory to the root of the project.
python3 main.py
Make sure you set the working directory to the root of the project.
python3 train.py
The script does not support CUDA acceleration for now.
You will have to install PyTorch and edit main.py
.
-
Locate the following lines
player_a, rd_dir_a = choose_player("A", 0) player_b, rd_dir_b = choose_player("B", 1)
-
Change the lines above to the following
player_a, rd_dir_a = choose_player("A", 0, ai_bot=True) player_b, rd_dir_b = choose_player("B", 1, ai_bot=True)
-
Locate the following lines
(player_a if board.get_round_counter() % 2 == 0 else player_b).go(board) print(board)
-
Insert the following code after the first line
if type(player_a) != HumanPlayer: player_a.step(board) if type(player_b) != HumanPlayer: player_b.step(board)
It should look like this finally:
(player_a if board.get_round_counter() % 2 == 0 else player_b).go(board) if type(player_a) != HumanPlayer: player_a.step(board) if type(player_b) != HumanPlayer: player_b.step(board) print(board)
-
Append the following code to the end of the file
if type(player_a) != HumanPlayer: player_a.clear() if type(player_b) != HumanPlayer: player_b.clear()
Make sure it is under the
while True
loop.
Notice that the model file must exist as .model/23mxx.pth
. You will find trained models under the folder model
.
Rename the model you pick to 23mxx.pth
so that the program can find it successfully.
For more information see Extension - Real AI.md.