irgiob / tetris-ai-9000

Utilising a genetic algorithm to finally crush my friends in Online Tetris
GNU General Public License v3.0
0 stars 1 forks source link

hello #1

Open daniel2644 opened 1 year ago

daniel2644 commented 1 year ago

how to fix error?: = RESTART: C:\Users\Daniel\Desktop\Nowy folder\python tetris bot\tetris-ai-9000-master\main.py Traceback (most recent call last): File "C:\Users\Daniel\Desktop\Nowy folder\python tetris bot\tetris-ai-9000-master\main.py", line 75, in play() File "C:\Users\Daniel\Desktop\Nowy folder\python tetris bot\tetris-ai-9000-master\main.py", line 67, in play run_game(weights, play_mode=True, display=terminal_view) File "C:\Users\Daniel\Desktop\Nowy folder\python tetris bot\tetris-ai-9000-master\play_jstris.py", line 28, in run_game game_data = get_raw_data() File "C:\Users\Daniel\Desktop\Nowy folder\python tetris bot\tetris-ai-9000-master\functions.py", line 37, in get_raw_data if (img_data[game_coords] == EMPTY_SPACE).all(): IndexError: index 319 is out of bounds for axis 1 with size 291

full screen tetris: https://gyazo.com/1fe6a76dfeed53480fae09bc572bf42f

irgiob commented 1 year ago

Hi, this code was actually written to be used on either https://tetris.com/play-tetris (with play.py) or jstris (with play.jstris.py). Both these examples work by checking if each cell is pure black or not to check if there is a tetromino in that cell. Since you're trying this with a different Tetris game where empty cells are not black, the code thinks every space is filled which might be causing the error. There might be other problems but that seems the most obvious one to me right now. You will probably need to modify some of the functions to get it to work for your version of Tetris.

daniel2644 commented 1 year ago

I would really like it to work in my version, but I don't know what exactly to modify because there are different colors rgb in this version, what you gave me also does not work, error: Traceback (most recent call last): File "C:\Users\Daniel\Desktop\Nowy folder\phbot tetris2\tetris-ai-9000-master\main.py", line 75, in play() File "C:\Users\Daniel\Desktop\Nowy folder\phbot tetris2\tetris-ai-9000-master\main.py", line 67, in play run_game(weights, play_mode=True, display=terminal_view) File "C:\Users\Daniel\Desktop\Nowy folder\phbot tetris2\tetris-ai-9000-master\play_jstris.py", line 28, in run_game game_data = get_raw_data() File "C:\Users\Daniel\Desktop\Nowy folder\phbot tetris2\tetris-ai-9000-master\functions.py", line 37, in get_raw_data if (img_data[game_coords] == EMPTY_SPACE).all(): IndexError: index 264 is out of bounds for axis 1 with size 245 when i changed the value of WIDTH ": 245 on 1 it was fix error, WIDTH not scaning , I do not know what code it is related to in genetic algorithm you forgot to add import numpy as np https://gyazo.com/0b8bb9453146562804756b1b47163f8e

irgiob commented 1 year ago

Hi there, after taking a look at the code again it looks like it's currently using the game runner for the Jstris version of Tetris instead of for the one on https://tetris.com/play-tetris, which is still buggy. Try going to genetic_algorithm.py and commenting out line 2 and uncomment line 1. And just to make sure, Don't forget to also run the display_config.py script to properly configure the AI to read from your specific device and make sure the display_config.txt file has been rewritten with the results you saw in the terminal. Hopefully, that will at least get it to work for https://tetris.com/play-tetris, though it's important to note that this was coded up on a Mac and there may be other bugs with trying to run it on Windows. ALSO it is important when running this AI on https://tetris.com/play-tetris that you set the game to start at level 20, the AI is going to play poorly if it starts at a lower level due to how it processes the information from the screenshots.

If the above instructions can at least get it to run then modifications can start being made to make it work for your specific version of Tetris. Hope that helps!