{"id":28387398,"url":"https://github.com/vpn1997/2048-ai","last_synced_at":"2025-10-18T09:50:39.814Z","repository":{"id":296382152,"uuid":"105435822","full_name":"vpn1997/2048-Ai","owner":"vpn1997","description":"Bot playing 2048","archived":false,"fork":false,"pushed_at":"2018-04-15T13:37:16.000Z","size":671,"stargazers_count":18,"open_issues_count":0,"forks_count":21,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-30T14:21:07.596Z","etag":null,"topics":["game-theory","machine-learning"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/vpn1997.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,"zenodo":null}},"created_at":"2017-10-01T10:54:03.000Z","updated_at":"2024-01-01T13:05:33.000Z","dependencies_parsed_at":"2025-06-03T05:05:37.812Z","dependency_job_id":null,"html_url":"https://github.com/vpn1997/2048-Ai","commit_stats":null,"previous_names":["vpn1997/2048-ai"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vpn1997/2048-Ai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vpn1997%2F2048-Ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vpn1997%2F2048-Ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vpn1997%2F2048-Ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vpn1997%2F2048-Ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vpn1997","download_url":"https://codeload.github.com/vpn1997/2048-Ai/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vpn1997%2F2048-Ai/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262139520,"owners_count":23265170,"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":["game-theory","machine-learning"],"created_at":"2025-05-30T17:40:31.447Z","updated_at":"2025-10-18T09:50:39.741Z","avatar_url":"https://github.com/vpn1997.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Playing 2048 game with an Automated Bot.\n\nBot uses Expectimax search with the depth of 4 to find the best possible move.\n\nProject is still in progress. During testing 1024 tile was produced every time and 2048 tile in 60% of the games.\n\n# Prerequisites\n\nGame theory, Machine Learning, Minmax, Expectimax\n\n# Files Info\n\ndirect.py --\u003e Expectimax implementation (main algorithm)\n\npuzzle.py ---\u003e Implementation of game (main file, run this file for demo)\n\nlogic.py ----\u003e Implementation of game (backend)\n\nmerge_game.py -----\u003e Helper file for merging the matrix\n\n## Demo\n\n```bash\n$ git clone https://github.com/vpn1997/2048-Ai\n$ cd 2048-Ai\n$ sh dependencies.sh\n$ python puzzle.py\n```\n\n## Human Play\nClick the \"Bot Play\" button to turn to Manual Playing mode.\nClick the same button, now turned to \"Human Play\" to let the bot take control\n\n![BotPlay Screenshot](/img/BotPlay.png?raw=true \"Bot Play Mode\")\n![HumanPlay Screenshot](/img/HumanPlay.png?raw=true \"Human Play Mode\")\n\n\n![webp net-resizeimage 2](https://user-images.githubusercontent.com/17298412/31058099-8a9077a4-a70b-11e7-99bb-e55cd540bb6d.png)\n\n## Heuristics\n\n(In file direct.py)\n\nI have used a score and a penalty function.\n\nA configuration gets a high score if it follows snake line pattern.\n\nWeights are assigned to individual tiles. You can tweak them to get better results.\n\nPenalty is given depending on how many filled tiles are present (more filled tiles =\u003e bigger penalty).\n\nYou can download the game interface from https://github.com/yangshun/2048-python.\n\n## Future work\n\n1. Getting 2048 or bigger tiles at higher frequency.\n\n2. Using Reinforcement learning didn't give any promising results.\n\nThe highest tile it used to get during the game was 128.\n  \nSo still working on improving that model.\n\n## Reference\nhttps://stackoverflow.com/questions/22342854/what-is-the-optimal-algorithm-for-the-game-2048\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvpn1997%2F2048-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvpn1997%2F2048-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvpn1997%2F2048-ai/lists"}