Support multiple seed pools
This commit is contained in:
110
simulator/level_7.txt
Normal file
110
simulator/level_7.txt
Normal file
@ -0,0 +1,110 @@
|
||||
81
|
||||
11
|
||||
124
|
||||
76
|
||||
10
|
||||
111
|
||||
128
|
||||
63
|
||||
106
|
||||
136
|
||||
50
|
||||
150
|
||||
6
|
||||
152
|
||||
74
|
||||
27
|
||||
113
|
||||
91
|
||||
171
|
||||
18
|
||||
167
|
||||
16
|
||||
125
|
||||
51
|
||||
148
|
||||
198
|
||||
93
|
||||
146
|
||||
200
|
||||
219
|
||||
196
|
||||
83
|
||||
177
|
||||
14
|
||||
237
|
||||
36
|
||||
262
|
||||
239
|
||||
276
|
||||
169
|
||||
285
|
||||
138
|
||||
242
|
||||
241
|
||||
259
|
||||
299
|
||||
302
|
||||
279
|
||||
182
|
||||
166
|
||||
191
|
||||
159
|
||||
306
|
||||
255
|
||||
320
|
||||
309
|
||||
295
|
||||
328
|
||||
313
|
||||
373
|
||||
269
|
||||
348
|
||||
340
|
||||
388
|
||||
286
|
||||
354
|
||||
428
|
||||
382
|
||||
398
|
||||
322
|
||||
441
|
||||
343
|
||||
469
|
||||
319
|
||||
453
|
||||
488
|
||||
456
|
||||
520
|
||||
525
|
||||
414
|
||||
508
|
||||
361
|
||||
529
|
||||
527
|
||||
521
|
||||
494
|
||||
569
|
||||
563
|
||||
417
|
||||
580
|
||||
589
|
||||
594
|
||||
614
|
||||
605
|
||||
422
|
||||
596
|
||||
505
|
||||
593
|
||||
676
|
||||
511
|
||||
682
|
||||
660
|
||||
413
|
||||
512
|
||||
483
|
||||
716
|
||||
722
|
||||
731
|
||||
629
|
||||
696
|
@ -1,4 +1,4 @@
|
||||
use std::{borrow::Borrow, fs::File, io::Write, sync::{Arc, Mutex}};
|
||||
use std::{fs::File, io::Write, sync::{Arc, Mutex}};
|
||||
|
||||
use board::Board;
|
||||
use ruleset::Ruleset;
|
||||
@ -16,28 +16,7 @@ mod zobrist;
|
||||
|
||||
fn main() {
|
||||
/*
|
||||
let mut rng = PicoRng::srand(0x20000);
|
||||
for _ in 0..10 {
|
||||
println!("{}", rng.rnd(0x10000));
|
||||
}
|
||||
return;
|
||||
*/
|
||||
|
||||
/*
|
||||
let ruleset = Ruleset {
|
||||
n_slots: 11,
|
||||
n_suits: 5,
|
||||
n_cards_per_suit: 10,
|
||||
n_arcana: 25
|
||||
};
|
||||
*/
|
||||
let ruleset = Ruleset {
|
||||
n_slots: 11,
|
||||
n_suits: 4,
|
||||
n_cards_per_suit: 13,
|
||||
n_arcana: 22
|
||||
};
|
||||
/*
|
||||
let filename = "level_1.txt";
|
||||
let ruleset = Ruleset {
|
||||
n_slots: 5,
|
||||
n_suits: 1,
|
||||
@ -46,6 +25,16 @@ fn main() {
|
||||
};
|
||||
*/
|
||||
/*
|
||||
let filename = "level_2.txt";
|
||||
let ruleset = Ruleset {
|
||||
n_slots: 5,
|
||||
n_suits: 2,
|
||||
n_cards_per_suit: 9,
|
||||
n_arcana: 0
|
||||
};
|
||||
*/
|
||||
/*
|
||||
let filename = "level_3.txt";
|
||||
let ruleset = Ruleset {
|
||||
n_slots: 7,
|
||||
n_suits: 2,
|
||||
@ -54,37 +43,61 @@ fn main() {
|
||||
};
|
||||
*/
|
||||
/*
|
||||
let filename = "level_4.txt";
|
||||
let ruleset = Ruleset {
|
||||
n_slots: 9,
|
||||
n_suits: 3,
|
||||
n_cards_per_suit: 9,
|
||||
n_arcana: 16
|
||||
};
|
||||
*/
|
||||
/*
|
||||
let filename = "level_5.txt";
|
||||
let ruleset = Ruleset {
|
||||
n_slots: 9,
|
||||
n_suits: 3,
|
||||
n_cards_per_suit: 11,
|
||||
n_arcana: 18
|
||||
};
|
||||
*/
|
||||
/*
|
||||
let filename = "fortunes_foundation.txt";
|
||||
let ruleset = Ruleset {
|
||||
n_slots: 11,
|
||||
n_suits: 4,
|
||||
n_cards_per_suit: 13,
|
||||
n_arcana: 22
|
||||
};
|
||||
*/
|
||||
|
||||
let filename = "level_7.txt";
|
||||
let ruleset = Ruleset {
|
||||
n_slots: 11,
|
||||
n_suits: 5,
|
||||
n_cards_per_suit: 10,
|
||||
n_arcana: 25
|
||||
};
|
||||
|
||||
let setup = ruleset.compile().expect("compilation should succeed");
|
||||
/*
|
||||
for _ in 0..10000 {
|
||||
Deal::deal(&setup, &mut rand::thread_rng());
|
||||
}
|
||||
*/
|
||||
|
||||
const THREADS: usize = 28;
|
||||
let winnable_seeds_file = Arc::new(Mutex::new(File::create("winnable_seeds_multithreaded.txt").expect("should be able to create")));
|
||||
let work_source: WorkSource = WorkSource::new(0);
|
||||
let winnable_seeds_file = Arc::new(Mutex::new(File::create(filename).expect("should be able to create")));
|
||||
|
||||
let mut threads = Vec::new();
|
||||
for i in 0..THREADS {
|
||||
for _ in 0..THREADS {
|
||||
let setup2 = setup.clone();
|
||||
let source = work_source.clone();
|
||||
let wsf = winnable_seeds_file.clone();
|
||||
threads.push(std::thread::spawn(move || {
|
||||
winnable_seeds_thread(
|
||||
&setup2,
|
||||
source,
|
||||
|seed| {
|
||||
let mut f = wsf.lock().expect("must be able to lock");
|
||||
write!(f, "{}\n", seed).expect("write should succeed");
|
||||
f.flush().expect("flush should succeed");
|
||||
},
|
||||
i as u32,
|
||||
THREADS as u32
|
||||
);
|
||||
}));
|
||||
}
|
||||
@ -95,11 +108,31 @@ fn main() {
|
||||
|
||||
}
|
||||
|
||||
fn winnable_seeds_thread(setup: &ruleset::Setup, mut cb: impl FnMut(u32), start: u32, step: u32) {
|
||||
#[derive(Clone)]
|
||||
struct WorkSource {
|
||||
seed: Arc<Mutex<Option<u32>>>
|
||||
}
|
||||
|
||||
impl WorkSource {
|
||||
fn new(seed: u32) -> Self {
|
||||
return WorkSource { seed: Arc::new(Mutex::new(Some(seed))) }
|
||||
}
|
||||
|
||||
fn take(&self) -> Option<u32> {
|
||||
let mut self_seed = self.seed.lock().expect("shouldn't have panicked");
|
||||
if let Some(seed) = *self_seed {
|
||||
*self_seed = seed.checked_add(1);
|
||||
return Some(seed);
|
||||
}
|
||||
return None
|
||||
}
|
||||
}
|
||||
|
||||
fn winnable_seeds_thread(setup: &ruleset::Setup, source: WorkSource, mut cb: impl FnMut(u32)) {
|
||||
let mut winnable = 0;
|
||||
let mut total = 0;
|
||||
|
||||
for seed in (start..0xffffffff).step_by(step as usize) {
|
||||
while let Some(seed) = source.take() {
|
||||
let mut board = Board::new(&setup);
|
||||
board.deal(Deal::deal(&setup, seed));
|
||||
board.display();
|
||||
|
@ -10832,3 +10832,109 @@
|
||||
85247
|
||||
92829
|
||||
91669
|
||||
97597
|
||||
85443
|
||||
84931
|
||||
91729
|
||||
88458
|
||||
92969
|
||||
95686
|
||||
86653
|
||||
88570
|
||||
86989
|
||||
79762
|
||||
87578
|
||||
90767
|
||||
89826
|
||||
86559
|
||||
90667
|
||||
89319
|
||||
89598
|
||||
85609
|
||||
89626
|
||||
89416
|
||||
88794
|
||||
90134
|
||||
87662
|
||||
97716
|
||||
91243
|
||||
92688
|
||||
86171
|
||||
96000
|
||||
93473
|
||||
79902
|
||||
86671
|
||||
87690
|
||||
97877
|
||||
86923
|
||||
89767
|
||||
86057
|
||||
93557
|
||||
92638
|
||||
90891
|
||||
90919
|
||||
89823
|
||||
90883
|
||||
89822
|
||||
89878
|
||||
92881
|
||||
84476
|
||||
92722
|
||||
92513
|
||||
92716
|
||||
84588
|
||||
94005
|
||||
98017
|
||||
89836
|
||||
90088
|
||||
94145
|
||||
90172
|
||||
90995
|
||||
92597
|
||||
97884
|
||||
90312
|
||||
80182
|
||||
88850
|
||||
80294
|
||||
81556
|
||||
84840
|
||||
96140
|
||||
91753
|
||||
80434
|
||||
90974
|
||||
91087
|
||||
91809
|
||||
94453
|
||||
98024
|
||||
87129
|
||||
81948
|
||||
82004
|
||||
91271
|
||||
86197
|
||||
91311
|
||||
90718
|
||||
85323
|
||||
87157
|
||||
92793
|
||||
92905
|
||||
91977
|
||||
94789
|
||||
94817
|
||||
85407
|
||||
96224
|
||||
98248
|
||||
91479
|
||||
88082
|
||||
85631
|
||||
91535
|
||||
91591
|
||||
85064
|
||||
82200
|
||||
98500
|
||||
89102
|
||||
98640
|
||||
80518
|
||||
82312
|
||||
82480
|
||||
89158
|
||||
96308
|
5627
simulator/src/seed_archive/level_1.txt
Normal file
5627
simulator/src/seed_archive/level_1.txt
Normal file
File diff suppressed because it is too large
Load Diff
6198
simulator/src/seed_archive/level_2.txt
Normal file
6198
simulator/src/seed_archive/level_2.txt
Normal file
File diff suppressed because it is too large
Load Diff
5253
simulator/src/seed_archive/level_3.txt
Normal file
5253
simulator/src/seed_archive/level_3.txt
Normal file
File diff suppressed because it is too large
Load Diff
5069
simulator/src/seed_archive/level_4.txt
Normal file
5069
simulator/src/seed_archive/level_4.txt
Normal file
File diff suppressed because it is too large
Load Diff
5612
simulator/src/seed_archive/level_5.txt
Normal file
5612
simulator/src/seed_archive/level_5.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user