Live data from Hacker News

So You Think You Can Program an Elevator

github.com

51–60 of 118 posts

Re: So You Think You Can Program an Elevator

#51

This is both cool and disappointing. I'm sure this is more challenging than it looks, and it's cool to see emergent complexity from a (seemingly) simply set of conditions to satisfy. However, the reason I think about elevator programming isn't to make an elevator behave the way they do today. It's to make an elevator behave better than they do today. For example: * I don't want an elevator to close and reopen its doo…

Totally agree. That's basically the challenge that I wanted to make, but I found that I bit off more than I could chew.

Re: So You Think You Can Program an Elevator

#52
post #8
post #2

Then there is the alternative system where you do not request UP or DOWN but you request the floor, otherwise known as destination dispatch https://en.wikipedia.org/wiki/Destination_dispatch which introduces a whole new set of complexity.

I think I read once that when elevators still had operators, larger buildings would have one or more dispatch agents in the lobby that would line people up at the appropriate elevator for the range of floors they intended to visit.

I used to work in a 50-story building that had banks of elevators, each of which was hard-coded to only visit the lobby and the appropriate range of floors. For example, the first bank would only visit 2-13, the 2nd bank would visit 14-25, etc. The elevator cars only had buttons inside for the floors they were allowed to visit. There were also a couple service/freight elevators that could visit all floors (including a couple of service/equipment floors that weren't reachable at all by the normal elevators), and had a human operator/guard who logged badge numbers, floors, and property-removal authorization forms.

I think this sort of elevator allocation is fairly common for tall buildings, because it's horribly inefficient for people going to the 44th floor to have to wait while people get on and off at all of the 42 floors in between!

Re: So You Think You Can Program an Elevator

#53

This is both cool and disappointing. I'm sure this is more challenging than it looks, and it's cool to see emergent complexity from a (seemingly) simply set of conditions to satisfy. However, the reason I think about elevator programming isn't to make an elevator behave the way they do today. It's to make an elevator behave better than they do today. For example: * I don't want an elevator to close and reopen its doo…

Elevators enable skyscrapers. As you build taller skyscrapers, more and more of the floor space is given over to elevators. There must be a huge incentive to improve elevator routing. I'd love to peek behind that curtain.

Re: So You Think You Can Program an Elevator

#54
post #14

This was was posed as the the first homework assignment in my first undergrad CS class (15 years ago). I don't think a single person managed to do it. It's a classic example of a problem that you think is appropriate to throw at new programmers but find out it goes terribly wrong because the hard part is designing a suitable state machine first. If you just start coding without a full model that covers all the edge c…

Don't go for a FSM.

GKRuleSystem[0] to the rescue!

Or any other Fuzzy Logic(?) framework.

Or maybe a behaviour tree, which is how I would have (tried) to design it with.

I hope I get something like this on an interview, instead of "reverse binary tree" like questions. This actually seems like a fun problem to solve. Knowing my defect brain, it would put a lot of effort into this because it's kinda fun. Also because I already have a ton of ideas on how to implement this - not that I already have.

Just off the top of my head. A BT that tracks current floor, direction, some predicates for inputs e.g ignore input 2 if direction is up and current floor is 3.

That would satisfy the current test conditions. HOWEVER.. a better style would be to keep that in queue with an indicator (UI) that it's on the queue after current direction has hit its highest floor. Could add another predicate that the elevator won't stop for 'caller' on third floor if it's filled (maxWeightReached) and everyone are going to bottom floor.

Eventually you could maximise the amount of people it moves based on space available and how many have called the elevator using their condo NFC tags.

Seriously, this what dev interviews should look like.

0: https://developer.apple.com/library/ios/documentation/Gamepl...

Re: So You Think You Can Program an Elevator

#55

Very similar immediately playable JavaScript version. http://play.elevatorsaga.com/ Which I'm now closing as I lost too much time to this the first time I saw it.

This is fantastic. Are there other good programming challenge / games like this? I'd love to see a collection of other similar games.

Re: So You Think You Can Program an Elevator

#56
post #36

On the topic of elevators, opening this link will cause you to (happily) lose an hour of productivity: https://m.youtube.com/watch?v=1Uh_N1O3E4E

thx.

An elevator once dropped me one and a half floors with open doors (both, floor station and cabin doors). I think the cable slipped over the transport wheel. Felt funny in the stomach, but we all kept standing when we hit the end-stop in the pit. "safest way of travel" huh!

Re: So You Think You Can Program an Elevator

#57

Very similar immediately playable JavaScript version. http://play.elevatorsaga.com/ Which I'm now closing as I lost too much time to this the first time I saw it.

This is fantastic. Are there other good programming challenge / games like this? I'd love to see a collection of other similar games.

https://codecombat.com/ maybe?

http://www.codeandconquer.co/ is vaporware at this stage.

https://www.battlecode.org/ is also great fun each year. Not sure if it continues running after the competition is over.

http://aichallenge.org/ hasn't run either for awhile unfortunately.

Re: So You Think You Can Program an Elevator

#60
post #8

Earlier quoted context omitted.

I think I read once that when elevators still had operators, larger buildings would have one or more dispatch agents in the lobby that would line people up at the appropriate elevator for the range of floors they intended to visit.

Taller buildings with complex and highly trafficked elevators still do this only using electronics. Employees swipe their badges at a podium which reads what floor they work on and indicates which elevator they should proceed to. The system can intelligently schedule the elevator for that person to use knowing where their destination is.

I'm in a building with a mere nine floors that has such a system (the only buttons in the elevators themselves are door open, door close and alarm). I imagine that the technology will increasingly appear in the smaller buildings as their elevators are built or refurbished.
Post reply on HN