Skip to content

Commit be06018

Browse files
committed
update readme + add count of pieces
1 parent 8687a45 commit be06018

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ Reversi in any language.
55

66
## Features
77

8-
- [ ] List of Legal moves
8+
- [x] List of Legal moves
9+
- [x] Piece placement and list of pieces that were turned
910
- [ ] AI Enemy using [MiniMax Algorithm](https://en.wikipedia.org/wiki/Minimax)

src/board.rs

+8
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ impl Board {
120120
}
121121
}
122122

123+
pub fn player1_count(&self) -> usize {
124+
self.p1.iter().fold(0, |acc, &row| acc + row.count_ones()) as usize
125+
}
126+
127+
pub fn player2_count(&self) -> usize {
128+
self.p2.iter().fold(0, |acc, &row| acc + row.count_ones()) as usize
129+
}
130+
123131
pub fn neighbours<T: Into<Position>>(&self, pos: T) -> Neighbours {
124132
let pos = pos.into();
125133
let row = pos.row();

0 commit comments

Comments
 (0)