summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-07-30 18:09:56 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-17 13:11:26 +0100
commitc3eaccd47742a41f79aa2aa05cee31c4b9848640 (patch)
tree6ea0253d6e9203ddea6d02e27cc17a052e419acb
parentb07c41babd3590ac3fdd95023ec53d8bd3c03a2e (diff)
downloadrommel-in-the-desert-c3eaccd47742a41f79aa2aa05cee31c4b9848640.tar.gz
restore ind debugging
-rw-r--r--rules.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/rules.js b/rules.js
index ebc9d88..e74e74c 100644
--- a/rules.js
+++ b/rules.js
@@ -1073,6 +1073,10 @@ function shuffle_cards() {
// === SUPPLY NETWORK ===
+function ind(d, msg, here, ...extra) {
+ //console.log(new Array(d).fill("-").join("") + msg, here, "("+hex_name[here]+")", extra.join(" "))
+}
+
var supply_defender, supply_defender_sides, supply_friendly, supply_enemy, supply_net, supply_line
var supply_visited = new Array(hexcount).fill(0)
var supply_src = new Array(hexcount).fill(0)
@@ -1108,9 +1112,11 @@ function is_supply_line_blocked(here, next, side) {
function trace_supply_highway(here, d) {
trace_total++
+ ind(d, "> highway", here)
// TODO: hoist to call sites to avoid function call overhead
if (supply_src[here]) {
+ ind(d, "! source highway", here)
return true
}
@@ -1134,12 +1140,15 @@ function trace_supply_highway(here, d) {
let road = side_road[side]
if (road === HIGHWAY) {
if (supply_friendly[next] > 1) {
+ ind(d, "? highway head", next)
if (trace_supply_chain(next, d+1, 0, 3)) {
+ ind(d, "< highway chain", here, next)
supply_line[side] = 1
has_supply = true
}
} else {
if (trace_supply_highway(next, d+1)) {
+ ind(d, "< highway", here, next)
supply_line[side] = 1
has_supply = true
}
@@ -1160,8 +1169,10 @@ function trace_supply_highway(here, d) {
function trace_supply_chain(here, d, n, range) {
trace_total++
+ ind(d, "> chain", here, n, range)
if (supply_src[here]) {
+ ind(d, "! source chain", here)
return true
}
@@ -1184,13 +1195,17 @@ function trace_supply_chain(here, d, n, range) {
let road = side_road[side]
if (road === HIGHWAY) {
+ ind(d, "? chain highway", next)
if (supply_friendly[next] > 1) {
+ ind(d, "? chain highway head", next)
if (trace_supply_chain(next, d+1, 0, 3)) {
+ ind(d, "< highway chain", here, next)
supply_line[side] = 1
has_supply = true
}
} else {
if (trace_supply_highway(next, d+1)) {
+ ind(d, "< chain highway", here, next)
supply_line[side] = 1
has_supply = true
}
@@ -1199,12 +1214,15 @@ function trace_supply_chain(here, d, n, range) {
let next_range = min(range, SUPPLY_RANGE[road])
if (n + 1 <= next_range) {
if (supply_friendly[next] > 1) {
+ ind(d, "? chain head", next)
if (trace_supply_chain(next, d+1, 0, 3)) {
+ ind(d, "< highway chain", here, next)
supply_line[side] = 1
has_supply = true
}
} else {
if (trace_supply_chain(next, d+1, n+1, next_range)) {
+ ind(d, "< chain trail", here, next_range)
supply_line[side] = 1
has_supply = true
}