chesslablab / php-chess

A chess library for PHP offering move validation, common formats, multiple variants, UCI engine support, explanation of chess positions, and image recognition.
https://chesslablab.github.io/php-chess/
MIT License
110 stars 52 forks source link

Review the doubled pawn evaluation in the heuristic picture #114

Closed programarivm closed 3 years ago

programarivm commented 3 years ago

The following test in tests/unit/Game/HeuristicPictureTest.php should pass with the $expected array described below.

/**
 * @test
 */
public function kaufman_01_play_Nf6_gxf6()
{
    $game = new Game();
    $game->loadFen('1rbq1rk1/p1b1nppp/1p2p3/8/1B1pN3/P2B4/1P3PPP/2RQ1R1K w - - bm Nf6+');
    $game->play('w', 'Nf6');
    $game->play('b', 'gxf6');

    $expected = [
        [ -1, -1, -1, 1, 1, 0, 0, 0, -1 ],
    ];

    $balance = $game->heuristicPicture(true);

    $this->assertEquals($expected, $balance);
}

Expected array:

$expected = [
    [ -1, -1, -1, 1, 1, 0, 0, 0, 1 ],
];

Atm, it seems as if the doubled pawn evaluation is being calculated the other way around, however:

A chess game can be plotted in terms of balance. +1 is the best possible evaluation for White and -1 the best possible evaluation for Black. Both forces being set to 0 means they're actually offset and, therefore, balanced.

For further information, please visit:

Keep it up, and happy learning and coding.

programarivm commented 3 years ago

Hi @vikeng thanks for the help, it is very much appreciated.

Please let me know if you'd want to look at this issue.

Keep it up.

programarivm commented 3 years ago

Just realized that I implemented the doubled pawn evaluation https://github.com/chesslablab/php-chess/issues/50 and closed the issue, sorry about that.