13 ms·
Elevator Saga – An elevator programming game
- asiachick 5y agoI don't remember the article but I remember reading about a building management game where the reviewer believed the entire game was based around the elevator management code and that writing that code was fun for the programmer but the game itself was not fun for the player. It looks like this highlights the "fun for the programmer" part.
- aidenn0 5y agoMaybe Sim Tower? The game was pretty boring, but building and managing elevators to keep people happy was a fun challenge.
- noduerme 5y agoSim Tower and Sim Ant were both great network-building games. They seemed boring until you really delved into the details. Maxis was really genius up until EA bought them. Here's a pretty cool project they did that never came to light... https://www.gamesradar.com/simrefinery-the-lost-oil-plant-game-from-maxis-is-now-playable-in-your-browser/ https://www.gamesradar.com/simrefinery-the-lost-oil-plant-ga...
- SaberTail 5y agoAs aidenn0 said, this sounds like SimTower and its sequel Yoot Tower. There's a section of the manual[1] called "A Message From Yoot Saito, Creator of Sim Tower" that describes how he started creating it because he was curious about elevator programming. [1] https://archive.org/details/SimTower_-_Manual_-_PC/page/n7/mode/2up https://archive.org/details/SimTower_-_Manual_-_PC/page/n7/m...
- adenozine 5y agoI used to interview programmers with an elevator programming problem. Neat to see it expanded so excellently and cleanly in this piece. Well done!
- alasdair_ 5y agoI had this question during a Google interview. The interviewer became annoyed when I suggested that an elevator that sometimes went backwards to pick ip someone on a just-missed floor could at least be interesting, if not perfectly efficient. They had a preconceived idea that they wanted a stateless system and didn’t like my stateful approach, even if it was potentially better for end users.
- bombcar 5y agoThat’s an example of a thing that may work well but would piss users off - it apparently reversing would annoy.
- Thorrez 5y agoNot just annoy. Some users might think they accidentally got on the wrong elevator ("oops, I got on a down elevator instead of an up elevator") and leave the elevator at the next floor to ask for a new elevator.
- adenozine 5y agoYeah, that's one reason I stopped doing like code-this-thing style of interviews. There's no point in contriving problems for someone, we could both be working on something useful. I think for me at least, the main attribute I look for in a candidate for a developer role is the ability-to-avoid-shitty-solutions-ness of someone. If they steer themselves from bad ideas well, the rest can be taught by presentation and practice with the rest of the team. I've had a similar idea around measuring how many riders make calls over say the past 100 rides, and then trying to calculate how efficient it might be to deviate a few floors either direction to grab someone close-by. It's an interesting hole to climb into. Did you get the gig at google?
- em-bee 5y agothe problem is having particular expectations at the outcome, which is wrong. even after hiring, if i have a particular expectation how problems are to be solved, then that will lead to disappointment, micromanagement and disempowerment of my developers. i did use elevatorsaga in interviews with good results. having someone making such an unusual suggestion in an interview would be a plus for me. this person is thinking out of the box. and it would lead to a discussion of the difference of optimizing solutions for overall performance vs user expectations.
- dang 5y agoOne past discussion, plus a one-commenter: Elevator Saga: The Elevator Programming Game - https://news.ycombinator.com/item?id=21425054 https://news.ycombinator.com/item?id=21425054 - Nov 2019 (1 comment) Elevator Saga – An elevator programming game - https://news.ycombinator.com/item?id=8929314 https://news.ycombinator.com/item?id=8929314 - Jan 2015 (104 comments)
- larschdk 5y agoAnd sadly it still has some unfixed bugs since 2015 where people don't consider the up/down indicators correctly, and will not enter the elevator even though the lights are on in the direction they want to go.
- RobKohr 5y agoIt uses the MIT license, and the git repo is here: https://github.com/magwo/elevatorsaga https://github.com/magwo/elevatorsaga along with some pull requests which might fix those problems. On the repo it says: "For developers/contributors: This project is not actively maintained. The repo is used to serve github pages so I would like to keep it as is. Feel free to fork and host your own versions of Elevator Saga! But I would like to keep the domain name with the original version of the game." I am sure someone on here has the chops to set up a clone of it.
- voldemort1968 5y agoI was thinking of creating this very thing on several occasions being in an elevator. The logic of elevators is very intriguing and more complicated than people realize.
- 7373737373 5y agoI'm not sure if this is true. I think all elevators I've encountered followed the elevator/SCAN algorithm: > the elevator continues to travel in its current direction (up or down) until empty, stopping only to let individuals off or to pick up new individuals heading in the same direction. with the elevator staying on its last location if there are no new requests and there being no buffering time after a request, first come first served https://en.wikipedia.org/wiki/Elevator_algorithm https://en.wikipedia.org/wiki/Elevator_algorithm
- dialogbox 5y agoThat is true only for the single elevator system. If there are multiple elevators, the system could be extremely complicated.
- falldmg 5y agoHave you ever seen elevators where you select a floor from the outside and it gets assigned to one of multiple elevators? Those seem like they might be doing something more sophisticated.
- disposedtrolley 5y agoI used to have those elevators where I worked and everybody hated them. I think the algorithm was tuned for efficiency, so you’d be waiting for an elevator for minutes as it tries to batch everyone up, while a dozen other elevators sit idle. This was made worse through the need to specify the number of people who are travelling to a specific floor so the algorithm can allocate enough space in each elevator. Large groups often ignored this so you’d often find that an elevator you’ve waited minutes for is full, and start the dance all over again. https://en.wikipedia.org/wiki/Destination_dispatch https://en.wikipedia.org/wiki/Destination_dispatch
- TheRealNGenius 5y agoAh disk scheduling algorithms :) https://en.wikipedia.org/wiki/Elevator_algorithm https://en.wikipedia.org/wiki/Elevator_algorithm
- spicybright 5y agoAre real elevators ever coded with logic like mentioned in this thread? Or do they just keep it a simple as possible?
- bombcar 5y agoThey can be. Express elevators and such. But mainly the programs are limited to what floor the elevators idle at because more complicated programs even if more efficient overall often piss people off.
- BuildTheRobots 5y ago>which floors the elevators idle at... I recently spent 4 months in hospital which left me with an amount of time to kill in an attempt to stay sane. One of the games was trying to get places I was technically allowed but really shouldn't have been ("sod your 'no public access' signs, in not public, I'm an inpatient!"). Being confined to a wheelchair made the game a bit more difficult. One day one of the ward staff mentioned that the building used to have a 4th floor which got mothballed years ago. None of the elevators had a button for it and trying to get up a flight of stairs wasn't an option. After puzzling for a while, I finally realised that one of the elevators was still set to idle on the 4th floor. Get in the elevator, don't press any buttons, read a book for 10 minutes and bam - elevator returns itself to the 4th floor, opens the doors and goes ping. I wheel myself out to find I'm not just on the 4th floor, but also behind (on the inside of) the locked doors at the top of the stairs, which I counted as a double win ;)
- lucb1e 5y agoThat's amazing. I'll be trying that trick next time I have some time to kill in a building! We also play the game sometimes of getting places we're not supposed to (as consultants). Walk around like you're from IT and are supposed to be there (technically both true), perhaps with a laptop under your arm, nobody will care what you do to any of the computers there. In schools and hospitals, and probably other places, try (variants of) the city you're in as password, perhaps combined with the postal code, and you usually get access to everything because of course the staff needs to actually help you. The username is pre-filled, don't worry about that (most of the time that's the field with more entropy). It's honestly terrifying and short of locking rooms (because some of the personnel needs fast access to computers, preferably faster than plugging in and out smartcards all day long) there just isn't really a solution. I'm pretty sure we could have walked into a surgery room, we steered clear of any place that looked like it might head us into places with patients under actual operation. Why those aren't locked I don't know, probably there is a good reason so probably they can't change that...
- lloydatkinson 5y agoWhat am I doing wrong? for(elevator of elevators) { elevator.on('idle', () => { //do some logic with elevator }) } It only seems to run for the second elevator rather than both of them?
- mercora 5y agoi likely ran into the same or a related issue. i dont know much about javascript though. for(var i = 0; i < elevators.length; i++) { elevators[i].on("idle", function() { for(var j = 0; j < floors.length; j++) { elevators[i].goToFloor(j); } }) } it only works for "i < 1" and then only the second elevator moves... its kinda sad as i immediately enjoyed playing ...
- garaetjjte 5y agoI think this was discussed there: https://news.ycombinator.com/item?id=8933979 https://news.ycombinator.com/item?id=8933979
- mercora 5y agothis did indeed help understanding and fixing the issue.
- davnicwil 5y agoJust in case this is interesting, a potentially more elegant way to solve this with modern JS is to use 'for(let i' instead of 'for(var i'. The reason is that 'let' gives 'i' 'block scope', meaning that each iteration of the loop block gets its own scope so that 'i' isn't overwritten each time, and each function you declare captures the value of 'i' at the time it was declared. In other words - the way you originally expected 'var' to behave is how 'let' behaves!
- umvi 5y agoShould be `for (let elevator of elevators)`
- Jun8 5y agoMade me remember an interesting anecdote: During my PhD at Purdue I had the good luck to take the Pattern Recognition (nowadays would be called ML) course from Prof. Fukunaga, one of the pioneers in the field (https://en.m.wikipedia.org/wiki/Keinosuke_Fukunaga https://en.m.wikipedia.org/wiki/Keinosuke_Fukunaga). In one of his classes he mentioned that years ago a company came to him, requesting his expertise in optimizing movement of a bank of elevators. He thought it would be trivial :-) After telling us that all his approaches failed miserably, he had one of his impish laughs and told us that he never worked on that problem again. Miss that guy. Get a copy of his book (https://books.google.com/books/about/Introduction_to_Statistical_Pattern_Reco.html?id=BIJZTGjTxBgC&printsec=frontcover&source=kp_read_button&newbks=1&newbks_redir=0&gboemv=1 https://books.google.com/books/about/Introduction_to_Statist...) if you can, it’s written in the “old style” but very informative. Interesting fact: Gen Fukunaga (https://en.m.wikipedia.org/wiki/Gen_Fukunaga https://en.m.wikipedia.org/wiki/Gen_Fukunaga), founder of anime company Funimation, is his son.
- labster 5y agoI’ve always wondered if the main computer in Star Trek has to be so big just to manage the turbolifts. Three dimensional elevators with multiple exits per level, probably prioritizing routes dynamically based on the passengers and the military alert level. Imagine the algorithms.
- lloydatkinson 5y agoI think it would fundamentally be a constraint based programming problem, eg the sudoku solvers, travelling salesman implementations, software that tells eg Amazon warehouses which parcels go in the van first based on both size and the route it’s planned so that the driver never had to dig all the parcels out to get the buried ones.
- MobileVet 5y agoBoiler Up! I had Prof Fukunaga for EE301 I think (Might have been EE202). I was too young and dumb to recognize his brilliance.
- sleepy_keita 5y agoI've always been fascinated with elevator algorithms. This is awesome!
- curmudgeon22 5y agoDuring Covid, I've often wished I could reprogram the elevator of the apartment building I live in. The current rule is only 2 people can be in the elevator at a time. Problems that arise: * Elevator stopping frequently, but already at capacity, slowing down overall performance * Elevator always goes to bottom (or top) first to pick up passengers going up (or down). This means if your waiting on the ground floor and it's a busy time, folks at the parking levels will repeatedly get picked up before you. Possible solutions: * First come, first served (need to remember order of what floor pushed button when) * Ability to set elevator as "full". Even if abused by a single person, still better than multiple wasted stops.
- asdfasgasdgasdg 5y agoElevator could also make a decent guess at fullness just by recording the discrete changes in weight. It wouldn't be perfect but again it would probably be better than allowing user input.
- em-bee 5y agoi believe all elevators at least have a failsafe to refuse to run if they are overloaded. going from there to tracking and using the actual weight for its programming is not a big step
- kqr 5y agoOh, elevators know to some accuracy how many people-mass things are in it. It just rarely has reason to use that information.
- geofft 5y agoDuring COVID I think it's totally reasonable for any person to be able to set the elevator as "full" - if you're returning from travel and quarantining, immunocompromised, etc. you might not want to travel with anyone. Also, * Elevator door closes when it's not in use - may as well stay open, get some ventilation, and use slightly less energy!
- Aeolun 5y agoOh, this reminds me of the elevator banks in my office. I’m sure there’s something going on there. It can let me know which of 8 elevators is coming to pick me up as soon as I press the button.
- ziptron 5y agoI always wished elevator buttons could toggle. If you accidentally press the wrong floor, just press it again to cancel. This may not work in all situations, but in some situations, it could be a time saver.
- mcrae 5y agoIt works this way often in (north-east) Asia. Double-tap a selected floor and it unselects. Brilliant.
- thesnide 5y agoYep. My office one does that. I first it was a joke, but it actually is indeed a brilliant scheme to avoid misclicks. And as you seldom unselect, it's Huffman coding for the win ;-)
- em-bee 5y agoour elevator does that, and i noticed it is quite common in chinese elevators. i can undo all destinations which makes the elevator just stop. living on the top floor of a highrise, i was occasionally able to use that when i realized that i forgot something at home (although most times it takes me longer to realize that than the elevator needs to make it all the way down) it is also very useful when the kids are naughty and press all the buttons for fun
- deleted 5y ago[deleted]
- joshribakoff 5y agoMany modern ones in high rise buildings require you to scan a key fob and/or enter the desired floor number, then it tells you which elevator to go wait at. The ones with the key fob often replace your previous selection automatically. There are not buttons in this style of elevator other than door open door close and call for help.
- 5y ago
- gnramires 5y agoAn interesting improvement over naive operation I thought long ago: idle elevators should go to 1/2 maximum floor! You easily cut average wait times in 1/2! Problem is, it's also energy inefficient. If you get a passenger at floor 1 or 0, you've wasted a lot of movement. On-demand movement wastes minimally. So I've learned of a tradeoff between energy and waiting time -- not just elevator speed, but in algorithms. It's fun to consider a minimal energy solution (it takes a very long time to get anywhere ;) ).
- gnramires 5y agoI've also learned it's a classic under-specified problem. To solve it completely you need, for example: 1) distribution of arrival times and destinations of passengers; (For example, if late evening people usually go up, it's best to idle on ground floor) 2) a "satisfaction function", giving a measure of performance of your system: You can get low average waiting times and diverging maximum wait time for a busy elevator, simply trade time from a single passenger for others (by e.g. never going to a floor). As long as utilization is significant at all times, this phenomenon exists. Clearly it's not only average we care about, but also maximum and minima of transit times. --- It's a very illuminating modelling exercise.
- SMAAART 5y agoelevator.goToFloor(1); elevator.goToFloor(2); elevator.goToFloor(0);
- Jtsummers 5y agoThat (or a slight variation) works for the first couple of levels. Then it gets harder.
- SamBam 5y agoI was happy that my solution for level 4 was also accepted for level 5 and 6. Only a small tweak was needed for level 7, as now moves were counted instead of time. The next level required no passenger to wait longer that a certain amount of time, and I would have had to trash half my program, so I quit for now.
- SMAAART 5y agoelevator.goToFloor(0); elevator.goToFloor(1); elevator.goToFloor(2); elevator.goToFloor(3); elevator.goToFloor(4);
- Daneel_ 5y agoCall me weird, but I’ve been fascinated by elevator logic since I was a child. I had a math curiosities book that dedicated a chapter to it and after reading that I was hooked on knowing more. I wish my knowledge of JavaScript was more than “programming language that’s not Java” so I could actually play this. Could anyone recommend an online introduction to JS so I can attempt to play this? I’m more of a bash guy.
- GreenWatermelon 5y agoIf you know your way around any programming language, then hop on (https://learnxinyminutes.com https://learnxinyminutes.com) to quickly get the hang of any other language.
- 7373737373 5y agoAlso, to understand the asynchronous nature of Javascript, have a look at this excellent presentation and website: http://latentflip.com/loupe/ http://latentflip.com/loupe/
- petee 5y agohttps://www.codecademy.com https://www.codecademy.com I didn't finish, but I recall enjoying their intro to JS, and managed to write a few working things hah
- jmchuster 5y agoIf you like these programming games, localmotion has one where you schedule taxis to pick up passengers between buildings. https://www.getlocalmotion.com/code-challenge https://www.getlocalmotion.com/code-challenge
- muddywater 5y agoWe're building an API to monitor elevators and stuff inside buildings. There are smart and dumb elevators. In any case, no one is actively using the data yet to improve our experiences like mentioned on this thread...sometimes we just wish we knew when to take the stairs. If you're curious to view the kind of data streaming from a building or basic elevator, see here: (https://onboarddata.io/ https://onboarddata.io/), python SDK is on Github (https://github.com/onboard-data/client-py https://github.com/onboard-data/client-py). Every building is different. Some elevators have data on flooding, weight, inspection, electricity usage, while others do not.
- petee 5y agoMost hotels I've stayed at seem to be significantly limited on speed; anything <=5 floors is almost always faster to just head for the stairs and not even bother waiting. After a week, it's 6 floors.
- juloo 5y agoIt's annoying that it doesn't highlight syntax errors. It's even worse than that because it's intercepting the syntax error for logging purpose and loses any informations. You get unrelated errors in the app's code.
- petee 5y agoAn advanced level of this game should have you implement your logic with mechanical relays. Those relay banks are always fascinating
- CyanDeparture 5y agoThere should be a checkbox here to add a mirror to the ground floor waiting area. If memory serves me correctly, this significantly reduces the amount people complain about waiting because they will look at themselves and it won't feel as long.