magwo / elevatorsaga

The elevator programming game!

Home Page:http://play.elevatorsaga.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Elevator moves while passengers enter the elevator

adisib opened this issue · comments

An elevator can immediately leave a floor while picking up passengers, causing the passengers to fly into the elevator.

Video demonstration (occurs around 20s):
https://youtu.be/CwGfmZQaLBw

The console output is the current elevator queue when "stopped_at_floor" is fired.

Here I immediately queue up/down presses to summon the elevator, as well as elevator floor number presses to send people out. The queue then organizes itself as they are added, making sure not to add duplicates.

However, in the video demonstration, floor 0 gets added, either before the person at floor 2 presses the button to queue floor 0 when they aren't even in the elevator yet, or by the person who just entered the elevator and shouldn't be pressing the down button to summon it. The elevator then immediately moves away to the next floor in the queue after arriving, resulting in the person flying into it to enter.

I'm not sure what is causing the root problem and do not have a minimal working example yet.
However, the code used in the video demonstration can be found here:
http://pastebin.com/Qwebn09L

Firefox 48.0