{"id":18250323,"url":"https://github.com/maxi1324/tetrisai","last_synced_at":"2025-04-04T16:31:19.457Z","repository":{"id":159581264,"uuid":"457940128","full_name":"Maxi1324/TetrisAi","owner":"Maxi1324","description":"Tetris Ai","archived":false,"fork":false,"pushed_at":"2022-03-08T18:21:07.000Z","size":35343,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-20T15:12:04.160Z","etag":null,"topics":["ai","cool","game","gui","keras","keras-rl2","lua","mesen","python","reinforcement-learning","sockets","tetris","tkinter"],"latest_commit_sha":null,"homepage":"","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/Maxi1324.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":"2022-02-10T20:40:31.000Z","updated_at":"2023-09-17T16:02:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"e488367c-52d6-4b8c-874b-0eded5f94d0f","html_url":"https://github.com/Maxi1324/TetrisAi","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/Maxi1324%2FTetrisAi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maxi1324%2FTetrisAi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maxi1324%2FTetrisAi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maxi1324%2FTetrisAi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Maxi1324","download_url":"https://codeload.github.com/Maxi1324/TetrisAi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247209340,"owners_count":20901755,"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":["ai","cool","game","gui","keras","keras-rl2","lua","mesen","python","reinforcement-learning","sockets","tetris","tkinter"],"created_at":"2024-11-05T09:44:22.303Z","updated_at":"2025-04-04T16:31:19.451Z","avatar_url":"https://github.com/Maxi1324.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TetrisAI\n\nThis is my try of creating a Tetris Ai.\n\n![\"Gui bild\"](imgs/gui.PNG)\n\n- Motivation\n- Goal Definition\n- Description\n- Conclusion\n- Learnings\n- Installation\n- External Tools\n\n## Motivation\n\nMy Motivation for this Project was to learn python and make experience with Ai. This Project was also made for School.\n\n\n## Goal Definition\n\nMy goal was it to create a programm which can Play Tetris. I wanted to use reinforcement learning for the learning Algorithm . As a programming language i wanted to use Python, which i never really used befor.\n\u003cbr\u003e\nI don't wanted to reprogramm Tetris. I thought it was faster to use an emulator and write a Lua script which communicates with my Python programm via Sockets. \n\u003cbr\u003e\n\n\n## Description\n\nMy Project is split into three parts. \n- AI \n- Lua Script\n- Gui\n\nThe Gui displays some information\u003cbr\u003e\nThe Lua Script is the code, which runs on the emulator\u003cbr\u003e\nThe AI part is... well..it's the AI related part of this Project.\n\nThe Gui was easy. I used Tkinter. \n\nThe Lua part was way mor difficult, because i din't know how to write Lua. \nAnother reason was in order to send the information, i have to know which information i wanted to send.\nThe Gamefield itself wasn't difficult. I can just grab the Pixel Color and look, if it is black and send this information in a byte stream.\n\nThe NextBlock and the score was not so easy. Because i can´t simply read the information from the screen. I had to read it from the memory. The problem was that i didn't knew where the information was stored. I had to simply try it. after some time I found the locations.\n\nThe AI Part was the most difficult one. \u003cbr\u003e\nI used keras RL-2 and a DQN Agent.\n\nThe reward function has changed so many times. I tried many, many, many variations of the reward algorithm. The one in the code now is just the last one i've tried.\n\n![\"aigif\"](imgs/Medien1.gif)\n\n## Conclusion\n\nI was not able to accomplish the goal completely.\nThe Ai is just not smart. I´ve tried uncountable variations of my code. It was foolish to think that someone who have never done anything with AI can accomplish a goal like this.\n\nMy biggest problem was that i was not abel to isolate the problems\n\n- size of the neural network\n- reward function\n- other error in my code\n- learning rate\n- ...\n\nAt the end it's sad that it didn't work, because a lot of my time went in this project. \u003cbr\u003e\nI think i learned a lot, so it ok.\n\n## Learnings\n\n- concept of AI\n- improved my Python Skills\n- learned tkinter\n- learned keras rl-2\n- learned lua\n- make small steps. I think, i should have done easier projects before this.\n\n## Installation\n\nYou have to have PYthon 1.9 Installed.\n\nFor legal reasons, the Rom and the Emulator aren't in this repository. \nThey have to be added at the following positions:\nMesen Emulator:\n\"/Emulator/Mesen.exe\"\nTetrisEuropePalRom:\n\"/Emulator/Tetris (Europe).nes\"\n\nAfter those files have been added, you can start the 00StartAll.ps1 file.\n\nThe Emulator as well as the Python programm will start and connect. The Ai will take over.\n\n\n## External Tools\n- Python\n- Lua\n- Keras rl-2\n- tkinter\n- Mesen(Emulator)\n\n\nPS: I know that the code bacame really messy. This is a result of all the changes i made to the code over and over again\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxi1324%2Ftetrisai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxi1324%2Ftetrisai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxi1324%2Ftetrisai/lists"}