-
Notifications
You must be signed in to change notification settings - Fork 20
Description
pub fn is_linear_connected(board: &HashMap<(i32, i32), Piece>,
played: &[(i32, i32)]) -> bool {
let xmin = played.iter().map(|p| p.0).min().unwrap_or(0);
let ymin = played.iter().map(|p| p.1).min().unwrap_or(0);
let xmax = played.iter().map(|p| p.0).max().unwrap_or(0);
let ymax = played.iter().map(|p| p.1).max().unwrap_or(0);
// Fail if the play isn't constrained to a single row/column
if xmin != xmax && ymin != ymax {
return false;
}
/for x in xmin..=xmax {
for y in ymin..=ymax {
if !board.contains_key(&(x, y)) {
return false;
}
}
}/
true
}
I commented out the part of the function that validates whether there is a piece in all positions of the ranges between xmin -> xmax as well as ymin -> ymax. This is actually stricter that the rules of the game and reduces the number of points possible per turn significantly. Here is what the rulebook says:
