[perft, position] Print moves and nodes counted at first level
At the first level of depth, print the move and the number of nodes counted in the tree underneath that node. This behavior imitates Stockfish, and helps with debugging. Clean up the output of the Perft binary, and update the check-positions script to compensate.
This commit is contained in:
parent
37cb9bcaa0
commit
d73630c85e
3 changed files with 20 additions and 42 deletions
|
@ -10,7 +10,7 @@ import json
|
|||
import subprocess
|
||||
|
||||
|
||||
def run_perft(fen, depth, expected_nodes_count):
|
||||
def run_perft(fen, depth):
|
||||
result = subprocess.run(
|
||||
[
|
||||
'cargo',
|
||||
|
@ -26,8 +26,8 @@ def run_perft(fen, depth, expected_nodes_count):
|
|||
|
||||
nodes_count = 0
|
||||
for line in result.stdout.splitlines():
|
||||
if line.startswith('nodes='):
|
||||
(_, nodes_count) = line.split('=')
|
||||
if line.startswith('nodes '):
|
||||
(_, nodes_count) = line.split(' ')
|
||||
nodes_count = int(nodes_count)
|
||||
|
||||
return nodes_count
|
||||
|
@ -61,7 +61,7 @@ def main(argv):
|
|||
print(f'depth={depth}')
|
||||
print(f'expected-nodes={expected_nodes_count}')
|
||||
|
||||
nodes_count = run_perft(fen, depth, expected_nodes_count)
|
||||
nodes_count = run_perft(fen, depth)
|
||||
print(f'nodes={nodes_count}')
|
||||
|
||||
did_pass = nodes_count == expected_nodes_count
|
||||
|
|
|
@ -14,7 +14,7 @@ fn main() -> anyhow::Result<()> {
|
|||
let args = Arguments::parse();
|
||||
let depth = args.depth;
|
||||
|
||||
println!("depth={depth}");
|
||||
println!("depth {depth}");
|
||||
|
||||
let mut position = if let Some(fen) = args.fen {
|
||||
Position::from_fen_str(&fen)?
|
||||
|
@ -24,7 +24,7 @@ fn main() -> anyhow::Result<()> {
|
|||
|
||||
let nodes_searched = position.perft(depth);
|
||||
|
||||
println!("nodes={nodes_searched}");
|
||||
println!("nodes {nodes_searched}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue