Skip to content

johndoknjas/Connect-Four-Engine

Repository files navigation

You can play Connect Four against this engine, either from the default empty starting position, or from random starting positions that already have a few pieces on them. These random positions are all deemed to be relatively fair, and I'd recommend this option. It's funner to play different starting positions, and also it prevents the user from learning as much from past games (which isn't that fair to the engine).

For Version 59 (the current version of the engine as of Feb 21, 2022), its score against me in games is 27 wins, 1 loss, and 1 draw (ratio of 18.33...). While I expect this ratio to go down a bit over time, this is still a dramatic increase in playing strength. The engine from Summer 2020 (Version 50) had a ratio between 4 and 5 against me, and the engine from January 2019 had a ratio between 3 and 4. The big part of the recent increase in playing strength is due to me using a new computer (much better speed), but I've also done some improvements of my own over the last month (most of which have been for optimizing the engine's speed).

For positions at and below 9 ply, the engine may communicate with a DB (via SQLite) to evaluate them and find a good move. This DB was generated by a previous version of the engine (V.41) that thought on each reachable 9 ply position, and then these results were used to generate data for all 0 to 8 ply positions as well.

The file was too large to upload to Github, but it can be downloaded here:

https://drive.google.com/file/d/1f0q-X5edDGx_Rh-TuJIHSRoRlc2R1WED/view?usp=sharing

After downloading, copy this DB file to some directory on your computer.

Also, please install sqlite3, if it's not on your computer. The program uses the splite3 C/C++ API to interface with the database.

After doing this, you can run a.exe directly, if you just want to play against the engine in the raw C++ ASCI interface. It's also possible to compile the C++ source code yourself. To do this, type the following in the terminal: g++ main.cpp -O2 -l sqlite3. This will generate a new a.exe file.

If you'd prefer to play using a Python GUI I built, go inside the python-gui directory and open the command prompt. If you don't have pyinstaller, install it with "pip install pyinstaller". Then type "pyinstaller interface.py" - we're only interested in the dist/interface directory that gets created. Copy the following files from /python-gui, and paste them into /python-gui/dist/interface: directory.txt, error_effect.wav, move_effect.wav, OngoingScore.txt, second_move_effect.wav, and signal.txt. Also, go back into the /Connect Four directory, and copy the a.exe file into /python-gui/dist/interface as well.

Then in /python-gui/dist/interface, open up the directory.txt file. Replace the line in it with the absolute path of where you downloaded the database onto your computer.

Finally, run interface.exe.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published