summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-01-17 01:37:32 +0100
committerTor Andersson <tor@ccxvii.net>2024-01-18 15:40:35 +0100
commit947cb4236b76468341f3e476b6a345945afd38f9 (patch)
tree483c9c5a1892a65cf88411d2ddd6cf23f4433b3c
parent6f7629ddffbad3affd36c348904874b468b11b55 (diff)
downloadrommel-in-the-desert-947cb4236b76468341f3e476b6a345945afd38f9.tar.gz
Use direction in memo key.
-rw-r--r--rules.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/rules.js b/rules.js
index 226850f..1c64aac 100644
--- a/rules.js
+++ b/rules.js
@@ -1142,7 +1142,7 @@ function shuffle_cards() {
var supply_friendly_hexes, supply_friendly_sides, supply_friendly, supply_enemy, supply_net, supply_line
var supply_visited = new Array(hexcount).fill(0)
-var supply_memo = new Array(hexcount * 8).fill(0)
+var supply_memo = new Array(hexcount * 8 * 6).fill(0)
// PASS 1: Forward scan from source to compute potential supply net and valid hex side crossings.
// Simple uniform cost search.
@@ -1333,8 +1333,8 @@ function backward_supply_next_move_type(here_move, road) {
return BACK_ABORT
}
-function trace_unit_supply_line(path, here, here_move, ssrc) {
- let memo_idx = (here << 3) + here_move
+function trace_unit_supply_line(path, here, here_move, ssrc, from_dir) {
+ let memo_idx = here * 48 + here_move * 6 + from_dir
if (supply_memo[memo_idx]) {
for (let x of path)
supply_line[x] = 2
@@ -1419,7 +1419,7 @@ function trace_unit_supply_line(path, here, here_move, ssrc) {
next_move = BACK_HIGHWAY_3
path.push(side)
- if (trace_unit_supply_line(path, next, next_move, ssrc))
+ if (trace_unit_supply_line(path, next, next_move, ssrc, s))
supplied = true
path.pop()
}
@@ -1478,7 +1478,7 @@ function trace_supply_network(start) {
let path = []
for (let x of search_order) {
if (supply_friendly[x] > 0 && x !== start) {
- trace_unit_supply_line(path, x, BACK_HEAD, start)
+ trace_unit_supply_line(path, x, BACK_HEAD, start, 0)
}
}
@@ -1507,7 +1507,7 @@ function trace_fortress_network(fortress, ss) {
let x = unit_hex(u)
if (is_map_hex(x) && x !== fortress) {
//if (supply_friendly[x] > 1 && supply_net[x]) continue
- trace_unit_supply_line(path, x, BACK_HEAD, fortress)
+ trace_unit_supply_line(path, x, BACK_HEAD, fortress, 0)
}
}
}