Skip to content

Rule Error w/ pub fn is_linear_connected{} #15

@IntrepidT

Description

@IntrepidT

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:

Image. Hope this change can be made and thanks for building!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions