scrom / Experiments

a NodeJS text adventure - deliberately coded badly to re-experience the pain of legacy code
http://mvta.herokuapp.com/
2 stars 0 forks source link

Creatures keep getting stuck on the fire escape/roof #400

Closed scrom closed 8 years ago

scrom commented 8 years ago

it turns out the case where a creature has come up the stairs to the top means they won't double-back down and can't use the "climb" exit. This leaves them to wait until the next turn without anything changing.

scrom commented 8 years ago

I'd still like to keep the no climbing without a purpose and no doubling back most of the time so I've added in some "final chance" attempts at taking another exits after the existing logic. First chance is 5 attempts to get another exit that includes the option to double-back but doesn't offer the option to use "exitAction" exits - e.g. climb. Nor "avoid" locations. if that fails (unlikely). The last chance is to use any available exit including double-back, avoids and even exitActions.

scrom commented 8 years ago

after a few attempts it's still not fixed. I think the problem is that paths are calculated in reverse but then once trapped, paths are cleared until there's a viable route - which form the trapped location - working in reverse is also not possible at it points them to the same one way door they came in through.

scrom commented 8 years ago

nope - it wasn't paths being calculated backwards. There was some code in getRandomLocation that caused odd behaviour (afaik).

This was such a knotty issue that I've had to overhaul creatures obtaining exits and wandering (long overdue refactorings at the same time

scrom commented 8 years ago

This problem is now fixed And most of the nasty bugs and regressions since reworking this have been found and fixed. Wandering animals and odd reporting of autoclose doors still need work.