diff --git a/battlesnake/src/logic.rs b/battlesnake/src/logic.rs index 4eacf17..bba154c 100644 --- a/battlesnake/src/logic.rs +++ b/battlesnake/src/logic.rs @@ -109,6 +109,7 @@ pub fn get_move(game: &Game, turn: i32, board: &Board, you: &Battlesnake) -> Opt turn, game.ruleset.settings.food_spawn_chance, game.ruleset.settings.minimum_food, + game.ruleset.name == "constrictor", ); let possible_actions = board.possible_actions().get(&game_info.my_token).cloned()?; if possible_actions.len() == 1 { diff --git a/battlesnake/src/simulation.rs b/battlesnake/src/simulation.rs index 9daceb3..22eae29 100644 --- a/battlesnake/src/simulation.rs +++ b/battlesnake/src/simulation.rs @@ -46,6 +46,9 @@ pub struct Board { min_food: u8, /// Alive snakes snakes: BTreeMap, + /// True when playing constrictor mode. In this mode the snakes don't loose health and grow + /// every turn + constrictor: bool, } impl Board { @@ -55,6 +58,7 @@ impl Board { turn: i32, food_chance: u8, min_food: u8, + constrictor: bool, ) -> Self { let width = board.width; debug_assert!(width > 0); @@ -78,6 +82,7 @@ impl Board { food_chance, min_food, snakes, + constrictor, } } @@ -107,7 +112,7 @@ impl Board { // feed snakes for snake in &mut self.snakes.values_mut() { let head = snake.head(); - if self.food.remove(head) { + if self.constrictor || self.food.remove(head) { snake.health = MAX_HEALTH; } }