Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified ABDADA #22

Merged
merged 16 commits into from
Dec 2, 2023
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ crc64 = "2.0.0"
anyhow = "1.0"
thiserror = "1.0"
arrayvec = "0.7.4"
num_cpus = "1.16.0"
async-recursion = "1.0"
dashmap = "5.5.3"
84 changes: 46 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,50 +29,58 @@ $ cargo run --release -- ffobench

## Benchmark result

- Date: 2023/11/12
- Date: 2023/12/01
- Hardware: AMD Ryzen 9 7950X3D, DDR5-4800 64GB
- Environment: Linux 5.15.0-88-generic, Ubuntu 22.04.3, rustc 1.75.0-nightly
- Environment: Linux 5.15.0-89-generic, Ubuntu 22.04.3, rustc 1.75.0-nightly

FFO 40-59

|No.|empties|result|answer|move|nodes|time|NPS|
|---:|---:|---:|---:|---:|---:|:--:|---:|
|40|20|+38|+38|A2|28.7M| 0.090s|316M/s|
|41|22| +0| +0|H4|36.1M| 0.140s|256M/s|
|42|22| +6| +6|G2|76.7M| 0.225s|339M/s|
|43|23|-12|-12|C7|41.2M| 0.174s|235M/s|
|44|23|-14|-14|D2|37.4M| 0.104s|356M/s|
|45|24| +6| +6|B2|1.19G| 1.389s|860M/s|
|46|24| -8| -8|B3| 172M| 0.525s|328M/s|
|47|25| +4| +4|G2|40.3M| 0.123s|325M/s|
|48|25|+28|+28|F6| 511M| 0.867s|589M/s|
|49|26|+16|+16|E1|2.10G| 3.767s|559M/s|
|50|26|+10|+10|D8|2.87G| 3.175s|904M/s|
|51|27| +6| +6|A3| 724M| 2.076s|348M/s|
|52|27| +0| +0|A3| 617M| 1.279s|482M/s|
|53|28| -2| -2|D8|3.30G| 5.317s|620M/s|
|54|28| -2| -2|C7|9.88G| 14.501s|681M/s|
|55|29| +0| +0|G6|22.9G| 37.539s|611M/s|
|56|29| +2| +2|H5|2.59G| 7.331s|354M/s|
|57|30|-10|-10|A6|12.7G| 26.499s|480M/s|
|58|30| +4| +4|G1|3.22G| 8.538s|378M/s|
|59|34|+64|+64|G8| 97| 0.030s|0M/s|

FFO 60-73
|40|20|+38|+38|A2|89.8M| 0.056s|1576M/s|
|41|22| +0| +0|H4| 106M| 0.079s|1332M/s|
|42|22| +6| +6|G2| 280M| 0.165s|1691M/s|
|43|23|-12|-12|C7| 190M| 0.146s|1294M/s|
|44|23|-14|-14|D2| 113M| 0.085s|1323M/s|
|45|24| +6| +6|B2|1.59G| 1.006s|1580M/s|
|46|24| -8| -8|B3| 502M| 0.351s|1427M/s|
|47|25| +4| +4|G2| 167M| 0.124s|1338M/s|
|48|25|+28|+28|F6| 954M| 0.721s|1321M/s|
|49|26|+16|+16|E1|3.00G| 1.905s|1576M/s|
|50|26|+10|+10|D8|3.49G| 2.752s|1270M/s|
|51|27| +6| +6|E2|1.52G| 1.255s|1210M/s|
|52|27| +0| +0|A3|1.40G| 1.145s|1229M/s|
|53|28| -2| -2|D8|5.41G| 4.412s|1226M/s|
|54|28| -2| -2|C7|15.5G| 10.756s|1441M/s|
|55|29| +0| +0|G6|30.3G| 29.226s|1039M/s|
|56|29| +2| +2|H5|5.31G| 5.211s|1019M/s|
|57|30|-10|-10|A6|24.2G| 22.297s|1089M/s|
|58|30| +4| +4|G1|6.53G| 6.084s|1074M/s|
|59|34|+64|+64|G8|2.00k| 0.041s|0M/s|
[Total] elapsed: 87828878us, node count: 100876738519, NPS: 1148560027nodes/sec

FFO 60-79

