Fix checkmate detection.

This commit is contained in:
yukirij 2024-08-20 19:12:19 -07:00
parent d7d7d019f3
commit dfa1c9a5e5
2 changed files with 5 additions and 3 deletions

View File

@ -263,6 +263,8 @@ GAME.Game = class {
this.state.check = 0; this.state.check = 0;
this.state.checkmate = false; this.state.checkmate = false;
let player = this.turn & 1;
// Determine threaten, check, and blocking for each piece // Determine threaten, check, and blocking for each piece
let checking_pieces = 0; let checking_pieces = 0;
for(let piece of this.board.pieces) { for(let piece of this.board.pieces) {
@ -316,8 +318,8 @@ GAME.Game = class {
} }
// Search for valid pool placements. // Search for valid pool placements.
for(let i = 0; i < this.pools[0].length; ++i) { for(let i = 0; i < this.pools[player].pieces.length; ++i) {
for(let move of this.placement_tiles(i, (this.turn & 1))) { for(let move of this.placement_tiles(i, player)) {
if(move.valid) { moves += 1; } if(move.valid) { moves += 1; }
} }
} }

View File

@ -1085,7 +1085,7 @@ const INTERFACE = {
// Select random from ties. // Select random from ties.
let selection = 0; let selection = 0;
for(let i = 1; i < moves.length; ++i) { for(let i = 1; i < moves.length; ++i) {
if(moves[i].score + 6 >= moves[i-1].score) { if(moves[i].score + 5 >= moves[i-1].score) {
selection++; selection++;
} else { } else {
break; break;