[perft] Add back the block on searching into seen positions
Check if the board position has been seen and stop recursion if so.
This commit is contained in:
		
							parent
							
								
									bf17017694
								
							
						
					
					
						commit
						c5cc0646ef
					
				
					 1 changed files with 8 additions and 4 deletions
				
			
		|  | @ -18,14 +18,18 @@ impl Position { | |||
| 
 | ||||
|         let legal_moves: Vec<GeneratedMove> = self.all_legal_moves(None).collect(); | ||||
| 
 | ||||
|         for ply in legal_moves { | ||||
|             let ply = ply.ply(); | ||||
|         for generated_ply in legal_moves { | ||||
|             let ply = generated_ply.ply(); | ||||
| 
 | ||||
|             let _has_seen_position = self | ||||
|             let has_seen_position = self | ||||
|                 .make_move(ply, ValidateMove::No) | ||||
|                 .expect("unable to make generated move"); | ||||
| 
 | ||||
|             let nodes_counted = self.perft_recursive(depth - 1, depth); | ||||
|             let nodes_counted = if has_seen_position { | ||||
|                 1 | ||||
|             } else { | ||||
|                 self.perft_recursive(depth - 1, max_depth) | ||||
|             }; | ||||
| 
 | ||||
|             total_nodes_counted += nodes_counted; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue