Skip to content

Commit

Permalink
Throw error on board sizes larger than 52
Browse files Browse the repository at this point in the history
For Go, points are specified with a-z or A-Z allowing 52 distinct
points. Past 52 there's no way in the SGF spec to specify a point, and
I think it's better to throw an error rather than pretending that's a
reasonable thing to try to render.
  • Loading branch information
julianandrews committed Oct 3, 2024
1 parent 3940432 commit cb45dc4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/goban.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ impl Stone {

fn get_board_size(sgf_node: &SgfNode<go::Prop>) -> Result<(u8, u8), GobanError> {
match sgf_node.get_property("SZ") {
Some(go::Prop::SZ(size)) => Ok(*size),
Some(go::Prop::SZ((x, y))) if *x <= 52 && *y <= 52 => Ok((*x, *y)),
None => Ok((19, 19)),
Some(_) => Err(GobanError::InvalidSzProperty),
_ => Err(GobanError::InvalidSzProperty),
}
}

Expand Down

0 comments on commit cb45dc4

Please sign in to comment.