{"id":15531447,"url":"https://github.com/squiddev/stop-learn","last_synced_at":"2025-04-06T00:11:51.637Z","repository":{"id":81349665,"uuid":"43307147","full_name":"SquidDev/stop-learn","owner":"SquidDev","description":"AI for the board game \"Stop\"","archived":false,"fork":false,"pushed_at":"2018-08-01T10:40:32.000Z","size":128,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-12T06:21:20.288Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SquidDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2015-09-28T14:49:25.000Z","updated_at":"2015-11-03T16:26:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"6b809125-e117-4c5f-83a1-f209cca53a21","html_url":"https://github.com/SquidDev/stop-learn","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SquidDev%2Fstop-learn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SquidDev%2Fstop-learn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SquidDev%2Fstop-learn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SquidDev%2Fstop-learn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SquidDev","download_url":"https://codeload.github.com/SquidDev/stop-learn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415973,"owners_count":20935387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-02T11:26:14.631Z","updated_at":"2025-04-06T00:11:51.631Z","avatar_url":"https://github.com/SquidDev.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stop-Learn\n\nI thought I'd need Machine Learning to play the game \"Stop\". I didn't, but the name stuck.\n\n## How to Play\n\nStop is played in an 8x8 grid, each player starting in opposite directions:\n\n```\n  0 1 2 3 4 5 6 7\n0| | | | | | | |X|\n1| | | | | | | | |\n2| | | | | | | | |\n3| | | | | | | | |\n4| | | | | | | | |\n5| | | | | | | | |\n6| | | | | | | | |\n7|0| | | | | | | |\n```\n\nBoth players take turns to play. You play by placing a new piece one or two tiles away\nfrom one of your existing pieces. You can only place a tile if you have a clear line of sight:\n\n```\n  0 1 2 3 4 5 6 7\n1| | | |x| | | | |\n2| | | |x| | | | |\n3| |x|x|X|O| | | |\n4| | | |x| | | | |\n5| | | |x| | | | |\n```\n\nThe game ends when one player (or both) cannot play. The winner is whoever has played the most tiles.\nSometimes the game can end despite both players can play as there are no cells in \"conflict\". \nIn the example below, X has one by 3 points.\n\n```\n  0 1 2 3 4 5 6 7\n0| | |X|0|X|X| |X|\n1| |X|0|0|0|X| | |\n2|X|X|0|X|0|X|X| |\n3|0|0|0|X|0|X| | |\n4| | |0|X|0|X|X| |\n5| | |0|X|0|X|X|X|\n6| | |0|X|X|X|0|0|\n7|0| |0|0|0|X|0|0|\n```\n\n## Running:\nYou'll need to setup CMake to use Clang (this isn't required, I just use Clang flags): \n`cmake -DCMAKE_C_COMPILER=/usr/bin/clang .`\n\nThen just run `./StopLearn`, this by default plays against the Manhattan algorithm with a depth of 2.\n\nYou can configure this in `main.cpp`.\n\nTo play you can entire coordinates in the form (x, y). There are also an additional set of commands you can\nrun:\n\n - `f`: Print a territory map based off the FloodFill algorithm\n - `m`: Print a territory map based off the Manhattan algorithm\n - `s`: Print the board score based off all scoring mechanisms\n - `g`: Generate an SVG graphic of the current board.\n\n## Scoring Mechanisms\nThe computer plays based off a min-max strategy, based off a score of the final board. \nThere are two scoring mechanisms: Manhattan and FloodFill. These both score the board \nthrough finding each player's territory (who owns each cell).\n\nBoth algorithms randomly shuffle the possible moves to show some degree of \n\"randomness\" - otherwise the same game could be played every time.\n\n### FloodFill \nThe first pass of the flood fill algorithm establishes territory based off which tiles are\neither occupied, or could be reached within one move. If both players can reach the cell within \none move, then it is marked as \"both\".\n\nThe second pass then attempts to flood fill the board from every occupied point. If it only finds\ntiles of the same player, than the fill is confirmed, and that territory is added, otherwise it\nis aborted.\n\n### Manhattan\nThe Manhattan algorithm takes its name from [Manhattan Distance](https://en.wikipedia.org/wiki/Taxicab_geometry), \nthough that is not entirely accurate. Like FloodFill, each tile can be owned by either player, or \"both\" players.\nInstead of filling the board, each tile's owner is determined by which player would take the least number of moves\nto get to that cell.\n\nManhattan ends up being more effective, as it does not depend on an \nenclosed area being considered 'territory'.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquiddev%2Fstop-learn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsquiddev%2Fstop-learn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquiddev%2Fstop-learn/lists"}