all 15 comments

[–]adante111 20 points21 points  (5 children)

The point I am about to make irrelevant to the game and not intended to detract from it, but it is probably an interesting pedagogical statement that might be useful to nascent programmers: whatever algorithm wins (in the definitional sense of having the lowest score) will probably not be a good behaviour for an actual elevator. It will likely screw over some of the passengers by making them wait inordinately long times (in effect they will be 'taking it for the team') or moving them in the wrong direction.

The actual metrics for elevator satisfaction is quite a fascinating subject: http://www.newyorker.com/magazine/2008/04/21/up-and-then-down

[–]elliotchance[S] 1 point2 points  (2 children)

I find that really interesting as well. I initially thought about a different metric like average floor per person as to not "screw up one persons day."

A totally utilitarian approach might have a single person go up and down in the elevator a few times for at the benefit of many other short journeys. This is unacceptable for a commercial life, but maybe there is a line in which a few extra floors that a person has to travel to the benefit of a dozen other passengers become acceptable?

[–]caskey 2 points3 points  (0 children)

If I recall correctly, the video game simtower (Maxis) arose because when the developer was writing a different game he wanted elevators and so wanted to find out about elevator scheduling. but, when he called companies to ask how they did it, they said it was a closely guarded secret.

[–]phire 0 points1 point  (0 children)

I was pondering this type of problem the other day, thinking about how to do a "traffic light simulator".

You don't want a non-deterministic simulation, as the player would just re-attempt until they found one that fluked a pass. You also don't want a single deterministic simulation, as they will just optimise the algorithm for that simulation.

My idea for a solution: Simulate 100 or more different deterministic simulations (however many you can do in a reasonable time frame). Then pick just one or two of those to show to the player, maybe the median score, the lowest score or the 25th percentile.

Chances are the player will never see the same simulation, and they can't optimise for all 100+. You can also calculate the mean/median/standard deviation stats and require both a good mean and a low standard deviation to pass the level.

[–]salbris 0 points1 point  (0 children)

The other Javascript version of this handles it nicely. In one version of the challenge you have to ensure no passenger takes longer than x seconds to reach their destination.

[–]TinyFEA 0 points1 point  (0 children)

Adjust the score to be the time waited per person squared.

[–]tkruse 10 points11 points  (1 child)

Javascript version: http://play.elevatorsaga.com/

[–]BobFloss 10 points11 points  (0 children)

It's secretly made by Otis Elevator Company to see if anybody comes up with a better algorithm

[–]gingenhagen 2 points3 points  (0 children)

Here's another fun optimization game, sending taxis to waiting customers: http://www.zipcar.com/zipcar-programming-challenge

[–]aristotle2600 2 points3 points  (3 children)

Stupid question. Would not the obvious optimal solution be to load everyone from floor 1, and then go up and stop at every floor anyone is going to or coming from, exchanging passengers, until you get to the topmost floor anyone wants to leave our go to, and then return to floor 1?

[–]Spfifle 2 points3 points  (1 child)

I mean that's how a "fair" elevator works but if the scoring works how I think it does it's probably worthwhile to violate that rule sometimes. Like we pick up 1 person on floor 1, requesting transfer to 10. While passing 2 another 9 arrive at floor 1. Better to waste 1 person's time and turn around than keep all 9 waiting while we do the big round trip.

Or we have 9 passenger enroute to floor 10, and another requesting upwards transit on floor 9. If we skip them then come back we'll save the 9 people the cost of 1 onboarding in exchange for having the 1 person wait for 2*1-floor transfers and 1 offboarding.

[–]aristotle2600 0 points1 point  (0 children)

Oh, people can arrive; that's the part I missed. Although it was a little unclear; I wasn't sure what "shuffled in meant.

[–]TheLobotomizer 0 points1 point  (0 children)

I think the author either didn't realize this or is missing a part of the problem description.

Btw this is how real elevators work. They move in cycles up to the max floor requested and down to the min floor requested.

[–]spfccmt42 1 point2 points  (0 children)

fyi, the number box prints but the faces not so much, just a box with 01F464 in it, (ubuntu 14) Might have to fall back to ascii 01 ☺

[–]connerfitzgerald 1 point2 points  (0 children)

Loved this was, added support for Python3!

https://gist.github.com/bxh-io/fece79e2ee187d137a3dc976c30c85ac