/
DoubledPawnEvalTest.php
101 lines (81 loc) · 3.34 KB
/
DoubledPawnEvalTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
namespace Chess\Tests\Unit\Eval;
use Chess\Eval\DoubledPawnEval;
use Chess\Piece\AsciiArray;
use Chess\Tests\AbstractUnitTestCase;
use Chess\Variant\Classical\PGN\AN\Square;
use Chess\Variant\Classical\Rule\CastlingRule;
class DoubledPawnEvalTest extends AbstractUnitTestCase
{
static private $size;
static private $castlingRule;
public static function setUpBeforeClass(): void
{
self::$size = Square::SIZE;
self::$castlingRule = (new CastlingRule())->getRule();
}
/**
* @test
*/
public function kaufman_16()
{
$expectedResult = [
'w' => 1,
'b' => 0,
];
$expectedExplanation = [
"Black has a slight doubled pawn advantage.",
];
$expectedElaboration = [
"The pawn on b3 is doubled.",
];
$position = [
7 => [ ' . ', ' . ', ' . ', ' . ', ' . ', ' . ', ' . ', ' . ' ],
6 => [ ' . ', ' . ', ' . ', ' . ', ' p ', ' . ', ' . ', ' . ' ],
5 => [ ' p ', ' . ', ' . ', ' p ', ' . ', ' . ', ' . ', ' . ' ],
4 => [ ' . ', ' . ', ' p ', ' P ', ' . ', ' . ', ' . ', ' . ' ],
3 => [ ' . ', ' . ', ' P ', ' . ', ' P ', ' . ', ' . ', ' . ' ],
2 => [ ' . ', ' P ', ' . ', ' . ', ' . ', ' . ', ' k ', ' . ' ],
1 => [ ' . ', ' P ', ' . ', ' K ', ' . ', ' . ', ' . ', ' . ' ],
0 => [ ' . ', ' . ', ' . ', ' . ', ' . ', ' . ', ' . ', ' . ' ],
];
$board = (new AsciiArray($position, self::$size, self::$castlingRule))
->toClassicalBoard('\Chess\Variant\Classical\Board', 'w');
$doubledPawnEval = new DoubledPawnEval($board);
$this->assertSame($expectedResult, $doubledPawnEval->getResult());
$this->assertSame($expectedExplanation, $doubledPawnEval->getExplanation());
$this->assertSame($expectedElaboration, $doubledPawnEval->getElaboration());
}
/**
* @test
*/
public function kaufman_17()
{
$expectedResult = [
'w' => 0,
'b' => 1,
];
$expectedExplanation = [
"White has a slight doubled pawn advantage.",
];
$expectedElaboration = [
"The pawn on c6 is doubled.",
];
$position = [
7 => [ ' . ', ' r ', ' . ', ' q ', ' . ', ' r ', ' k ', ' . ' ],
6 => [ ' p ', ' . ', ' p ', ' . ', ' . ', ' p ', ' b ', ' p ' ],
5 => [ ' . ', ' . ', ' p ', ' p ', ' . ', ' k ', ' p ', ' . ' ],
4 => [ ' . ', ' . ', ' . ', ' . ', ' . ', ' . ', ' B ', ' . ' ],
3 => [ ' . ', ' . ', ' . ', ' . ', ' P ', ' . ', ' . ', ' . ' ],
2 => [ ' . ', ' . ', ' N ', ' Q ', ' . ', ' . ', ' . ', ' . ' ],
1 => [ ' P ', ' P ', ' P ', ' . ', ' . ', ' P ', ' P ', ' P ' ],
0 => [ ' . ', ' . ', ' . ', ' R ', ' . ', ' R ', ' K ', ' . ' ],
];
$board = (new AsciiArray($position, self::$size, self::$castlingRule))
->toClassicalBoard('\Chess\Variant\Classical\Board', 'w');
$doubledPawnEval = new DoubledPawnEval($board);
$this->assertSame($expectedResult, $doubledPawnEval->getResult());
$this->assertSame($expectedExplanation, $doubledPawnEval->getExplanation());
$this->assertSame($expectedElaboration, $doubledPawnEval->getElaboration());
}
}