hive/engine/moves/
beetle.rs

1use crate::engine::{
2  grid::{coordinate::hex::Hex, Grid},
3  rules::{freedom_to_move_rule, one_hive_rule},
4};
5
6pub fn beetle_moves(grid: &Grid, hex: &Hex) -> Vec<Hex> {
7  let mut moves: Vec<Hex> = Vec::new();
8
9  for neighbor in hex.neighbors() {
10    if one_hive_rule(grid, hex, &neighbor)
11      && ((!grid.is_hex_occupied(hex) && freedom_to_move_rule(grid, hex, &neighbor))
12        || grid.is_hex_occupied(hex))
13    {
14      moves.push(neighbor);
15    }
16  }
17
18  moves
19}