MestreLion / hackmatch

Exapunks Hack*Match Bot
GNU General Public License v3.0
5 stars 2 forks source link

main: Game window closed [AttributeError] #2

Closed Aratietur closed 1 year ago

Aratietur commented 1 year ago

The missing problem ist the window acceptance: From CMD.exe: C:\Users\nikol>C:\Users\nikol\AppData\Roaming\Python\Python311\Scripts\hackmatch-bot.exe Read game settings: C:/Users/nikol/OneDrive/Dokumente/My Games/EXAPUNKS//config.cfg Launching game and waiting 60 seconds for game window Launch game by Steam URI: steam://rungameid/716490 Read game settings: C:/Users/nikol/OneDrive/Dokumente/My Games/EXAPUNKS//config.cfg Game window: <Win32Window left="0", top="0", width="1366", height="768", title="EXAPUNKS"> [2023-09-03 02:40:24 CRITIC] main: Game window closed [AttributeError]

As you can see i modified your config-path. After entering the start command

Unfortunately i don't have any ideas left why this AttributeError happens. I already changed the screen resolution to 1366x768 with a single screen active and deactivated CRT effects.

MestreLion commented 1 year ago

Can you run again as hackmatch-bot.exe --verbose? This will output more debug data which might help finding why the error happens

Aratietur commented 1 year ago

Thx for your fast reply!

C:\Users\nikol>C:\Users\nikol\AppData\Roaming\Python\Python311\Scripts\hackmatch-bot --verbose [2023-09-03 21:52:42 DEBUG ] main: Namespace(loglevel=10, benchmark=False, watch=False, timeout=850, string=None, path=None, debug=True) [2023-09-03 21:52:42 INFO ] game: Read game settings: C:/Users/nikol/OneDrive/Dokumente/My Games/EXAPUNKS//config.cfg [2023-09-03 21:52:42 DEBUG ] game: Parsed game settings: {'DisplayIndex': '0', 'EnableCrtDistortion': 'False', 'EnableHistograms': 'True', 'EnableLeaderboards': 'True', 'EnableMultiplayer': 'True', 'FilterProfanity': 'False', 'ForceLowQualityTextures': 'False', 'Fullscreen': 'False', 'GifOutputDirectory': '', 'KeyMapping.Down': '115', 'KeyMapping.Left': '97', 'KeyMapping.Right': '100', 'KeyMapping.Start': '13', 'KeyMapping.Up': '119', 'KeyMapping.X': '106', 'KeyMapping.Y': '107', 'KeyMapping.Z': '108', 'Language': 'English', 'OS.Windows.UseOpenGL': 'False', 'Resolution.Height': '768', 'Resolution.Width': '1366', 'ShowTenthPercentile': 'False', 'ShowTopPercentile': 'False', 'UseLargeFonts': 'False', 'UseSoftwareCursor': 'False', 'Volume.Music': '29', 'Volume.Sound': '25', 'Volume.Voice': '26'} [2023-09-03 21:52:42 INFO ] main: Launching game and waiting 60 seconds for game window [2023-09-03 21:52:42 INFO ] game: Launch game by Steam URI: steam://rungameid/716490 [2023-09-03 21:52:45 INFO ] game: Read game settings: C:/Users/nikol/OneDrive/Dokumente/My Games/EXAPUNKS//config.cfg [2023-09-03 21:52:45 DEBUG ] game: Parsed game settings: {'DisplayIndex': '0', 'EnableCrtDistortion': 'False', 'EnableHistograms': 'True', 'EnableLeaderboards': 'True', 'EnableMultiplayer': 'True', 'FilterProfanity': 'False', 'ForceLowQualityTextures': 'False', 'Fullscreen': 'False', 'GifOutputDirectory': '', 'KeyMapping.Down': '115', 'KeyMapping.Left': '97', 'KeyMapping.Right': '100', 'KeyMapping.Start': '13', 'KeyMapping.Up': '119', 'KeyMapping.X': '106', 'KeyMapping.Y': '107', 'KeyMapping.Z': '108', 'Language': 'English', 'OS.Windows.UseOpenGL': 'False', 'Resolution.Height': '768', 'Resolution.Width': '1366', 'ShowTenthPercentile': 'False', 'ShowTopPercentile': 'False', 'UseLargeFonts': 'False', 'UseSoftwareCursor': 'False', 'Volume.Music': '29', 'Volume.Sound': '25', 'Volume.Voice': '26'} [2023-09-03 21:52:45 DEBUG ] gui : Keymap: {: 'a', : 'd', : 'w', : 's', : '\r', : 'j', : 'k'} [2023-09-03 21:52:45 INFO ] main: Game window: <Win32Window left="0", top="0", width="1372", height="797", title="EXAPUNKS"> [2023-09-03 21:52:45 CRITIC] main: Game window closed [AttributeError]

MestreLion commented 1 year ago

