summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-01-04 01:03:28 +0100
committerTor Andersson <tor@ccxvii.net>2024-01-04 01:05:42 +0100
commit06abc605b0e1e32585ec72e410dae5bc2e407d73 (patch)
tree5978e6d9e1f2e951163d0ad8fcb43ce7b991affd /rules.js
parentfb54e6b4b0df7b90ffd68124400fefda0af89d09 (diff)
downloadrommel-in-the-desert-06abc605b0e1e32585ec72e410dae5bc2e407d73.tar.gz
More optimizations.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js31
1 files changed, 26 insertions, 5 deletions
diff --git a/rules.js b/rules.js
index 88a977f..119022c 100644
--- a/rules.js
+++ b/rules.js
@@ -25,7 +25,7 @@ var game = null
var view = null
const {
- all_hexes, hex_exists, hex_road, side_road, side_limit, hex_name, regions,
+ all_hexes, hex_exists, hex_all_road, hex_road, side_road, side_limit, hex_name, regions,
unit_name, unit_appearance, unit_elite, unit_class, unit_speed, unit_max_steps,
} = require("./data.js")
@@ -1363,12 +1363,33 @@ function trace_unit_supply_line(path, here, here_move, ssrc) {
let reached = (next === ssrc)
if (!reached) {
- // Stop searching if we reach a supplied highway,
- // but only if we can't continue by trail or track.
- // Example: Tobruk - EL Adem - Sidi Rezegh - Ft. Capuzzo
- if (hex_road[next] === HIGHWAY && supply_net[next] === 2)
+ // Sometimes we can stop searching if we reach a supplied highway.
+ if (hex_road[next] === HIGHWAY && supply_net[next] === 2) {
+
+ // But only if we can't continue by trail or track.
+ // If we always stop we'll miss possible departures that reconnect
+ // to the highway elsewhere.
+ //
+ // Example: Tobruk - EL Adem - Sidi Rezegh - Ft. Capuzzo
+
+ // Not enough movement left to leave highway:
if (next_move === BACK_HIGHWAY_3 || next_move === BACK_STOP)
reached = true
+
+ // MAYBE WRONG
+ // (can we leave supplied highway to connect to chain elsewhere?)
+ // Only these places can reconnect to the highway using trail/track:
+ if (
+ next !== 35 && // Gazala
+ next !== 55 && // Er Regima
+ next !== 61 && // Bir Harmat
+ next !== 62 && // El Adem
+ next !== 64 && // Ft. Capuzzo
+ next !== 65 && // Sollum
+ next !== 78 // Ghemines
+ )
+ reached = true
+ }
}
// reached supply source