-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This overhauls the way MoveTable is used by boxing it in a new struct NoArc. NoArc is a thread-safe way to read a block of memory. Essentially every file in the engine had to change, because essentially every file used GameManager or MoveTable in some way. It shouldn't be too horrible to sort through, though!
- Loading branch information
1 parent
9dd6cb5
commit 2a7943c
Showing
12 changed files
with
148 additions
and
202 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,13 @@ | ||
use crate::types::Move; | ||
|
||
use super::GameManager; | ||
use super::{GameManager, MoveTable, NoArc}; | ||
use rayon::prelude::*; | ||
|
||
pub fn perft(depth: u16, maxdepth: u16, mv: Move, gm: GameManager) { | ||
if depth > maxdepth { | ||
return; | ||
} | ||
let mvlst = gm.legal_moves(); | ||
let count = mvlst.iter().count(); | ||
pub fn perft(depth: u16, maxdepth: u16, gm: GameManager, tbl: &NoArc<MoveTable>) -> u64 { | ||
if depth == maxdepth { | ||
//let s = format!("{}{}: ", mv.1.to_str(), mv.2.to_str()).to_ascii_lowercase(); | ||
//println!("{}", s); | ||
//eprintln!("MOVE AT DEPTH {depth}"); | ||
//println!("{s}{}", mvlst.iter().count()); | ||
1 | ||
} else { | ||
gm.legal_moves(tbl) | ||
.into_par_iter() | ||
.map(|mv| perft(depth + 1, maxdepth, mv.4, tbl)) | ||
.sum::<u64>() | ||
} | ||
mvlst | ||
.into_par_iter() | ||
.for_each(|(pc, from, to, mvtp, modgm)| { | ||
perft(depth + 1, maxdepth, (pc, from, to, mvtp.clone()), modgm) | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.