Live data from Hacker News

So You Think You Can Program an Elevator

github.com

101–110 of 118 posts

Re: So You Think You Can Program an Elevator

#101
post #89

Earlier quoted context omitted.

Not sure why I am being downvoted here. A FSM would make things very hard to read compared to a BT. The fact that you would have to use a stack to pop events shows that it might not be the best suited use.

There is nothing that dictates that you use a stack when designing a FSM. I'm not going to argue that a BT wouldn't be a good solution, I'm sure it can be used to make a reasonable one. In any case, a well designed FSM would get you a long way. Since the input (pressed buttons) is finite, you can cover every single case and weight according to importance of floor and wait time.

I was actually promoting a stack as that would make things easier, but it's still tacked on a solution that isn't as good.

A well designed FSM doesn't necessarily mean an easily read FSM.

I always try to draw states and transitions on paper, and I end up making a mess. That could be a flaw on my side. But I won't be making the same mess with BT.

I don't see how a FSM could avoid having transitions back and forth.

  * Elevator is on level 3
  * A person in the elevator wants to go to level 4
  * A person waiting for down on level 5
  * A person in the elevator wants to go to level 2
  * A person waiting for down on level 2
FSM would need to track current floor and direction. Would need guards/predicates on transitions for inputs Could just be me, but I wouldn't be able to draw a pretty picture with those.

Re: So You Think You Can Program an Elevator

#103
post #10

Earlier quoted context omitted.

Oh no. My work day has been seriously threatened.

Which is why I closed it once I'd copied the link, it's very very addictive. I think it's the programmer equivalent of https://xkcd.com/356/

Nice link! The problem has been solved, by the way: http://physics.stackexchange.com/questions/2072/on-this-infi...

Re: So You Think You Can Program an Elevator

#104
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…

It's a cool programming problem to work on over a few courses. For example at the start when learning basic programming you just code a functional elevator (ie. a user presses a button, the elevator goes there, picks them up and delivers them).

Then you get to add more people, queuing of commands etc (helping you discover some different algorithms and data structures).

Then you can throw in some advanced predictive code and machine learning, taking into consideration usage vs time, locations people most travel to/from etc.

Re: So You Think You Can Program an Elevator

#105

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.

Well I can report just straight random is only good enough for the first level.

Re: So You Think You Can Program an Elevator

#106
Nice. To the author, is there anyway to change the simulation to try programming 2 elevators in the same shaft ( http://www.thyssenkruppelevator.co.uk/new-installation/eleva... ) or Double-decker elevators ( https://en.wikipedia.org/wiki/Double-deck_elevator )?

Because, you know, I really have no work I need to accomplish this year...

Re: So You Think You Can Program an Elevator

#107

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…

Elevator simulation is used often as a case study for petri nets. There is quite a bit of PN material using elevators.

Eg https://www.youtube.com/watch?v=59jW9dngt_c

PNs are a great way of modelling the concurrent state handling required for something like this.

Re: So You Think You Can Program an Elevator

#108

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.

"Human Resources Machine" from Tomorrow Corporation (it's a proper indie game, you can find it on Steam).

It abstracts simple programming concepts (like loops, branches, etc) in a visual language.

Re: So You Think You Can Program an Elevator

#109

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…

i get angry at my building's elevators every damn day. They should park themselves at the ground floor before 10:30am and above ground after. I get to th building before 7am and there are times when 6 of us are waiting on one of 4 elevators for at least two minutes. It's inexplicable. They should be there waiting and ready. Ain't no on 11-21 trying to go DOWN before 7. So yes I think I could program an elevator. And…

Either your building has old/cheap/shitty elevators or they are misconfigured. This is already standard feature in our elevators.

Re: So You Think You Can Program an Elevator

#110

Earlier quoted context omitted.

i get angry at my building's elevators every damn day. They should park themselves at the ground floor before 10:30am and above ground after. I get to th building before 7am and there are times when 6 of us are waiting on one of 4 elevators for at least two minutes. It's inexplicable. They should be there waiting and ready. Ain't no on 11-21 trying to go DOWN before 7. So yes I think I could program an elevator. And…

Either your building has old/cheap/shitty elevators or they are misconfigured. This is already standard feature in our elevators.

My building is from 1983. I would wager five bucks that more than half of office tower elevators are old/cheap/shitty/misconfigured.
Post reply on HN