What should happen if you’re on the tenth floor of a building and push the button to call an elevator? Obviously, the elevator should come to you. But what if it’s going up at the 11th floor at the moment, as someone told it to take them to the 15th floor? Well, do that first, then get to the tenth floor. But what if, meanwhile, someone calls it to the 14th floor, wanting to go down? Maybe pass that floor when going up, but stop there on the way down to the tenth floor. But what if you, on the tenth floor, want to get to the 16th floor? Maybe pass the person waiting the 14th floor after all. And what if there are multiple elevators in the lobby, which one should be dispatched and where?

Since I wrote the post about Robot Battle, I’ve been looking more into the programming game genre. I found this little gem called Elevator Saga, where you need to program elevators in increasingly complex buildings. It nicely makes you question the simple assumption that an elevator should “just” come to you when you call it.

Programming an elevator is a classic exercise in computer science, but Elevator Saga abstracts away all the scary stuff like threads, deadlocks, and mutexes, instead offering a simple but powerful enough Javascript API (e.g. elevator.goToFloor(3);). You also don’t compete against anyone else in this one, so it’s peaceful enough. It’s weirdly satisfying. Give it a go if you’ve ever wanted to micromanage a box on a pulley. You can’t do much worse than the Sirius Cybernetics Corporation:

Modern elevators are strange and complex entities. The ancient electric winch and “maximum-capacity-eight-persons” jobs bear as much relation to a Sirius Cybernetics Corporation Happy Vertical People Transporter as a packet of mixed nuts does to the entire west wing of the Sirian State Mental Hospital.

This is because they operate on the curious principle of “defocused temporal perception.” In other words they have the capacity to see dimly into the immediate future, which enables the elevator to be on the right floor to pick you up even before you knew you wanted it, thus eliminating all the tedious chatting, relaxing and making friends that people were previously forced to do while waiting for elevators.

Not unnaturally, many elevators imbued with intelligence and precognition became terribly frustrated with the mindless business of going up and down, up and down, experimented briefly with the notion of going sideways, as a sort of existential protest, demanded participation in the decision-making process and finally took to squatting in basements sulking.

An impoverished hitchhiker visiting any planets in the Sirius star system these days can pick up easy money working as a counselor for neurotic elevators.

–Douglas Adams, The Restaurant at the End of the Universe

And finally, here’s a screenshot of the game: