Skip to main content

binoxxo/
lib.rs

1//! Binoxxo is a library to create and check binoxxo puzzles.
2//!
3//! # How to use
4//!
5//! Add `binoxxo` to your dependencies.
6//!
7//! # Create a puzzle
8//!
9//! A binoxxo puzzle is a square board with either X or O or empty fields.
10//! To fill the board the puzzler must fill the empty fields accourding
11//! to the binoxxo rules.
12//!
13//! ## Board
14//!
15//! You can create a board with the [`Board::FromStr`](field/struct.Board.html).
16//!
17//! ```
18//! use binoxxo::field::{Board, Field};
19//! use std::str::FromStr;
20//! let board = Board::from_str("
21//!     X O X O
22//!     O X O X
23//!     X X O O
24//!     O O X X"
25//! ).unwrap();
26//! ```
27//! It creates a [`Board`](field/struct.Board.html) struct. You can also create `Board`s
28//! manually.
29//!
30//! ## create_puzzle_board
31//!
32//! Use [`create_puzzle_board`](bruteforce/Board::from_str/fn.create_puzzle_board.html) to create a random puzzle:
33//! ```
34//! let size = 10usize;
35//! let guesses = 15usize;
36//! let board = binoxxo::bruteforce::create_puzzle_board(size, guesses);
37//! println!("Board:\n{}", board.to_string());
38//! ```
39//! The `size` is length of one square side in number of fields.
40//! 10 is a common size.
41//!
42//! `guesses` is an tuner for the difficulty of the resulting puzzle.
43//! The larger `guesses` the more complicated the resulting puzzle and
44//! the more empty fields does the board has.
45//!
46//! ## create_full_board
47//!
48//! You can also create a randomly full board without empty fields:
49//! ```
50//! let size = 10usize;
51//! let board = binoxxo::bruteforce::create_full_board(size);
52//! println!("Board:\n{}", board.to_string());
53//! ```
54//!
55//! See the create_board example for how to print the resulting board.
56//!
57//! # Check a board
58//!
59//! You can check a full board with the [`is_valid_board`](bruteforce/rules/fn.is_board_valid.html):
60//! ```
61//! use binoxxo::field::Board;
62//! use binoxxo::rules::is_board_valid;
63//! use std::str::FromStr;
64//! let board = Board::from_str("
65//!     X O X O
66//!     O X O X
67//!     X X O O
68//!     O O X X"
69//! ).unwrap();
70//! println!("Board is valid: {}", is_board_valid(&board));
71//! ```
72//! # Rules
73//!
74//! * there must be no empty fields
75//! * there must be no more than two fields of the same token
76//!   * either X O O X or O X X O
77//!   * but not X O O O or X X X O
78//! * each row and column must contain exactly the same numbers of X and O
79//! * each row and column must be unique
80//!
81//! For more details see:
82//! [https://www.kreuzwortraetsel.ch/techniken-binoxxo/](https://www.kreuzwortraetsel.ch/techniken-binoxxo/)
83//! in German.
84//!
85//! # License
86//!
87//! The crate is published under the [MIT](https://opensource.org/licenses/MIT) license.
88
89pub mod bruteforce;
90pub mod field;
91pub use bruteforce::rules;