2 ms·
// Whenever the elevator is idle (has no more queued destinations) ... I don't get it. The first challenge is to fix the fact that the idle loop never sends th
by anigbrowl 4y ago
// Whenever the elevator is idle (has no more queued destinations) ...
I don't get it. The first challenge is to fix the fact that the idle loop never sends the elevator to floor 2, fair enough.
But generally when I run the simulation a person appears and calls the elevator on floor 2, plus people get into the elevator on floor 0 and don't get out on floor 1 (presumably because they dream of going to floor 2). So how are their inputs not queued?
This might work better as an IDE that had a watch variable window showing the queue. As it is I feel I'm experiencing a simulation of badly documented code rather than a badly programmed elevator.
- TylerE 4y agoNothing in the starter template queues anything. You have to wire that up.
- anigbrowl 4y agoThe quoted comment is taken directly from the starter template. Hence my comment about 'badly documented code'.
- throwaway4aday 4y agoThe api documentation https://play.elevatorsaga.com/documentation.html https://play.elevatorsaga.com/documentation.html is correct, you just need to think about the problem rather than expect step by step handholding.
- shagie 4y agoA person waiting for the elevator doesn't put anything into the queue. The loop for challenge 1 is: q: [] idle -> enqueue 0, 1, 2 --- q: [0, 1, 2] go to floor 0; (noop@floor0)q: [1, 2] go to floor 1; q: [2] go to floor 2; q: [] idle -> enqueue 0, 1, 2 --- q: [0, 1, 2] go to floor 0; q: [1, 2] ... It doesn't matter if anyone wants to go to that floor who is in the elevator or wants to get on the elevator at that floor. https://play.elevatorsaga.com/documentation.html https://play.elevatorsaga.com/documentation.html And then you get into the events... something like this would likely be interesting/chaotic. elevator.on("floor_button_pressed", function(floorNum) { elevator.goToFloor(floorNum, true); })
- anigbrowl 4y agoI'm not having difficulty understanding the coding problem. I'm talking about how the comments would actually be misleading to a person who was.