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
pub mod point; pub mod utils; pub use bk2d_macro::*; use point::*; pub trait Action { fn name(&self) -> &'static str; fn stage(&self) -> u32; } pub trait Public { fn round(&self) -> u32; fn id(&self) -> u64; } pub trait BK2D { type Error: std::error::Error; type Player: Player; type Action: Action + Clone; type ActionResult; type Public: Public + Clone; type Options: std::default::Default; fn new(board: Board, options: Self::Options) -> Self; fn add_player(&mut self, p: Self::Player) -> Result<(), Self::Error>; fn current_player(&self) -> &<Self::Player as Player>::Ident; fn next_player(&mut self) -> &<Self::Player as Player>::Ident; fn start(&mut self); fn action(&mut self, action: Self::Action) -> Result<Self::ActionResult, Self::Error>; fn is_start(&self) -> bool; fn round(&self) -> u32; fn public_actions(&self, round: Option<u32>) -> &[Self::Public]; fn public_actions_from(&self, start: u64, end: Option<u64>) -> &[Self::Public]; fn win(&self) -> Option<&<Self::Player as Player>::Ident>; } pub trait Player { type Ident; fn ident(&self) -> &Self::Ident; fn location(&self) -> &Point; } #[cfg(test)] mod tests;