Skip to content

Commit

Permalink
everything should work smoothly now
Browse files Browse the repository at this point in the history
  • Loading branch information
MinusKelvin committed Oct 14, 2020
1 parent 246acd6 commit f766828
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions opening-book/book-builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ fn main() {

dbg!(book.value_of_position(Board::new().into()));

dump(&book);

book.compile(&[Board::new().into()]).save(
std::fs::File::create("book.ccbook").unwrap()
).unwrap();

dump(&book);
}

fn convert(p: fumen::Piece) -> FallingPiece {
Expand Down
2 changes: 1 addition & 1 deletion opening-book/pc-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() {
let (send, recv) = crossbeam_channel::bounded(256);
let count = &std::sync::atomic::AtomicUsize::new(0);
let mut all_seq = all_sequences(initial_bag);
all_seq.retain(|(_,b)| b.hold.is_none());
all_seq.retain(|(_,b)| b.hold.is_none() || b.bag == EnumSet::all());
let total = all_seq.len();
println!("Working on PC book {} ({} queues)", i, total);
rayon::scope(|s| {
Expand Down
6 changes: 4 additions & 2 deletions opening-book/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ impl BookBuilder {
self.0.keys().copied()
}

pub fn compile(&self, roots: &[Position]) -> Book {
pub fn compile(mut self, roots: &[Position]) -> Book {
let mut book = HashMap::new();
let mut to_compile = roots.to_vec();
while let Some(pos) = to_compile.pop() {
Expand All @@ -207,7 +207,7 @@ impl BookBuilder {
Book(book)
}

fn build_position(&self, pos: &Position) -> Vec<(Sequence, Option<FallingPiece>)> {
fn build_position(&mut self, pos: &Position) -> Vec<(Sequence, Option<FallingPiece>)> {
let mut sequences = vec![];
for (next, bag) in pos.next_possibilities() {
for (queue, _) in possible_sequences(vec![], bag) {
Expand All @@ -216,8 +216,10 @@ impl BookBuilder {
sequences.push((seq, mv));
}
}
self.0.remove(pos);
sequences.sort_by_key(|&(s, _)| s);
sequences.dedup_by_key(|&mut (_, m)| m);
sequences.shrink_to_fit();
sequences
}
}
Expand Down

0 comments on commit f766828

Please sign in to comment.