HTML5/JavaScript Simulations
⇨ Elevator InAction

Elevator InAction

I've recently developed an interest in the logic of automation - what do algorithms that operate machinery look like? This latest experiment simulates the control unit of an elevator, exploring how a purely event-driven machine handles and prioritises multiple random inputs.

Created in Construct 2 with graphics and music lovingly "borrowed" from the classic Elevator Action, watch on your PC or mobile device as the elevator manages its workload of calls and floor selections in a virtual 10-storey building.

Start Elevator InAction

Elevator InAction development notes

For those with an interest in AI and automation, the source CAPX file is available here and the original design document can be viewed here. A brief explanation of the logic used in Elevator InAction follows...

-- ELEVATOR INACTION --

_________________
Operating logic:

"Call lift" is pressed on a random floor programatically. If that floor is not already in the "floors to call at" list, it is added as follows...

- If lift is going up and call is higher than the next stop, call is added to the back of the list.
- If lift is going up and call is lower than the next stop (but higher than the current floor!), call is added to front of the list.
- If lift is going up and call is lower than the current floor, call is added to the back of the list.
- If lift is going down and call is lower than the next stop, call is added to back of the list.
- If lift is going down and call is higher than the next stop (but lower than the current floor!), call is added to front of the list.
- If lift is going down and call is higher than the current floor, call is added to the back of the list.

Floor selections are also made by passengers who board the lift. These are handled in the same manner as calls.

_________________
However, the sorting is not perfect..!

If the lift is going up and a call or selection is:
- Higher than the next stop
- But not the highest floor on the list
It will be incorrectly added to the back of the queue as it is higher than the next stop, not correctly inserted between the next stop and the highest floor.

Example: List is "4,6" and 5 is requested. 5 will be placed at back of list, as it is higher than 4 (next floor), whereas it should be inserted between 4 and 6.

Vice versa for descent!

_________________
This logic hole is fixed in the following way:

On its way to the next stop, if the lift passes a floor which is in the list, it will stop there and remove that floor from the list.

Example: If the lift has just stopped at 4 and the next floor order is "6,5" due to the sorting issue, the lift will stop at 5 on its way to 6, thereby solving the problem.

On stops such as these, no floor selections are made - this gives the appearance of random passenger behaviour.

_________________
User input

You can call the lift yourself on a PC, by pressing keys 1-9 for floors 1-9 and 0 for floor 10.


tldr; Elevator InAction is a variation on a FIFO queue.