This project started as a simple endeavor for my 7th grade science fair. Six years later, I've revisited it to enhance and refine the original code. The result is a more efficient and elegantly structured algorithm. I've further refactored the project into an extendable engine library, allowing for uniform testing of various AI algorithms.
To play the game, run
python engine.py
which will use new.NewEngine
by default, but you can edit to it use old.OldEngine
or a brand new one you create
(instructions below)!
You can also play the original version created 6 years ago (although slightly cleaned up) by running
original_pygame.py
.
To create your own AI engine, follow these steps:
- Create a new class (e.g.,
your_engine.YourEngine
) that extendsbase_engine.BaseEngine
. - Implement the
ai_turn
method, with a parametertesting=False
to disable debug output during testing.
Tip
Feel free to create additional functions to assist with your AI logic implementation.
- Next, modify
engine.py
to use your new engine by adding the following code:
import your_engine
Engine = your_engine.YourEngine
Caution
Adjust the num_games
variable in tester.py
according to your computer's performance. This will allow you to test
fewer or more games as needed.
- To test your engine, run
tester.py
with the command:
python tester.py
Important
Do not edit base_engine.py
or tester.py
unless you are fixing a bug or adding a feature to the engine library.
base_engine.py
: Contains the base engine class that all AI engines must extend.tester.py
: Contains the testing logic for the AI engine.engine.py
: Contains the engine class that the tester uses.
original_pygame.py
: A barely cleaned-up version of the original code from the 7th grade science fair project. Not compatible with the engine library.original_cli.py
: A cleaned-up version of the original code from the 7th grade science fair project. Not compatible with the engine library.original.py
: A port oforiginal_cli.py
. Compatible with the engine library.new.py
: A complete rewrite of the original code using cleaner and more efficient logic. Compatible with the engine library.
This project is licensed under the GNU General Public License v3.0. For more information, see the LICENSE
file.