Struct backgammon_logic::board::Board [−][src]
pub struct Board { pub board: InternalBoard, pub bar_black: u8, pub bar_white: u8, }
Fields
board: InternalBoard
bar_black: u8
bar_white: u8
Methods
impl Board
[src]
impl Board
pub fn init() -> Board
[src]
pub fn init() -> Board
Return a board setup as such:
+11-10--9--8--7--6-----5--4--3--2--1--0-+
| B . . . W . | | W . . . . B |
| B . . . W . | | W . . . . B |
| B . . . W . | | W . . . . . |
| B . . . . . | | W . . . . . |
| B . . . . . | | W . . . . . |
| | | |
| W . . . . . | | B . . . . . |
| W . . . . . | | B . . . . . |
| W . . . B . | | B . . . . . |
| W . . . B . | | B . . . . W |
| W . . . B . | | B . . . . W |
+12-13-14-15-16-17----18-19-20-21-22-23-+
pub fn bar(&self, p: Player) -> u8
[src]
pub fn bar(&self, p: Player) -> u8
pub fn board(&self, p: Player) -> InternalBoard
[src]
pub fn board(&self, p: Player) -> InternalBoard
Returns a board that is counter-clockwise from the Player
.
pub fn apply_submove(&mut self, _s: Submove)
[src]
pub fn apply_submove(&mut self, _s: Submove)
pub fn validate_submove(&self, s: &Submove, p: Player) -> Result<bool, &str>
[src]
pub fn validate_submove(&self, s: &Submove, p: Player) -> Result<bool, &str>
Check if a submove is legal. Returns true
if valid or false
if invalid.
Checks (in order):
- Ensure chequer exists
- Check chequer ownership
- Check bar
- Check not moving onto an opponent's point
pub fn pips(&mut self, p: Player) -> u16
[src]
pub fn pips(&mut self, p: Player) -> u16
Return the pip count for the Player
.
TODO: it would be nice to perform this functionally with zip()
and fold()
.