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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user