1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! Core rules implementation for Voronoi Go. Machine translated from the original
//! implementation playable at [voronoigo.com].
//!
//! [voronoigo.com]: https://voronoigo.com
//!
//! This small section of docs was written by a human, but the rest can be assumed to
//! be machine-written unless stated otherwise. All of the code was also written
//! by a machine but reviewed by a human and verified against output from the
//! original implementation. For more information and support for using this implementation
//! in non-rust languages, visit [the repo]. For questions left unanswered by these docs,
//! you can also join [the discord] and ask there. I am happy to help you out.
//!
//! [the repo]: https://github.com/csun/voronoi-go-rs
//! [the discord]: https://discord.gg/4ren7UAFeb
//!
//! You'll mainly want to interact with the [`Game`] struct to play moves, calculate
//! territory, compute cuttability, etc. Code sample:
//! ```
//! use voronoi_go::{Game, Point};
//!
//! // A board nine stones across is 18 units wide: coordinates are stone radii.
//! let mut game = Game::new(18.0);
//!
//! game.try_move(Point::new(4.0, 4.0))?; // black
//! game.try_move(Point::new(14.0, 14.0))?; // white
//!
//! assert_eq!(game.stones().len(), 2);
//!
//! // Territory is area, and the two shares sum to the whole board.
//! let area = game.territory();
//! assert!((area.black() + area.white() - 18.0 * 18.0).abs() < 1e-9);
//!
//! // Undo restores the previous state bit for bit.
//! game.undo_move();
//! assert_eq!(game.stones().len(), 1);
//! # Ok::<(), voronoi_go::StonePlayError>(())
//! ```
//!
//! # Feature flags
//!
//! Both are on by default but are optional.
//!
//! - **`svg`** — [`Game::dump_svg`] and [`AliveZone::to_svg`], which write a
//! standalone board image. Items behind it are labelled on [docs.rs].
//! - **`serde`** — `Serialize`/`Deserialize` on the public data types. Required by the engine binary and the Python bindings.
//!
//! [docs.rs]: https://docs.rs/voronoi-go
// `doc_cfg` is nightly-only, and `docsrs` is set only by docs.rs and by
// `cargo docs-rs`. Every other build never sees the attribute, so this costs a
// stable build nothing while giving a reader feature labels where they look.
// The segment arena, the shapes and the shared-start index. Internal: nothing a
// consumer of the rules needs, and publishing it would freeze the one structure
// `docs/design.md` most wants free to change. The three names that leak through
// `ZoneError` are re-exported below.
pub
pub use ;
// Named by `ZoneError`'s variants, so they have to be reachable even though the
// module they come from is not.
pub use ;
pub use ;
pub use ;
pub use ;
pub use GameDelta;
pub use ;
pub use ;
pub use ;
pub use ;