Live data from Hacker News

So You Think You Can Program an Elevator

github.com

11–20 of 118 posts

Re: So You Think You Can Program an Elevator

#11

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.

That is hilarious. If elevators always malfunctioned like that imagine how many calories some people would burn.

Re: So You Think You Can Program an Elevator

#12
post #10

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.

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/

Re: So You Think You Can Program an Elevator

#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 cases, it quickly degenerates to a mess of ad-hoc heuristics and spaghetti.

Re: So You Think You Can Program an Elevator

#15
A project during my graduate work was to solve this problem. You can read my write up, which includes pseudo-code for the best algorithm I found[1].

Long story short: a simple, rules-based algorithm defeated my best efforts at having multiple elevators working together to coordinate their action.

[1]: https://clarkmoody.com/Moody_AgentBasedElevatorControl.pdf

Re: So You Think You Can Program an Elevator

#16

This is a lot like an assignment for my operating systems class to introduce threads/lock (each elevator and rider is a thread). https://users.cs.duke.edu/~chase/cps310/lab3-elevator.html

Nice! They shoot for automated grading. I wish I had that when I was a TA.
Post reply on HN