diff options
| author | tslil clingman <> | 2020-01-11 23:36:41 -0500 |
|---|---|---|
| committer | tslil clingman <> | 2020-01-11 23:36:41 -0500 |
| commit | 5ae986b316b0be692e79203f79a00a8afdd71a77 (patch) | |
| tree | e4d97555f4bf12d6c05b4c1c8063413445046ee6 /src/board.rs | |
| parent | 258e083264971acd3ef7ace721083972954f45e1 (diff) | |
Notes about action checking and generation
Diffstat (limited to 'src/board.rs')
| -rw-r--r-- | src/board.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/board.rs b/src/board.rs index 626dcb0..9ba89dc 100644 --- a/src/board.rs +++ b/src/board.rs @@ -96,9 +96,22 @@ type Stack = Vec<(Player, Stone)>; pub struct Board { size: u16, + black_flats: u8, + white_flats: u8, + black_capstones: u8, + white_capstones: u8, board: Vec<Stack>, } +// Probably it's best to split the move and place actions into their +// own methods, they should also take an extra argument which can be +// used to log error messages + +// How to solve code duplication between is_legal_action and +// perform_action? + +// TODO: Generate all legal actions for a given player + impl Board { fn lookup(&self, pos: &Position) -> Option<&Stack> { let y: u16 = pos.y as u16; @@ -106,10 +119,12 @@ impl Board { self.board.get((x + y * self.size) as usize) } - fn is_legal_move(&self, mov: &Action) -> bool { + fn is_legal_action(&self, mov: &Action) -> bool { match mov { - Action::Place(_, pos, _) => match self.lookup(pos) { + Action::Place(player, pos, piece) => match self.lookup(pos) { Some(stack) => { + // Incomplete and incorrect, must take account of + // piece availabilty if stack.len() == 0 { true } else { |
