项目作者: if-h4102

项目描述 :
Several AIs foor the othello game
高级语言: Prolog
项目地址: git://github.com/if-h4102/ai-othello.git
创建时间: 2016-11-22T07:06:04Z
项目社区:https://github.com/if-h4102/ai-othello

开源协议:GNU Affero General Public License v3.0

下载


AI Othello

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).

Overview

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:

  1. A totally random AI.
  2. Another random AI.
  3. A deterministic AI.
  4. 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.

Usages

1. Play using the console

  1. > 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:

  1. > ?- main:run.

Example: (Human versus min-max AI)

  1. What is the type of the first player which will use the symbol x ?
  2. Type -1 for a human player or a number between 0 and 3 to select an ai with the given level.
  3. |: -1.
  4. What is the type of the second player which will use the symbol o ?
  5. Type -1 for a human player or a number between 0 and 3 to select an ai with the given level.
  6. |: 3.
  7. 1 2 3 4 5 6 7 8
  8. ---------------------------------
  9. 1 | | | | | | | | |
  10. ---------------------------------
  11. 2 | | | | | | | | |
  12. ---------------------------------
  13. 3 | | | | | | | | |
  14. ---------------------------------
  15. 4 | | | | x | o | | | |
  16. ---------------------------------
  17. 5 | | | | o | x | | | |
  18. ---------------------------------
  19. 6 | | | | | | | | |
  20. ---------------------------------
  21. 7 | | | | | | | | |
  22. ---------------------------------
  23. 8 | | | | | | | | |
  24. ---------------------------------
  25. number of tokens - o : 2 | X : 2
  26. You use the symbol : x
  27. At which abscissa do you want to play ?
  28. |: 3.
  29. At which ordinate do you want to play ?
  30. |: 5.
  31. 1 2 3 4 5 6 7 8
  32. ---------------------------------
  33. 1 | | | | | | | | |
  34. ---------------------------------
  35. 2 | | | | | | | | |
  36. ---------------------------------
  37. 3 | | | | | | | | |
  38. ---------------------------------
  39. 4 | | | | x | o | | | |
  40. ---------------------------------
  41. 5 | | | x | x | x | | | |
  42. ---------------------------------
  43. 6 | | | | | | | | |
  44. ---------------------------------
  45. 7 | | | | | | | | |
  46. ---------------------------------
  47. 8 | | | | | | | | |
  48. ---------------------------------
  49. number of tokens - o : 1 | X : 4
  50. 1 2 3 4 5 6 7 8
  51. ---------------------------------
  52. 1 | | | | | | | | |
  53. ---------------------------------
  54. 2 | | | | | | | | |
  55. ---------------------------------
  56. 3 | | | | | | | | |
  57. ---------------------------------
  58. 4 | | | | x | o | | | |
  59. ---------------------------------
  60. 5 | | | x | o | x | | | |
  61. ---------------------------------
  62. 6 | | | o | | | | | |
  63. ---------------------------------
  64. 7 | | | | | | | | |
  65. ---------------------------------
  66. 8 | | | | | | | | |
  67. ---------------------------------
  68. number of tokens - o : 3 | X : 3
  69. You use the symbol : x
  70. At which abscissa do you want to play ?
  71. |:

And so on until the end of the game.

2. Play using a graphical interface

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.

Launch the server

Just run

  1. swipl src\server.pl

Launch the graphical interface

First please install Node.js

  1. git clone https://github.com/Sn0wFox/ai-othello-web-gui.git
  2. cd ai-othello-web-gui
  3. npm install -g gulp typescript typings
  4. npm install
  5. typings install
  6. gulp build
  7. node build\server.js

Go to the provided URL in your favorite browser

Usually http://localhost:3000/.

Then enjoy.

Overview

Here’s what it looks like:

ihm

3. Performances

You’ll need to have pyhton installed.

  1. > py src\profile.py

Please note that advanced AIs are slower, and so performances tests

4. Tests

To run all the tests, just run

  1. swipl test/main.pl

5. Debug mode

  1. > swipl src/main.pl

From here you can access everything. (you will first have to play a game)

Requierements - SWIprolog

Install

Ubuntu

  1. sudo apt-get install swiprolog

can be used with the command: ‘prolog’

for more information please read ‘man’

Windows

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.

Usage

Just run

  1. swipl <whatever_you_need>

For more information, please take a look at this page.