Skip to content

Fix puzzle loop state handling and zero counting - #53

Open
marccyzz wants to merge 2 commits into
vncsms:masterfrom
marccyzz:fix-puzzle-loop
Open

Fix puzzle loop state handling and zero counting#53
marccyzz wants to merge 2 commits into
vncsms:masterfrom
marccyzz:fix-puzzle-loop

Conversation

@marccyzz

Copy link
Copy Markdown

This pull request fixes a few issues in the puzzle bot logic.

Changes:

  • refresh the puzzle screenshot before reading the new piece color in state 4
  • refresh the puzzle screenshot again before rebuilding the puzzle board in state 5
  • fix the empty-cell counting logic in tetris.py
  • use the correct return value when a move is successfully placed in play_game()

Why:
The previous implementation could work with stale screenshots and could also treat a successful move as a failed one. That could lead to wrong board detection, incorrect state transitions, and clicks outside the intended puzzle area.

I tested the logic flow locally and the changes are meant to make the puzzle state machine more reliable.

This patch improves the puzzle bot flow in `puzzle.py`.

It refreshes the captured puzzle image before reading the current piece color and before rebuilding the board state, so the bot no longer relies on stale image data between states.

It also fixes the board-state evaluation by using `count_zeros()` correctly and adds a small debug output to help inspect detected free cells during runtime.

These changes should make the puzzle state machine more reliable and reduce cases where the bot clicks based on outdated puzzle information.
Fix `count_zeros()` so the puzzle board state uses the correct number of empty cells.
@emreozyoruk

Copy link
Copy Markdown

is it working ?

@marccyzz

Copy link
Copy Markdown
Author

unfortunately not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants