Stockfish 在完美功能上给出了矛盾的结果
Stockfish giving contradictory results on perft funtion
我正在开发一个 Unity 国际象棋程序,我正在使用 stockfish 通过比较 perft 函数结果来调试我的移动生成算法。
在这个深度为 2 的位置 (8/2p5/3p4/1P5r/1K5k/5p2/4P1P1/1R6 b - - 0 1
) 上,Stockfish 给出了这个结果:
f3f2: 20
d6d5: 22
c7c6: 23
c7c5: 7
f3e2: 18
f3g2: 18
h5b5: 5
h5c5: 20
h5d5: 22
h5e5: 22
h5f5: 22
h5g5: 22
h5h6: 22
h5h7: 22
h5h8: 22
h4g3: 20
h4g5: 22
h4g4: 21
Nodes searched: 350
然后,如果我尝试通过将 fen 字符串更改为此 (8/8/3p4/1Pp4r/1K5k/5p2/4P1P1/1R6 w - - 0 1
) 并将深度更改为 1 来应用移动 c7c5,Stockfish 仅提供 6 个输出:
b4a3: 1
b4b3: 1
b4c3: 1
b4a4: 1
b4c4: 1
b4a5: 1
Nodes searched: 6
所以它给出的输出是 6 而不是 7,正如它在深度 2 中所说的那样(c7c5: 7 意味着在移动 c7c5 之后有 7 种可能的对手反应)。为什么会这样?
position fen 8/2p5/3p4/1P5r/1K5k/5p2/4P1P1/1R6 b - - 0 1
d
+---+---+---+---+---+---+---+---+
| | | | | | | | | 8
+---+---+---+---+---+---+---+---+
| | | p | | | | | | 7
+---+---+---+---+---+---+---+---+
| | | | p | | | | | 6
+---+---+---+---+---+---+---+---+
| | P | | | | | | r | 5
+---+---+---+---+---+---+---+---+
| | K | | | | | | k | 4
+---+---+---+---+---+---+---+---+
| | | | | | p | | | 3
+---+---+---+---+---+---+---+---+
| | | | | P | | P | | 2
+---+---+---+---+---+---+---+---+
| | R | | | | | | | 1
+---+---+---+---+---+---+---+---+
a b c d e f g h
Fen: 8/2p5/3p4/1P5r/1K5k/5p2/4P1P1/1R6 b - - 0 1
Key: EF2C6A67E054E287
Checkers:
go perft 2
f3f2: 20
d6d5: 22
c7c6: 23
c7c5: 7
f3e2: 18
f3g2: 18
h5b5: 5
h5c5: 20
h5d5: 22
h5e5: 22
h5f5: 22
h5g5: 22
h5h6: 22
h5h7: 22
h5h8: 22
h4g3: 20
h4g5: 22
h4g4: 21
Nodes searched: 350
position fen 8/8/3p4/1Pp4r/1K5k/5p2/4P1P1/1R6 w - - 0 1
d
+---+---+---+---+---+---+---+---+
| | | | | | | | | 8
+---+---+---+---+---+---+---+---+
| | | | | | | | | 7
+---+---+---+---+---+---+---+---+
| | | | p | | | | | 6
+---+---+---+---+---+---+---+---+
| | P | p | | | | | r | 5
+---+---+---+---+---+---+---+---+
| | K | | | | | | k | 4
+---+---+---+---+---+---+---+---+
| | | | | | p | | | 3
+---+---+---+---+---+---+---+---+
| | | | | P | | P | | 2
+---+---+---+---+---+---+---+---+
| | R | | | | | | | 1
+---+---+---+---+---+---+---+---+
a b c d e f g h
Fen: 8/8/3p4/1Pp4r/1K5k/5p2/4P1P1/1R6 w - - 0 1
Key: 17EBC3EFE240B12C
Checkers: c5
go perft 1
b4a3: 1
b4b3: 1
b4c3: 1
b4a4: 1
b4c4: 1
b4a5: 1
Nodes searched: 6
这是完整的命令
您使用的 FEN 有误。走c7c5
后的FEN串是8/8/3p4/1Pp4r/1K5k/5p2/4P1P1/1R6 w - c6 0 2
。你忘记了过路人广场。
我正在开发一个 Unity 国际象棋程序,我正在使用 stockfish 通过比较 perft 函数结果来调试我的移动生成算法。
在这个深度为 2 的位置 (8/2p5/3p4/1P5r/1K5k/5p2/4P1P1/1R6 b - - 0 1
) 上,Stockfish 给出了这个结果:
f3f2: 20
d6d5: 22
c7c6: 23
c7c5: 7
f3e2: 18
f3g2: 18
h5b5: 5
h5c5: 20
h5d5: 22
h5e5: 22
h5f5: 22
h5g5: 22
h5h6: 22
h5h7: 22
h5h8: 22
h4g3: 20
h4g5: 22
h4g4: 21
Nodes searched: 350
然后,如果我尝试通过将 fen 字符串更改为此 (8/8/3p4/1Pp4r/1K5k/5p2/4P1P1/1R6 w - - 0 1
) 并将深度更改为 1 来应用移动 c7c5,Stockfish 仅提供 6 个输出:
b4a3: 1
b4b3: 1
b4c3: 1
b4a4: 1
b4c4: 1
b4a5: 1
Nodes searched: 6
所以它给出的输出是 6 而不是 7,正如它在深度 2 中所说的那样(c7c5: 7 意味着在移动 c7c5 之后有 7 种可能的对手反应)。为什么会这样?
position fen 8/2p5/3p4/1P5r/1K5k/5p2/4P1P1/1R6 b - - 0 1
d
+---+---+---+---+---+---+---+---+
| | | | | | | | | 8
+---+---+---+---+---+---+---+---+
| | | p | | | | | | 7
+---+---+---+---+---+---+---+---+
| | | | p | | | | | 6
+---+---+---+---+---+---+---+---+
| | P | | | | | | r | 5
+---+---+---+---+---+---+---+---+
| | K | | | | | | k | 4
+---+---+---+---+---+---+---+---+
| | | | | | p | | | 3
+---+---+---+---+---+---+---+---+
| | | | | P | | P | | 2
+---+---+---+---+---+---+---+---+
| | R | | | | | | | 1
+---+---+---+---+---+---+---+---+
a b c d e f g h
Fen: 8/2p5/3p4/1P5r/1K5k/5p2/4P1P1/1R6 b - - 0 1
Key: EF2C6A67E054E287
Checkers:
go perft 2
f3f2: 20
d6d5: 22
c7c6: 23
c7c5: 7
f3e2: 18
f3g2: 18
h5b5: 5
h5c5: 20
h5d5: 22
h5e5: 22
h5f5: 22
h5g5: 22
h5h6: 22
h5h7: 22
h5h8: 22
h4g3: 20
h4g5: 22
h4g4: 21
Nodes searched: 350
position fen 8/8/3p4/1Pp4r/1K5k/5p2/4P1P1/1R6 w - - 0 1
d
+---+---+---+---+---+---+---+---+
| | | | | | | | | 8
+---+---+---+---+---+---+---+---+
| | | | | | | | | 7
+---+---+---+---+---+---+---+---+
| | | | p | | | | | 6
+---+---+---+---+---+---+---+---+
| | P | p | | | | | r | 5
+---+---+---+---+---+---+---+---+
| | K | | | | | | k | 4
+---+---+---+---+---+---+---+---+
| | | | | | p | | | 3
+---+---+---+---+---+---+---+---+
| | | | | P | | P | | 2
+---+---+---+---+---+---+---+---+
| | R | | | | | | | 1
+---+---+---+---+---+---+---+---+
a b c d e f g h
Fen: 8/8/3p4/1Pp4r/1K5k/5p2/4P1P1/1R6 w - - 0 1
Key: 17EBC3EFE240B12C
Checkers: c5
go perft 1
b4a3: 1
b4b3: 1
b4c3: 1
b4a4: 1
b4c4: 1
b4a5: 1
Nodes searched: 6
这是完整的命令
您使用的 FEN 有误。走c7c5
后的FEN串是8/8/3p4/1Pp4r/1K5k/5p2/4P1P1/1R6 w - c6 0 2
。你忘记了过路人广场。