|No.|empties|result|answer|move|nodes|time|NPS|
|---:|---:|---:|---:|---:|---:|:--:|---:|
|60|24|+20|+20|C2|71.6M| 0.151s|471M/s|
|61|25|-14|-14|G1| 186M| 0.360s|517M/s|
|62|27|+28|+28|E8|4.95G| 8.081s|612M/s|
|63|27| -2| -2|F2|2.05G| 3.174s|645M/s|
|64|27|+20|+20|B4|6.60G| 11.802s|559M/s|
|65|28|+10|+10|G1|27.5G| 46.222s|596M/s|
|66|28|+30|+30|H3|15.7G| 19.343s|812M/s|
|67|28|+22|+22|H3|19.5G| 25.571s|765M/s|
|68|30|+28|+28|E8| 139G| 120.086s|1161M/s|
|69|30| +0| +0|H3|16.5G| 34.297s|481M/s|
|70|30|-24|-24|E3|7.66G| 16.387s|467M/s|
|71|31|+20|+20|D2|16.1G| 43.403s|372M/s|
|72|31|+24|+24|E1| 233G| 342.222s|683M/s|
|73|31| -4| -4|G4|21.2G| 61.781s|344M/s|
|60|24|+20|+20|C2| 211M| 0.159s|1324M/s|
|61|25|-14|-14|G1| 335M| 0.303s|1102M/s|
|62|27|+28|+28|E8|8.08G| 6.938s|1164M/s|
|63|27| -2| -2|F2|2.89G| 2.381s|1213M/s|
|64|27|+20|+20|B4|11.6G| 9.471s|1232M/s|
|65|28|+10|+10|G1|31.1G| 21.178s|1470M/s|
|66|28|+30|+30|H3|22.5G| 16.607s|1356M/s|
|67|28|+22|+22|H3|28.9G| 20.325s|1425M/s|
|68|30|+28|+28|E8| 153G| 115.037s|1335M/s|
|69|30| +0| +0|H3|18.2G| 15.637s|1164M/s|
|70|30|-24|-24|E3|16.1G| 13.649s|1182M/s|
|71|31|+20|+20|D2|27.6G| 25.330s|1091M/s|
|72|31|+24|+24|E1| 254G| 284.996s|892M/s|
|73|31| -4| -4|G4|34.2G| 38.391s|890M/s|
|74|31|-30|-30|F1| 846G| 762.676s|1109M/s|
|75|32|+14|+14|D2| 334G| 241.491s|1384M/s|
|76|32|+32|+32|A3|2.39T|2046.156s|1171M/s|
|77|34|+34|+34|B7|2.08T|1720.431s|1210M/s|
|78|34| +8| +8|F1|1.04T|1231.807s|845M/s|
|79|36|+64|+64|D7|28.2G| 33.405s|846M/s|
[Total] elapsed: 6606379988us, node count: 7340282057714, NPS: 1111089896nodes/sec
16 changes: 3 additions & 13 deletions src/book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use std::io::{BufRead, BufReader, BufWriter, Write};
use std::path::Path;
use std::sync::{Arc, Mutex};
use std::time::Instant;
use tokio::runtime::Runtime;

pub struct Book {
records: Vec<Record>,
Expand Down Expand Up @@ -170,17 +169,11 @@ impl Book {
}
}

fn search(
board: Board,
think_time_limit: u128,
solve_obj: &mut SolveObj,
rt: &Runtime,
sub_solver: &Arc<SubSolver>,
) -> Hand {
fn search(board: Board, think_time_limit: u128, solve_obj: &mut SolveObj, sub_solver: &Arc<SubSolver>) -> Hand {
solve_obj.cache_gen += 1;
if board.empty().count_ones() <= 18 {
let mut solve_obj = solve_obj.clone();
rt.block_on(async move { solve_with_move(board, &mut solve_obj, &sub_solver.clone()).await })
solve_with_move(board, &mut solve_obj, &sub_solver.clone())
} else {
let start = Instant::now();
let timer = Timer {
Expand Down Expand Up @@ -216,7 +209,6 @@ fn play_with_book(
book: Arc<Mutex<Book>>,
think_time_limit: u128,
solve_obj: &mut SolveObj,
rt: &Runtime,
rng: &mut SmallRng,
sub_solver: &Arc<SubSolver>,
) {
Expand All @@ -235,7 +227,7 @@ fn play_with_book(
continue;
}
}
let hand = search(board, think_time_limit, solve_obj, rt, &sub_solver);
let hand = search(board, think_time_limit, solve_obj, sub_solver);
hands.push(hand);
board = board.play_hand(hand).unwrap();
}
Expand All @@ -248,7 +240,6 @@ fn grow_book(in_book_path: &Path, out_book_path: &Path, repeat: usize) -> Result
let book = Arc::new(Mutex::new(Book::import(in_book_path)?));
let mut solve_obj = setup_default();
solve_obj.params.ybwc_empties_limit = 64;
let rt = Runtime::new().unwrap();
let sub_solver = Arc::new(SubSolver::new(&[]));
(0..repeat).into_par_iter().for_each(|i| {
let mut rng = SmallRng::seed_from_u64(0xbeefbeef + i as u64);
Expand All @@ -265,7 +256,6 @@ fn grow_book(in_book_path: &Path, out_book_path: &Path, repeat: usize) -> Result
book.clone(),
think_time_limit,
&mut solve_obj,
&rt,
&mut rng,
&sub_solver.clone(),
);
Expand Down
Loading
Loading