{"id":15493062,"url":"https://github.com/pchampio/othello-prolog","last_synced_at":"2026-02-18T11:33:04.609Z","repository":{"id":80616607,"uuid":"109761052","full_name":"pchampio/othello-prolog","owner":"pchampio","description":":scroll: A fully functional Othello (Reversi) game, with several AIs, made in prolog for swipl.","archived":false,"fork":false,"pushed_at":"2024-04-26T10:20:33.000Z","size":1495,"stargazers_count":17,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-11T22:16:24.397Z","etag":null,"topics":["alpha-beta","artificial-intelligence","board-game","logic-programming","minmax","othello-game","prolog","student-project","swipl","univ-lemans"],"latest_commit_sha":null,"homepage":"","language":"Prolog","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pchampio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-06T23:12:35.000Z","updated_at":"2025-08-13T01:31:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"d0062349-c38e-4404-8543-864a7c9dcb5b","html_url":"https://github.com/pchampio/othello-prolog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pchampio/othello-prolog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchampio%2Fothello-prolog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchampio%2Fothello-prolog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchampio%2Fothello-prolog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchampio%2Fothello-prolog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pchampio","download_url":"https://codeload.github.com/pchampio/othello-prolog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pchampio%2Fothello-prolog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29577929,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T08:38:15.585Z","status":"ssl_error","status_checked_at":"2026-02-18T08:38:14.917Z","response_time":162,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alpha-beta","artificial-intelligence","board-game","logic-programming","minmax","othello-game","prolog","student-project","swipl","univ-lemans"],"created_at":"2024-10-02T08:03:58.282Z","updated_at":"2026-02-18T11:32:59.598Z","avatar_url":"https://github.com/pchampio.png","language":"Prolog","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Othello Prolog\n\n\u003e A fully functional [Othello game](https://en.wikipedia.org/wiki/Reversi), with several AIs, made for the [swi prolog interpreter](http://www.swi-prolog.org/)\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/Drakirus/othello-prolog/blob/master/demo.gif\"\u003e\n    \u003cimg alt=\"ScreenShot~ demo\" src=\"./demo.gif\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Overview\n\nThis app allows 2 players to play an Othello game.\n\n\u003e During de pre-game menu the admin can set the two players to human or AIs. \n\u003e\n\u003e\n\u003e `-- Set the Player x to be a --`  \n\u003e  `1. Human`  ---\u003e User input. [prompt.pl](./game/prompt.pl)  \n\u003e  `2. Bot (random)`    ---\u003e A totally random AI. [random.pl](./ai/random.pl)   \n\u003e  `3. Bot (minmax)`    ---\u003e An AI using the min-max algorithm. [minmax.pl](./ai/minmax.pl)  \n\u003e  `4. Bot (alphabeta)` ---\u003e An AI using the alpha-beta algorithm. [alphabeta.pl](./ai/alphabeta.pl)  \n\n## Usage\n\n### Play\nLoad the file in the swipl-interpreter:\n```\n$ swipl ./othello.pl\n```\nPlay the game:\n```\n\u003e?- play.\n```\n\n## Things about this implementation\n\n### Heuristic/Evaluation function \n\nI used [this](https://courses.cs.washington.edu/courses/cse573/04au/Project/mini1/RUSSIA/Final_Paper.pdf)\nexcellent heuristic/evaluation function, made by researchers from the University of Washington.\n\nThis heuristic function is actually a collection of several heuristics\nand calculates the utility value of a board position by assigning\ndifferent weights to those heuristics [here](https://github.com/Drakirus/othello-prolog/blob/05cecc989db8e5ec041380c2ba5f77377fa3f524/ai/heuristic.pl#L172).  \n\nThe heuristic takes into account:\n\n  - The coin parity [here](https://github.com/Drakirus/othello-prolog/blob/05cecc989db8e5ec041380c2ba5f77377fa3f524/ai/heuristic.pl#L22-L34)\n  - The mobility [here](https://github.com/Drakirus/othello-prolog/blob/05cecc989db8e5ec041380c2ba5f77377fa3f524/ai/heuristic.pl#L37-L72)\n  - The corners captured [here](https://github.com/Drakirus/othello-prolog/blob/05cecc989db8e5ec041380c2ba5f77377fa3f524/ai/heuristic.pl#L77-L94)\n  - The stability [here](https://github.com/Drakirus/othello-prolog/blob/05cecc989db8e5ec041380c2ba5f77377fa3f524/ai/heuristic.pl#L99-L160)\n\n\n### Performances\n\u003e To ensure the best **performance** and to improve the **bot playing time** the Game Engine use a [cache.pl](./utils/cache.pl) system.  \n\nThe Cache saves the Heuristic value of a given board. [here](https://github.com/Drakirus/othello-prolog/blob/05cecc989db8e5ec041380c2ba5f77377fa3f524/ai/heuristic.pl#L183-L204).\n\nThis method saves (roughly):\n  \u003e - **20000** call out of **36000** when running a AlphaBeta of Depth 4 (-1min30 save on my machine **2min10** vs **3min40**).\n  \u003e - **66000** call out of **77000** when running a MinMax of Depth 4 (-9min save on my machine **11min** vs **20min**).\n\nThe Cache is also used to save some computing time of the [next board generation](https://github.com/Drakirus/othello-prolog/blob/89c9372dfe8d426c356f1e8153ece6a9e1db4295/game/rules.pl#L258-L269)\nwitch in his own cut the number of call to this rule by half (20 seconds save).\n\n\n## MinMax Vs AlphaBeta (depth = 3)\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://raw.githubusercontent.com/Drakirus/othello-prolog/master/minmax_vs_alphabeta.png\"\u003e\n    \u003cimg alt=\"MinMax vs AlphaBeta\" src=\"https://raw.githubusercontent.com/Drakirus/othello-prolog/master/minmax_vs_alphabeta.png\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nNote that the overall trend in counts analyzed by Min-Max increases in the first\nthird following a Gaussian strongly pronounced. This is because the board\nis free, and many combinations are allowed. In the next 2 thirds, the descent is\nalso done according to the distribution of gauss, since the\nnumber of game combinations decreases gradually as we reach the\nedges.\n\nIn depth 6 we have 3.8 million board\nanalyzed, to play an obvious shot find in depth 2.  \nEvidence appears: Alpha-Beta is still not the reincarnation of pure optimization\n...\n\n\n## Note\n\u003e I always write the test of the rule/predicate, below and indented by 3 tabs of the definition of itself.\n\n## Todo\n  1. +/-inf heuristic when wining/losing. (some plays are more rewards than a winning one..)  \n  \n  2. Dynamic stability_weights\n      - The [stability_weights](https://github.com/Drakirus/othello-prolog/blob/d2a668b69f1844ba549eea9a6561505d8a57de9c/ai/heuristic.pl#L115) penalize the player making a move on a adjacent corners cell. But if the same player own the related corner it's actualy not a bad move..\n      \n  3. Dynamic [weights](https://github.com/Drakirus/othello-prolog/blob/d2a668b69f1844ba549eea9a6561505d8a57de9c/ai/heuristic.pl#L172) in the dynamic_heuristic_evaluation  \n  \n      - At the start we need to reduce the opponent mobility  \n      - In the middle game we need to focus on the stability of your placement  \n      - In the very end of the game we only focus on the coin parity  \n       \n  4. Remove the ugly if/then/else\n  \n  5. Make use of board symmetrys to improve the Cache systems \n  \n  6. GnuProlog (2x faster)\n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpchampio%2Fothello-prolog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpchampio%2Fothello-prolog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpchampio%2Fothello-prolog/lists"}