Toefish is a small Tic-Tac-Toe evaluation bot written in C.
It can look at a board state and tell you the result or the best move.
--- skibidi
git clone https://github.com/Dantoza/Toefish.git
cd Toefish
gcc -o toefish toefish.c -lcjson./toefish <args> <file path>- -e Evaluate mode: finds the fastest way to "mate" and tells you if the game is a forced draw.
- -m Move mode: finds and returns the best next move.
Toefish uses the minimax algorithm to find the best possible move assuming that two perfect players are playing. Since tic-tac-toe is a solved game, instead giving a score like stockfish, toefish can predict every move untill the end of the game, always finding the fastest mate for any player if its possible
-
Evaluate mode: finds the fastest way to "mate" and tells you if the game is a forced draw(-e argument/flag when running the program)
-
Play mode: finds the best next move( -m argument/flag when running the program)
{
"0": "X",
"1": "O",
"2": "X",
"3": "O",
"4": "X",
"5": "O",
"6": "X",
"7": "O",
"8": "_"
}which is the equivalent to:
0 | 1 | 2
---+---+---
3 | 4 | 5
---+---+---
6 | 7 | 8
Important
JSON board state is deprecated and getting replaced by [danilo napis kle notr kako se ta tvoj fancy format imenuje]
To compile toefish, you need to install the cJSON, since the code needs to parse the JSON.
For better explanation of how to install the library, please reffer to the cJSON repo.
For installing on Windows, you can use CMake,for Linux you can use either CMake or, if supported, install it from your package manager:
sudo apt-get update
sudo apt-get install libcjson-devsudo pacman -S cjsonsudo dnf install cjson-develsudo zypper install cjson-develIf your distribution does not provide a package/you are using Windows, you can build cJSON from source:
git clone https://github.com/DaveGamble/cJSON.git
cd cJSON
mkdir build && cd build
cmake ..
make
sudo make install- Implement alpha-beta pruning to optimize the code
- Add an addittional option to output the next-move board state into a new file for easier implementation with GUIs
- Improve the JSON format or switch the format entirely for something better used for smaller amounts of data(possibly removing the dependency on cJSON)
- Add 4th board state to fully use the 2 bits in proprietary format (use?)
- publishing the program to Linux and Windows repositories such as scoop.sh , Debian archive, AUR,...
This project is under the GPL-3.0 License.
See the LICENSE file for details.
Made by Dantoza 🎣