Text adventure engine
Request
The Lantern Wharf game designer needs a testable engine for dock, garden and tower.
Data
Commands arrive as a string array. All state begins fresh for each solve call.
Deliverable
Return the requested state summary at each step, ending with key-controlled movement and LIFO movement undo. The browser performs no filesystem or network operations.
Lantern Wharf is a fictional browser adventure with three rooms and a small command language. Your engine returns its state instead of printing a transcript, which lets the tests check every command sequence. Begin with movement and add one requirement at a time. The preceding source is the exact starter for the next step, and your own working source carries forward in the player.
Treat unknown commands, blocked movement and an empty undo history as ordinary inputs. They should leave the engine consistent. Visit history records where the traveler has ever been; movement history records positions that can still be undone. Inventory is a third piece of state. Keep those meanings separate so an undo can restore a position without silently restoring a dropped key.
commands = ["east", "take", "east", "undo"]
// Final engine: garden|3|true
Undo changes the current room while the tower remains in historical visits.