not very helpful, bummer :(

It seems an exception occurred when trying either pywinctl.Rect(), pywinctl.Window.topleft or pywinctl.Window.bottomright. Maybe there was an API change in latest pywinctl?

Care to try uninstalling it and installing a known-working version to see if it works?

if you've installed in a venv:

$ source venv/bin/activate
$ pip uninstall pywinctl
$ pip install 'pywinctl <= 0.0.43'

Then run the bot again

Aratietur commented 1 year ago

Got the following: C:\Users\nikol\AppData\Roaming\Python\Python311>hackmatch-bot Read game settings: C:/Users/nikol/OneDrive/Dokumente/My Games/EXAPUNKS//config.cfg Launching game and waiting 60 seconds for game window Launch game by Steam URI: steam://rungameid/716490 Read game settings: C:/Users/nikol/OneDrive/Dokumente/My Games/EXAPUNKS//config.cfg Game window: <Win32Window left="0", top="0", width="1372", height="797", title="EXAPUNKS"> [2023-09-05 15:08:31 ERROR ] main: Pillow was built without XCB support Traceback (most recent call last): File "C:\Users\nikol\AppData\Roaming\Python\Python311\site-packages\hackmatch\main.py", line 166, in run main(argv) File "C:\Users\nikol\AppData\Roaming\Python\Python311\site-packages\hackmatch\main.py", line 126, in main board = window.new_board(debug=c.args.debug) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\nikol\AppData\Roaming\Python\Python311\site-packages\hackmatch\gui.py", line 270, in new_board image: Image = self.take_screenshot() ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\nikol\AppData\Roaming\Python\Python311\site-packages\hackmatch\gui.py", line 255, in take_screenshot image = PIL.ImageGrab.grab(bbox, xdisplay="") # RGBA in macOS ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\nikol\AppData\Roaming\Python\Python311\site-packages\PIL\ImageGrab.py", line 68, in grab raise OSError(msg) OSError: Pillow was built without XCB support

Atm i installed the following modules: C:\Users\nikol\Dropbox\Mein PC (DESKTOP-18T1P8G)\Downloads>pip freeze EasyProcess==1.1 entrypoint2==1.1 hackmatch==1.2 MouseInfo==0.1.3 mss==9.0.1 Pillow==10.0.0 PyAutoGUI==0.9.54 PyGetWindow==0.0.9 PyMonCtl==0.3 PyMsgBox==1.0.9 pyperclip==1.8.2 PyRect==0.2.0 pyscreenshot==3.1 PyScreeze==0.1.29 pytweening==1.0.7 pywin32==306 PyWinBox==0.4 PyWinCtl @ file:///C:/Users/nikol/Dropbox/Mein%20PC%20%28DESKTOP-18T1P8G%29/Downloads/PyWinCtl-0.0.43-py3-none-any.whl#sha256=c02caf9c320f3365308245ba216154d3afeddcbfcd1c34c412df632f50c2dd1f typing_extensions==4.7.1

Don't know why PyWinCtl looks so strange... used "pip install Name" to install the download from https://pypi.org/project/PyWinCtl/0.0.43/#files

MestreLion commented 1 year ago
  • i uninstalled pywinctl 0.0.50 and installed 0.0.43 manually

    • deleted hackmatch-bot and installed it anew (it updated automatically to 0.0.50 again, so i returned to 0.0.43 manually again^^)

Yes, I didn't publish yet a new release with a pinned PyWinCtl version, will do as soon as we confirm that 0.0.43 works fine :)

MestreLion commented 1 year ago

File "C:\Users\nikol\AppData\Roaming\Python\Python311\site-packages\hackmatch\gui.py", line 255, in take_screenshot image = PIL.ImageGrab.grab(bbox, xdisplay="") # RGBA in macOS ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\nikol\AppData\Roaming\Python\Python311\site-packages\PIL\ImageGrab.py", line 68, in grab raise OSError(msg) OSError: Pillow was built without XCB support

Atm i installed the following modules: C:\Users\nikol\Dropbox\Mein PC (DESKTOP-18T1P8G)\Downloads>pip freeze EasyProcess==1.1 entrypoint2==1.1 hackmatch==1.2 MouseInfo==0.1.3 mss==9.0.1 Pillow==10.0.0 PyAutoGUI==0.9.54 PyGetWindow==0.0.9 PyMonCtl==0.3 PyMsgBox==1.0.9 pyperclip==1.8.2 PyRect==0.2.0 pyscreenshot==3.1 PyScreeze==0.1.29 pytweening==1.0.7 pywin32==306 PyWinBox==0.4 PyWinCtl @ file:///C:/Users/nikol/Dropbox/Mein%20PC%20%28DESKTOP-18T1P8G%29/Downloads/PyWinCtl-0.0.43-py3-none-any.whl#sha256=c02caf9c320f3365308245ba216154d3afeddcbfcd1c34c412df632f50c2dd1f typing_extensions==4.7.1

Don't know why PyWinCtl looks so strange... used "pip install Name" to install the download from https://pypi.org/project/PyWinCtl/0.0.43/#files

This is not a PyWinCtl's issue... it seems it the version pinning worked!

What you stumbled now is another issue, this time between Windows and Pillow, the library I use for the screenshots (which the bot uses to read the game board)... it seems that Pillow requires this "XCB support" to be able to take screenshots when running in Windows.

I'll create a new issue for this, it is unrelated to pywinctl

MestreLion commented 1 year ago

I already changed the screen resolution to 1366x768 with a single screen active and deactivated CRT effects.

Actually, the bot works much better in 1600x900 (or even full-screen 1920x1080) than in 1366x768, as the pixel recognition in low-res is much harder and less accurate (and might need a bit of fine-tuning).

Single screen helps, but should not be necessary, the bot is supposed to work on your primary screen. (and this is a great opportunity to test it!)

As for CRT effects, the bot automatically re-writes the game config to disable it, so it shouldn't be necessary for you to do. (another good test opportunity)