@@ -8,6 +8,28 @@ mod tests {
8
8
9
9
use cetkaik_full_state_transition:: * ;
10
10
11
+ fn deincentivize_tam_move ( candidates : & [ message:: PureMove ] ) -> message:: PureMove {
12
+ use rand:: seq:: SliceRandom ;
13
+ use rand:: Rng ;
14
+ let mut rng = rand:: thread_rng ( ) ;
15
+ loop {
16
+ let cand = candidates. choose ( & mut rng) . unwrap ( ) ;
17
+
18
+ if ( rng. gen :: < f64 > ( ) < 0.05_f64 )
19
+ == matches ! ( cand,
20
+ message:: PureMove :: NormalMove (
21
+ message:: NormalMove :: TamMoveNoStep { ..}
22
+ ) | message:: PureMove :: NormalMove (
23
+ message:: NormalMove :: TamMoveStepsDuringFormer { ..}
24
+ ) | message:: PureMove :: NormalMove (
25
+ message:: NormalMove :: TamMoveStepsDuringLatter { ..}
26
+ ) )
27
+ {
28
+ return cand. to_owned ( ) ;
29
+ }
30
+ }
31
+ }
32
+
11
33
#[ must_use]
12
34
pub fn yield_random_next ( current_state : & state:: A , config : Config ) -> Option < state:: A > {
13
35
use rand:: seq:: SliceRandom ;
@@ -16,15 +38,15 @@ pub fn yield_random_next(current_state: &state::A, config: Config) -> Option<sta
16
38
let ( hop1zuo1_candidates, candidates) = current_state. get_candidates ( config) ;
17
39
let candidate = match ( & hop1zuo1_candidates[ ..] , & candidates[ ..] ) {
18
40
( [ ] , [ ] ) => return None , // stuck; yield no more
19
- ( [ ] , candidates) => candidates . choose ( & mut rng ) . unwrap ( ) ,
20
- ( hop1zuo1_candidates, [ ] ) => hop1zuo1_candidates. choose ( & mut rng) . unwrap ( ) ,
41
+ ( [ ] , candidates) => deincentivize_tam_move ( & candidates ) ,
42
+ ( hop1zuo1_candidates, [ ] ) => hop1zuo1_candidates. choose ( & mut rng) . unwrap ( ) . to_owned ( ) ,
21
43
( hop1zuo1_candidates, candidates) => {
22
- if rng. gen :: < f64 > ( ) < 0.1_f64 {
44
+ if rng. gen :: < f64 > ( ) < 0.01_f64 {
23
45
// choose randomly from hop1zuo1_candidates
24
- hop1zuo1_candidates. choose ( & mut rng) . unwrap ( )
46
+ hop1zuo1_candidates. choose ( & mut rng) . unwrap ( ) . to_owned ( )
25
47
} else {
26
48
// choose randomly from candidates
27
- candidates . choose ( & mut rng ) . unwrap ( )
49
+ deincentivize_tam_move ( & candidates )
28
50
}
29
51
}
30
52
}
@@ -39,7 +61,9 @@ pub fn yield_random_next(current_state: &state::A, config: Config) -> Option<sta
39
61
40
62
let c_candidates = c. get_candidates ( config) ;
41
63
42
- let c_msg = * c_candidates. choose ( & mut rng) . expect ( "This cannot fail, because it is always legal to cancel" ) ;
64
+ let c_msg = * c_candidates
65
+ . choose ( & mut rng)
66
+ . expect ( "This cannot fail, because it is always legal to cancel" ) ;
43
67
44
68
let ( hand_not_resolved, maybe_ciurl) = apply_after_half_acceptance ( & c, c_msg, config)
45
69
. map_err ( |e| format ! ( "Internal error in yield_random_next: {}" , e) )
0 commit comments