fga401 / AutoTableTurf

Automate the Tableturf game helping you reach Level 999 and get all sleeves.
GNU General Public License v3.0
47 stars 5 forks source link

Failure to place cards #4

Closed MegaBlaziken closed 1 year ago

MegaBlaziken commented 1 year ago

Hello, We have now completed building the environment and have done some testing. It works fine and we have been monitoring it for a while, but we have seen a lot of strange behavior and give-aways, so we would like to know if it is an anomaly in the program or an event that we should fix. The card kept spinning and eventually giving up: N-ZAP89 Splatana Stamper Splatana Wiper Splat Bomb Wave Breaker

It does not move from its initial location and continues to try to place it in places where it cannot be placed: Sprinkler Squid Beakon Oversized

When it appears as a card, the web portal returns an error (I think it was an array error, I will submit the log of the error again if necessary). Fish Stick

I have it running in the following environment Ubuntu 20.04.6 LTS Capture Card: 4KVC00

fga401 commented 1 year ago

Sorry for the late reply.

The card kept spinning and eventually giving up

That means the recognition is wrong. The input to the AI is not the actual situation. And the giving up is a kind of mechanism to prevent a dead loop.

It does not move from its initial location and continues to try to place it in places where it cannot be placed

Same error of recognition. Does the giving up not work here?

When it appears as a card, the web portal returns an error

it would be great if you can share error logs.

And some tips for better recognition:

MegaBlaziken commented 1 year ago

Sorry for the delay, I was checking and verifying various operations.

The card kept spinning and eventually giving up It does not move from its initial location and continues to try to place it in places where it cannot be placed With regard to the above, I understand.

Also, in all cases, it will always give up.

When it appears as a card, the web portal returns an error

It would be great if you can share error logs.

They are in the following form. We have video logs regarding the situation and will present them if necessary.

