Skip to content

Commit

Permalink
board evaluation - check evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
99dino committed Jul 31, 2023
1 parent 53f1355 commit 5d0995d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,14 @@ function evaluateBoard(game, move, prevSum, color) {
if (game.in_draw() || game.in_threefold_repetition() || game.in_stalemate()) {
return 0;
}
if (game.in_check()) {
// Opponent is in check (good for us)
if (move.color === color) {
prevSum += 50;
}
// Our king's in check (bad for us)
else {
prevSum -= 50;
}
}
}

0 comments on commit 5d0995d

Please sign in to comment.