File tree Expand file tree Collapse file tree 2 files changed +51
-5
lines changed Expand file tree Collapse file tree 2 files changed +51
-5
lines changed Original file line number Diff line number Diff line change
1
+ use crate :: { labels, util, block} ;
2
+
3
+ pub fn print_probabilities ( ) {
4
+ let mut emu = util:: emulator ( None ) ;
5
+ let rng_seed = labels:: get ( "rng_seed" ) ;
6
+ let drought_modifier = labels:: get ( "droughtModifier" ) ;
7
+ let next_rng = labels:: get ( "pickRandomTetrimino" ) ;
8
+
9
+ let seed = 0x8988 ;
10
+ emu. memory . iram_raw [ ( rng_seed + 0 ) as usize ] = ( seed >> 8 ) as _ ;
11
+ emu. memory . iram_raw [ ( rng_seed + 1 ) as usize ] = seed as u8 ;
12
+ emu. memory . iram_raw [ labels:: get ( "practiseType" ) as usize ] = labels:: get ( "MODE_DROUGHT" ) as u8 ;
13
+
14
+ for modifier in 0 ..19 {
15
+ emu. memory . iram_raw [ drought_modifier as usize ] = modifier;
16
+
17
+ let mut longbars = 0 ;
18
+ let mut total = 0 ;
19
+
20
+ for _ in 0 ..100000 {
21
+ emu. registers . pc = next_rng;
22
+
23
+ util:: run_to_return ( & mut emu, false ) ;
24
+
25
+ let block: block:: Block = emu. memory . iram_raw [ labels:: get ( "spawnID" ) as usize ] . into ( ) ;
26
+
27
+ if block == block:: Block :: I {
28
+ longbars += 1 ;
29
+ }
30
+
31
+ total += 1 ;
32
+ }
33
+ println ! (
34
+ "{} longbar%: {:.2}" ,
35
+ "0123456789ABCDEFGHI" . as_bytes( ) [ modifier as usize ] as char ,
36
+ ( longbars as f64 / total as f64 ) * 100.
37
+ ) ;
38
+ }
39
+ }
Original file line number Diff line number Diff line change 1
1
mod block;
2
+ mod drought;
2
3
mod input;
3
4
mod labels;
4
5
mod pushdown;
8
9
mod util;
9
10
mod video;
10
11
11
-
12
12
use gumdrop:: Options ;
13
13
14
14
fn parse_hex ( s : & str ) -> Result < u32 , std:: num:: ParseIntError > {
@@ -26,6 +26,8 @@ struct TestOptions {
26
26
sps_qty : u32 ,
27
27
#[ options( help = "list RNG seeds" ) ]
28
28
rng_seeds : bool ,
29
+ #[ options( help = "list drought mode probabilities" ) ]
30
+ drought_probs : bool ,
29
31
foo : bool ,
30
32
}
31
33
@@ -64,6 +66,10 @@ fn main() {
64
66
println ! ( "{:?}" , rng:: seeds( ) ) ;
65
67
}
66
68
69
+ if options. drought_probs {
70
+ drought:: print_probabilities ( ) ;
71
+ }
72
+
67
73
// other stuff
68
74
69
75
if options. foo {
@@ -79,11 +85,12 @@ fn main() {
79
85
let mode_typeb = labels:: get ( "MODE_TYPEB" ) as u8 ;
80
86
81
87
rng:: seeds ( ) . iter ( ) . for_each ( |seed| {
82
-
83
88
emu. reset ( ) ;
84
89
85
90
// spend a few frames bootstrapping
86
- for _ in 0 ..3 { emu. run_until_vblank ( ) ; }
91
+ for _ in 0 ..3 {
92
+ emu. run_until_vblank ( ) ;
93
+ }
87
94
88
95
emu. memory . iram_raw [ practise_type] = mode_typeb;
89
96
emu. memory . iram_raw [ game_mode] = 4 ;
@@ -103,7 +110,7 @@ fn main() {
103
110
emu. ppu . render_ntsc ( video:: WIDTH ) ;
104
111
view. update ( & emu. ppu . filtered_screen ) ;
105
112
} ) ;
106
- loop {
107
- }
113
+ loop { }
108
114
}
115
+
109
116
}
You can’t perform that action at this time.
0 commit comments