Skip to content

Various Bugfixes#144

Open
squidKid-deluxe wants to merge 1 commit intoPbatch:mainfrom
squidKid-deluxe:main
Open

Various Bugfixes#144
squidKid-deluxe wants to merge 1 commit intoPbatch:mainfrom
squidKid-deluxe:main

Conversation

@squidKid-deluxe
Copy link
Copy Markdown

Please note - this commit was AI-generated and I am not a very competent TS dev, please review before accepting. Summary of changes:

  1. src/utils/findPieces.tsx - Fixed getUpdate function (line 132)
  • Changed if (square == -1) to if (typeof square !== 'number' || !Number.isInteger(square) || square < 0 || square >= 64)
  • Fixes: TypeError: can't access property 0, update[square] is undefined - handles undefined/NaN/out-of-bounds square values from tensor operations
  1. src/utils/findPieces.tsx - Reset state after move detection (lines 223, 240)
  • Added state = zeros(64, 12); after both move detection paths
  • Fixes: Second move being ignored - state now resets after each detected move
  1. src/utils/math.tsx - Fixed zeros function
  • Changed Array.from(Array(rows), ...) to Array.from({ length: rows }, ...)
  • Fixes: Sparse array issues that could cause undefined rows
  1. src/components/play/playSidebar.tsx - Fixed opponent move handling
  • Changed board.move(lastMove) to board.playUci(lastMove)
  • Added fromOpponent check to prevent sending opponent moves back to Lichess
  • Fixes: TypeError: board.move is not a function and duplicate move submissions
  1. src/slices/gameSlice.tsx - Added playUci method
  • Added parseUci import and makeSan for converting UCI moves to SAN notation
  • Fixes: Opponent moves from Lichess stream not being properly added to game state
  1. src/types.tsx & src/slices/gameSlice.tsx - Added fromOpponent field
  • Tracks whether a move came from the opponent (via stream) vs detected by camera
  • Fixes: System sending opponent's moves back to Lichess
  1. src/utils/lichess.tsx - Removed alert popup
  • Changed alert(err) to console.error(err)
  • Fixes: Intrusive error alerts during Lichess API failures

- findPieces.tsx - Fixed getUpdate to handle invalid square values (undefined/NaN/out-of-bounds)
- findPieces.tsx - Reset state after detecting a move so subsequent moves can be detected
- math.tsx - Fixed zeros to use Array.from({ length: rows }, ...) instead of sparse array
- gameSlice.tsx - Added playUci method with makeSan for opponent moves
- types.tsx - Added fromOpponent field to prevent sending opponent moves back to Lichess
- lichess.tsx - Changed alert() to console.error() for error handling
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.

1 participant