Skip to content

Commit

Permalink
update material diff calculation, queen worth 9
Browse files Browse the repository at this point in the history
  • Loading branch information
fitztrev committed May 30, 2024
1 parent 75de83e commit 322e448
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions js/utils/calculate-material-imbalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ export function calculateMaterialImbalance(position: string): number {
if (piece === 'p') return -1
else if (piece === 'n' || piece === 'b') return -3
else if (piece === 'r') return -5
else if (piece === 'q') return -8
else if (piece === 'q') return -9
else if (piece === 'P') return +1
else if (piece === 'N' || piece === 'B') return +3
else if (piece === 'R') return +5
else if (piece === 'Q') return +8
else if (piece === 'Q') return +9
else return 0
})

Expand Down
6 changes: 3 additions & 3 deletions tests/calculate-material-imbalances.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { fenToPosition } from '../js/utils/fen-to-position'
describe('test material imbalance calculations', () => {
test.each([
['rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1', 0],
['rbnq4/p7/8/8/8/8/8/8 w - - 0 1', -20],
['8/8/8/8/8/8/P7/RBNQ4 w - - 0 1', 20],
['rb6/8/8/8/8/8/P7/2NQ4 w - - 0 1', 4],
['rbnq4/p7/8/8/8/8/8/8 w - - 0 1', -21],
['8/8/8/8/8/8/P7/RBNQ4 w - - 0 1', 21],
['rb6/8/8/8/8/8/P7/2NQ4 w - - 0 1', 5],
])('test FEN: %p', (fen, value) => {
expect(calculateMaterialImbalance(fenToPosition(fen))).toEqual(value)
})
Expand Down

0 comments on commit 322e448

Please sign in to comment.