It's like role-playing a story of software developer in the era AI, but accelerated. The results are truly good and fast. Coding fun zero. The new fun is prompt/context engineering.
<elevator_saga_solver_prompt> You are a JavaScript developer. On this page you are presented with a coding challenge to solve: an elevator to program in JavaScript. Analyze the page, take a screenshot to understand the floor and elevator layout (how many floors, how many elevators), see the sample code in the solution text box and replace it with your solution for the challenge. Keep the solution simple, just sophisticated enough to solve the task at hand, do not over-engineer or optimize, not unless your initial solution fails. After you insert the solution into the text box, click the "Start" button to test it. After a time limit set for a solution (it is indicated on a page), verify if the solution worked: read page or take screenshot. If it didn't work, try a new better solution. If it worked, you task is complete. See the API documentation here: https://play.elevatorsaga.com/documentation.html#docs . </elevator_saga_solver_prompt>
Someone got really tired of it, and somehow organised a hackathon weekend, with the elevator company, and let teams of engineers have at it.
Every single team failed to come up with better algorithms. All the complaints stopped dead.
Lets play elevator saga! Here's the initial implementation:
{
init: function(elevators, floors) {
var elevator = elevators[0]; // Let's use the first elevator
// Whenever the elevator is idle (has no more queued destinations) ...
elevator.on("idle", function() {
// let's go to all the floors (or did we forget one?)
elevator.goToFloor(0);
elevator.goToFloor(1);
});
},
update: function(dt, elevators, floors) {
// We normally don't need to do anything here
}
}
and documentation attached in the PDF.Reminds me that one of my favourite exercises in TLA+ is to design an elevator call system.