Fix handling of blocked diagonal movement (fixes #86)

I had it mostly right based on experimentation, but had the conditions
inside-out, which allowed this case to slip through the cracks.  This
makes the Settlement of Arrakis replay sync.
This commit is contained in:
Eevee (Evelyn Woods) 2021-12-03 07:16:59 -07:00
parent 4ebe5c1149
commit 77afca5799

View File

@ -1421,40 +1421,28 @@ export class Level extends LevelInterface {
actor.decision = dir1; actor.decision = dir1;
} }
else { else {
// We have two directions. If one of them is our current facing, we prefer that // Resolve two directions.
// one, UNLESS it's blocked AND the other isn't.
// Note that if this is an override, then the forced direction is still used to // Note that if this is an override, then the forced direction is still used to
// interpret our input! // interpret our input!
// FIXME lynx only checks horizontal?
let open1 = try_direction(dir1, push_mode);
let open2 = try_direction(dir2, push_mode);
let current_direction = forced_move ?? actor.direction; let current_direction = forced_move ?? actor.direction;
if (dir1 === current_direction || dir2 === current_direction) { if (open1 && open2 && (dir1 === current_direction || dir2 === current_direction)) {
let other_direction = dir1 === current_direction ? dir2 : dir1; // Both directions are open, but one of them is the way we're already moving, so
let curr_open = try_direction(current_direction, push_mode); // stick with that
let other_open = try_direction(other_direction, push_mode); actor.decision = current_direction;
if (! curr_open && other_open) { open = true;
actor.decision = other_direction; }
open = true; else if (open1 !== open2) {
} // Only one direction is open, so use it.
else { actor.decision = open1 ? dir1 : dir2;
actor.decision = current_direction; open = true;
open = curr_open;
}
} }
else { else {
// Neither direction is the way we're moving, so try both and prefer horizontal // If we got here, both directions are equally (in)accessible, and we have no
// FIXME i'm told cc2 prefers orthogonal actually, but need to check on that // reason to prefer one over the other, so prefer the horizontal.
// FIXME lynx only checks horizontal, what about cc2? it must check both if (dir1 === 'east' || dir1 === 'west') {
// because of the behavior where pushing into a corner always pushes horizontal
let open1 = try_direction(dir1, push_mode);
let open2 = try_direction(dir2, push_mode);
if (open1 && ! open2) {
actor.decision = dir1;
open = true;
}
else if (! open1 && open2) {
actor.decision = dir2;
open = true;
}
else if (dir1 === 'east' || dir1 === 'west') {
actor.decision = dir1; actor.decision = dir1;
open = open1; open = open1;
} }