From 70658f1d0dd021b7a98dc82559e073cb717c9246 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 26 Dec 2022 01:13:58 +0100 Subject: Forbid entering own map edge hexes. --- rules.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rules.js b/rules.js index 7e5fc7a..4e78cd5 100644 --- a/rules.js +++ b/rules.js @@ -1622,15 +1622,19 @@ function search_redeploy(start) { // Breadth First Search function search_path_bfs(from, cost, start, road, max_cost, retreat, sline, sdist) { let path_enemy, enemy_sides + let exit1, exit2 if (presence_invalid) update_presence() if (is_axis_player()) { path_enemy = presence_allied enemy_sides = game.allied_sides + exit1 = exit2 = 175 } else { path_enemy = presence_axis enemy_sides = game.axis_sides + exit1 = 99 + exit2 = 148 } from.fill(0) @@ -1655,6 +1659,10 @@ function search_path_bfs(from, cost, start, road, max_cost, retreat, sline, sdis if (next < first_hex || next > last_hex || !hex_exists[next]) continue + // can't enter own map edge + if (next === exit1 || next === exit2) + continue + // already seen if (cost[next] < 15) continue @@ -1718,6 +1726,7 @@ function search_path_bfs(from, cost, start, road, max_cost, retreat, sline, sdis function search_path_redeploy_bfs(cost, start, road) { let path_enemy, friendly_network, enemy_network, enemy_sides + let exit1, exit2 if (presence_invalid) update_presence() @@ -1726,11 +1735,14 @@ function search_path_redeploy_bfs(cost, start, road) { friendly_network = game.buildup.axis_network enemy_network = game.buildup.allied_network enemy_sides = game.allied_sides + exit1 = exit2 = 175 } else { path_enemy = presence_axis friendly_network = game.buildup.allied_network enemy_network = game.buildup.axis_network enemy_sides = game.axis_sides + exit1 = 99 + exit2 = 148 } cost.fill(63) @@ -1754,6 +1766,10 @@ function search_path_redeploy_bfs(cost, start, road) { if (next < first_hex || next > last_hex || !hex_exists[next]) continue + // can't enter own map edge + if (next === exit1 || next === exit2) + continue + // already seen if (cost[next] < 63) continue -- cgit v1.2.3