https://github.com/if-h4102/ai-othello
Note for people reading this outside of GitHub: this is a MarkDown file. You can read it as raw text, but it's more convenient to use some browser plugin or simply read it directly on GitHub (see the previous link).
This app allows two players to play an Othello game, also known as Reversi.
The two players can be human or one of the developped AIs:
- A totally random AI.
- Another random AI.
- A deterministic AI.
- An AI using the min-max algorithm.
Note that the more the AI's number is high, the more it's supposed to be efficient.
You'll find how to play the game in the following section.
> swipl src/main.pl
Then follow instructions to setup players (-1 for human player, [0, .., 3] for AI) and play.
Once the gave finished you can start an other one by calling on the prolog interpreter:
> ?- main:run.
Example: (Human versus min-max AI)
What is the type of the first player which will use the symbol x ?
Type -1 for a human player or a number between 0 and 3 to select an ai with the given level.
|: -1.
What is the type of the second player which will use the symbol o ?
Type -1 for a human player or a number between 0 and 3 to select an ai with the given level.
|: 3.
1 2 3 4 5 6 7 8
---------------------------------
1 | | | | | | | | |
---------------------------------
2 | | | | | | | | |
---------------------------------
3 | | | | | | | | |
---------------------------------
4 | | | | x | o | | | |
---------------------------------
5 | | | | o | x | | | |
---------------------------------
6 | | | | | | | | |
---------------------------------
7 | | | | | | | | |
---------------------------------
8 | | | | | | | | |
---------------------------------
number of tokens - o : 2 | X : 2
You use the symbol : x
At which abscissa do you want to play ?
|: 3.
At which ordinate do you want to play ?
|: 5.
1 2 3 4 5 6 7 8
---------------------------------
1 | | | | | | | | |
---------------------------------
2 | | | | | | | | |
---------------------------------
3 | | | | | | | | |
---------------------------------
4 | | | | x | o | | | |
---------------------------------
5 | | | x | x | x | | | |
---------------------------------
6 | | | | | | | | |
---------------------------------
7 | | | | | | | | |
---------------------------------
8 | | | | | | | | |
---------------------------------
number of tokens - o : 1 | X : 4
1 2 3 4 5 6 7 8
---------------------------------
1 | | | | | | | | |
---------------------------------
2 | | | | | | | | |
---------------------------------
3 | | | | | | | | |
---------------------------------
4 | | | | x | o | | | |
---------------------------------
5 | | | x | o | x | | | |
---------------------------------
6 | | | o | | | | | |
---------------------------------
7 | | | | | | | | |
---------------------------------
8 | | | | | | | | |
---------------------------------
number of tokens - o : 3 | X : 3
You use the symbol : x
At which abscissa do you want to play ?
|:
And so on until the end of the game.
We developped a graphical interface separatly (you'll find it here). To do so, we created a prolog server using a REST API.
Here are the developped endpoints:
- GET /api/board/initial
- POST /api/board/update
- POST /api/play
- POST /api/play/validate
- POST /api/play/able
They are very well documented on the file src/server.pl
.
Just run
swipl src\server.pl
First please install Node.js
git clone https://github.com/Sn0wFox/ai-othello-web-gui.git
cd ai-othello-web-gui
npm install -g gulp typescript typings
npm install
typings install
gulp build
node build\server.js
Usually http://localhost:3000/
.
Then enjoy.
Here's what it looks like:
You'll need to have pyhton installed.
> py src\profile.py
Please note that advanced AIs are slower, and so performances tests
To run all the tests, just run
swipl test/main.pl
> swipl src/main.pl
From here you can access everything. (you will first have to play a game)
sudo apt-get install swiprolog
can be used with the command: 'prolog'
for more information please read 'man'
Download the msi-installer you need here.
Be sure to update your PATH
environment variable to include the path to the executable file swipl-win.exe
.
Just run
swipl <whatever_you_need>
For more information, please take a look at this page.