Corrupt JPEG data: premature end of data segment
[2023-06-15 14:45:38,104] ERROR in app: Exception on /home/run [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.9/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/actjp/ใƒ‡ใ‚นใ‚ฏใƒˆใƒƒใƒ—/AutoTableTurf/portal/home/home.py", line 71, in run
    manager.run(profile=Profile.from_json(profile), closer=closer, debug=debug)
  File "/home/actjp/ใƒ‡ใ‚นใ‚ฏใƒˆใƒƒใƒ—/AutoTableTurf/tableturf/manager/tableturf.py", line 99, in run
    self.run_once(task.deck, closer=task_closer, debug=debug)
  File "/home/actjp/ใƒ‡ใ‚นใ‚ฏใƒˆใƒƒใƒ—/AutoTableTurf/tableturf/manager/tableturf.py", line 115, in run_once
    self.__select_deck(deck)
  File "/home/actjp/ใƒ‡ใ‚นใ‚ฏใƒˆใƒƒใƒ—/AutoTableTurf/tableturf/manager/tableturf.py", line 145, in __select_deck
    deck = self.__multi_detect(detection.deck)(debug=self.__session['debug'])
  File "/home/actjp/ใƒ‡ใ‚นใ‚ฏใƒˆใƒƒใƒ—/AutoTableTurf/tableturf/manager/tableturf.py", line 47, in wrapper
    previous = detect_fn(self.__capture(), *args, **kwargs)
  File "/home/actjp/ใƒ‡ใ‚นใ‚ฏใƒˆใƒƒใƒ—/AutoTableTurf/tableturf/manager/detection/deck.py", line 95, in deck
    deck = [Card(grids[i], costs[i]) for i in range(15)]
  File "/home/actjp/ใƒ‡ใ‚นใ‚ฏใƒˆใƒƒใƒ—/AutoTableTurf/tableturf/manager/detection/deck.py", line 95, in <listcomp>
    deck = [Card(grids[i], costs[i]) for i in range(15)]
  File "/home/actjp/ใƒ‡ใ‚นใ‚ฏใƒˆใƒƒใƒ—/AutoTableTurf/tableturf/model/card.py", line 104, in __init__
    self.__patterns = [Pattern(np.rot90(grid, i)) for i in range(4)]
  File "/home/actjp/ใƒ‡ใ‚นใ‚ฏใƒˆใƒƒใƒ—/AutoTableTurf/tableturf/model/card.py", line 104, in <listcomp>
    self.__patterns = [Pattern(np.rot90(grid, i)) for i in range(4)]
  File "/home/actjp/ใƒ‡ใ‚นใ‚ฏใƒˆใƒƒใƒ—/AutoTableTurf/tableturf/model/card.py", line 24, in __init__
    self.__offsets = indexes - indexes[0][np.newaxis, ...]
IndexError: index 0 is out of bounds for axis 0 with size 0

do not use cards that are Axisymmetric or Centrosymmetric, which may cause infinite spinning. do not use level-up cards, which have many sparkling special effects and makes wrong recognition happen more frequently.

Roger, I'll think about the deck structure.

I am also sorry that this question is not directly related to a different error or program, but may I ask you something? I am currently using Ubuntu (VirtualBox, windows11), Bluetooth adapter and Razer ripsaw HD. When I view the video from the Razer capture board in a browser, the screen is frequently disturbed, Corrupt JPEG data: premature end of data segment. error in the log. I would like to work around this, has this ever happened in your environment? It did not occur in windows 11. I use Razer ripsaw HD and check with ubuntu browser and OBS but the disturbance is always happening. Especially, the bug is always noticeable in the sprite display of the tree in the square.

image

https://github.com/fga401/AutoTableTurf/assets/120486368/c2ccf3fc-bb88-430c-83f1-51d03e56fe12

fga401 commented 1 year ago

your logs show that an error happens when it is trying to get your desk. I guess you choose a invalid deck which has an empty slot, or less than 15 cards in that deck. have you changed the config json? you will need to input a valid deck number.

2023-06-17 17_17_19-192 168 50 102_5000_home_

btw, as for the screen capture issue, It seems WSL is not fully compatible with your Razer. Why not run the python script on Windows 11?

MegaBlaziken commented 1 year ago

I am aware that the deck numbers start at 0. We also use decks 8~15 and all 15 cards are stored in all these decks. I have not changed the json file, do you mean to change portal > profiles > default.json instead of the text area of the browser? I always edited the text area directly.

Why not run the python script on Windows 11?

Thank you, I have tried to do a screen capture in windows 11 for this. However, when I output the switch video to the Razer Ripsaw HD at 1080p, the screen is distorted, so I solved this problem by changing the setting on the switch side to output at 720p.

Therefore, our environment, which is currently (mostly) working properly, is as follows. portal : Windows11 capture board: Razer ripsaw HD ( Switch setting: 720p )

controller : Ubuntu in VMbox Bridge adapter I will change to another capture board because I want to change the point that the switch must be set to 720p. Sorry for the length of this article, thank you very much.

fga401 commented 1 year ago

Alright, could you turn on the debug mode and open pages http://localhost:5000/debug/deck.image and http://localhost:5000/debug/deck.color_mask before runing the script, and share the last screenshots of that two pages while the error happens?

MegaBlaziken commented 1 year ago

Is this the right way? deck_image deck_color_mask

Capture in windows 11 and Razer ripsaw HD (720p), the operation part is ubuntu in VMBox. Are there any other clarifications needed, such as the main PC being a Ryzen?

fga401 commented 1 year ago

yeah that's what i want. could you share your config and these two pictures? http://localhost:5000/debug/deck_cursor.image http://localhost:5000/debug/deck_cursor.color_mask

it seems the code enters the next round before the previous one ends, so it can't detect your deck. It's a code issue and not relative to devices. In current code, I just sleep for several secs to waiting for the animation to end, which is not robust.

a temp fix could be increase the sleep time here https://github.com/fga401/AutoTableTurf/blob/7c6e4b66079cda7c13370009e47f52357c45abaa/tableturf/manager/tableturf.py#L300

MegaBlaziken commented 1 year ago

This is a screenshot of the URL you gave us. I changed the time in the code you gave us from 10 to 20 for now. I will see how it works for a while. Thank you very much for your lengthy response. deck_cursor_image deck_cursor_color_mask

fga401 commented 1 year ago

it's great to hear that my codes work for someon else.

one more question, I would like to know which deck are you using? No. 11?

MegaBlaziken commented 1 year ago

Yes, it is 11 now. The deck is there to beat Big Man.

Also, I increased the sleep time on line 300, but the same error occurred only because it took longer to get to the experience increase screen.

fga401 commented 1 year ago

Yes, it is 11 now.

oh it make sense now. as you can see in the last picture, there is a small white mask on the green rectangle No.11. you can move the Deck 11 to another place.

MegaBlaziken commented 1 year ago

In other words, is this a glitch that occurs because the result numbers happen to be at the cursor position for selecting deck 11? I will try to make sure that deck 11 is in a different location.