-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrules.rs
84 lines (59 loc) · 1.69 KB
/
rules.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use std::fmt;
use crate::analysis::Analysis;
/// A legality rule, it updates the analysis on the legality of the position,
/// after deriving new information.
pub trait Rule: fmt::Debug {
/// Initializes the rule state for a given board.
fn new() -> Self
where
Self: Sized + fmt::Debug;
/// Update the rule's state based on the given analysis state.
fn update(&mut self, analysis: &Analysis);
/// Check whether or not it makes sense to apply the rule (we do not want to
/// apply a rule if we are sure it will not derive any new information).
fn is_applicable(&self, analysis: &Analysis) -> bool;
/// Applies the rule, possibly modifying the legality analysis after having
/// derived new information.
/// Returns `true` iff progress has been made.
fn apply(&self, analysis: &mut Analysis) -> bool;
}
mod material;
pub use material::*;
mod steady;
pub use steady::*;
mod origins;
pub use origins::*;
mod refine_origins;
pub use refine_origins::*;
mod destinies;
pub use destinies::*;
mod steady_mobility;
pub use steady_mobility::*;
mod royalty_on_1st_rank;
pub use royalty_on_1st_rank::*;
mod pawn_on_2nd_rank;
pub use pawn_on_2nd_rank::*;
mod pawn_on_3rd_rank;
pub use pawn_on_3rd_rank::*;
mod corner_knight;
pub use corner_knight::*;
mod mobility;
pub use mobility::*;
mod route_from_origins;
pub use route_from_origins::*;
mod route_to_reachable;
pub use route_to_reachable::*;
mod nb_captures;
pub use nb_captures::*;
mod surpassed_pawns;
pub use surpassed_pawns::*;
mod unretractable;
pub use unretractable::*;
mod missing;
pub use missing::*;
mod captures;
pub use captures::*;
mod tombs;
pub use tombs::*;
mod parity;
pub use parity::*;