diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-05-01 18:32:11 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-05-01 18:43:40 +0200 |
commit | 708b21aea1d82ff88c4fd857badbe742837c28ec (patch) | |
tree | f4c07f7193fb409befa6309523a2502f087fc05c /tools/engage.js | |
parent | 687e35cda69c6db8454ad4860cdc9e1df7b39d75 (diff) | |
download | plantagenet-708b21aea1d82ff88c4fd857badbe742837c28ec.tar.gz |
ravine
Diffstat (limited to 'tools/engage.js')
-rw-r--r-- | tools/engage.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tools/engage.js b/tools/engage.js index 5b5ed90..4441fa8 100644 --- a/tools/engage.js +++ b/tools/engage.js @@ -120,12 +120,21 @@ function make_engagement(array, choice) { const ENGAGEMENTS = [] const CHOICE = [] -function run(bits, array) { +function pack_battle_array(filled) { + let bits = 0 + for (let p = 0; p < 6; ++p) + if (filled[p]) + bits |= (1 << p) + return bits +} + +function run(array) { console.log("<tr>") console.log("<td>") show_array(array) console.log("<td>") let eng = make_engagement(array, 0) + let bits = pack_battle_array(array) ENGAGEMENTS[bits] = eng if (!eng) { let eng_a = make_engagement(array, 1) @@ -138,7 +147,7 @@ function run(bits, array) { function runall() { for (let x = 0; x < 64; ++x) { if ((x & 7) && (x & 56)) - run(x, [ (x>>5)&1, (x>>4)&1, (x>>3)&1, (x>>2)&1, (x>>1)&1, (x>>0)&1 ]) + run([ (x>>5)&1, (x>>4)&1, (x>>3)&1, (x>>2)&1, (x>>1)&1, (x>>0)&1 ]) } } |