Halo

mail@pastecode.io avatar
unknown
rust
2 years ago
1.3 kB
3
Indexable
Never
    const X: bool = true;
    const O: bool = false;
    fn example_ok_board() -> Board {
        return Board::new([
            [X, X, X, X, O, O, O, O, X, O],
            [O, O, O, O, O, O, X, O, O, O],
            [O, O, O, X, X, O, O, O, O, O],
            [O, O, O, O, O, O, O, O, O, O],
            [O, X, O, X, O, O, O, O, O, O],
            [O, O, O, X, O, O, O, O, O, O],
            [O, O, O, X, O, O, O, O, O, O],
            [O, O, O, O, O, O, O, O, X, X],
            [O, X, X, X, O, O, O, O, O, O],
            [O, O, O, O, O, X, O, O, X, X],
        ]);
    }

    fn example_ok_commitable_board() -> CommitableBoard {
        return CommitableBoard::from_board(&example_ok_board(), &mut rand::thread_rng()).unwrap();
    }

    #[test]

    fn correct_baord_pass_all_verifications() {
        let board = example_ok_commitable_board();
        let mut salt = Salter::new(&mut rand::thread_rng());
        let commitment = salt.create_commitment(&board);

        let H: HashSet<(Coordinate, Coordinate)> = board
            .shuffled_cells
            .iter()
            .map(|cell| cell.position.unwrap())
            .collect();

        print!(
            "rozmiar boarda {}/{:?}\n",
            H.len(),
            board.shuffled_cells.len()
        );
    }
}