1use std::fmt;
2
3pub type Coord = (i32, i32);
5
6pub const HEX_DIRS: [Coord; 6] = [
8 (1, 0),
9 (-1, 0),
10 (0, 1),
11 (0, -1),
12 (1, -1),
13 (-1, 1),
14];
15
16pub const WIN_AXES: [Coord; 3] = [
18 (1, 0),
19 (0, 1),
20 (1, -1),
21];
22
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
25pub enum Player {
26 P1,
27 P2,
28}
29
30impl Player {
31 pub fn opponent(self) -> Self {
33 match self {
34 Player::P1 => Player::P2,
35 Player::P2 => Player::P1,
36 }
37 }
38}
39
40impl fmt::Display for Player {
41 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42 match self {
43 Player::P1 => write!(f, "P1"),
44 Player::P2 => write!(f, "P2"),
45 }
46 }
47}