Simplify the get_legal_moves method

It's cheap (and gets rid of boilerplate) to check for the field
occupancy inside the get_moves and get_captures funcitons.
This commit is contained in:
2021-12-27 20:29:39 +01:00
parent 5916a054ad
commit 0e8eb7b767

View File

@@ -23,15 +23,10 @@ impl Engine {
&self,
position: &board::Position,
) -> Result<impl Iterator<Item = board::Position> + '_, ()> {
if self.board.occupied(position) {
Ok(self
.board
.find_moves(position)
.unwrap()
.chain(self.board.find_captures(position).unwrap()))
} else {
Err(())
}
Ok(self
.board
.find_moves(position)?
.chain(self.board.find_captures(position)?))
}
pub fn make_move(
&mut self,