The Steam-Hound of Tamberlic Pass
The Wardens of Tamberlic Pass have built a clockwork hound, fired by a small boiler, to guard the high road. Before they set it loose they want a full reckoning of how it will behave. Given the log of what happens on the pass, report the hound's mood after every event.
Write houndLog(steam, events).
steamis an integer,0or greater: the capacity of the hound's boiler. The hound starts with a full boiler (steamunits left) in the mood"dormant".eventsis a list of strings. Each is exactly one of"glimpse","tick","token","stoke".
Return a list of strings with the same length as events. Entry i is the hound's mood immediately after event i has been applied. The four moods are "dormant", "watching", "hunting" and "spent".
Apply the events in order using these rules. Any combination of mood and event not listed here changes nothing.
glimpse - dormant becomes watching. - watching becomes hunting if the hound has at least 1 unit of steam left. If it has 0 left, it becomes spent instead. - hunting and spent are unchanged.
tick - watching: if this is the third tick received since the hound most recently became watching, it becomes dormant. Otherwise it stays watching. - hunting: steam left decreases by 1. If steam left is now 0, it becomes spent. - dormant and spent are unchanged.
token - If the hound has become hunting three or more times in total since the start of the log, a token has no effect at all. - Otherwise: watching becomes dormant; hunting becomes watching; dormant and spent are unchanged.
stoke - In every mood, steam left is set back to steam. If the hound is spent, it also becomes dormant. Any other mood is unchanged.
Precise counting: - "Become hunting" means a change from watching to hunting. A glimpse while already hunting does not count. This count never resets, not even on a stoke. - The ticks that send a watching hound to sleep are counted only from the moment it most recently became watching (whether from dormant or from hunting). Only tick events count; a stoke while watching neither counts nor resets the count. - Steam left is only ever changed by ticks while hunting and by stokes. It is not refilled when the hound calms down.
examples
- case 1
steam of 2; events glimpse, glimpse, tick, tick, stoke["watching", "hunting", "hunting", "spent", "dormant"] - two ticks of hunting drain the boiler, the stoke wakes it back to dormant - case 2
steam of 0; events glimpse, glimpse["watching", "spent"] - with an empty boiler the hound cannot begin a hunt - case 3
steam of 9; events glimpse, glimpse, token, glimpse, token, glimpse, token["watching", "hunting", "watching", "hunting", "watching", "hunting", "hunting"] - after the third hunt begins, the token no longer works - case 4
steam of 4; events glimpse, tick, tick, glimpse, token, tick, tick, tick["watching", "watching", "watching", "hunting", "watching", "watching", "watching", "dormant"] - the tick count starts over when it returns to watching
- reward
- 540 XP
- signature
houndLog
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- hunt drains boiler then stoke wakes
- three quiet ticks, stoke does not reset count
- token calms hunt and tick count restarts
- empty log
- zero steam boiler
- third hunt burns the token
- glimpse while hunting is not a new hunt
- hunt count survives spent and stoke
- stoke mid-hunt refills
- dormant and spent ignore events
- steam not refilled by calming