9 ms·
Elevator Saga: Elevator programming game
- rlv-dan 4y agoThe best thing about this is that I no longer feel an urge for another side project to make an elevator programming sim myself :-)
- deleted 4y ago
- fragmede 4y agoReminds me of SimTower https://simtower.fandom.com/wiki/Elevators https://simtower.fandom.com/wiki/Elevators
- metadat 4y agoI played this too much growing up. Never did figure out how to survive becoming a 4 or 5 star hotel, the clientele always vanished once the stars level increased that high and I was never able to recover! Fond memories of all 90s Maxis games!
- dragontamer 4y agoIIRC, all offices need to be reset periodically. Was it... setting the price high then low, then high again? It was something like that. All offices in SimTower had a time-limit on their usage. Once they've been occupied for a few years, no one likes the office and you need to manually refresh them by setting prices through some price ritual (delete? Change prices? I forget). ---------- Alternatively, set the bottom 20 floors to hotels, and the basement floors to a great parking lot + shopping center in support of those hotels.
- colechristensen 4y agoYup, you set the price of the office to the minimum and then back up.
- swyx 4y agovery "nobody goes there, it's too crowded" energy haha
- omnibrain 4y agoI also immediately thought of Sim Tower. The introduction chapter to the handbook mentioned that the Dev (Yoot Saito) actually started with an elevator simulation.
- KingOfCoders 4y agoNice, I used such code (elevators) as part of interviewing.
- mikeatlas 4y agoI've had this prompt given to me in interviews.
- xiaodai 4y agothis is a classic. i wonder what other programming games are there though?
- schemescape 4y agoI’ve been working on a single-instruction (subleq) programming game that runs in the browser: https://jaredkrinke.itch.io/sic-1 https://jaredkrinke.itch.io/sic-1 Edit: very much inspired by TIS-100.
- tarentel 4y agoHuman Resource Machine is pretty interesting. TIS-100 is also neat but it can be a bit much as it can definitely feel more like programming than a game.
- ZetaZero 4y agoA mostly curated list: https://www.reddit.com/r/programminggames/comments/d5pg8q/a_list_of_all_recommended_programming_games_by/ https://www.reddit.com/r/programminggames/comments/d5pg8q/a_...
- teddyh 4y agoSee also: https://news.ycombinator.com/item?id=6345975 https://news.ycombinator.com/item?id=6345975
- publicola1990 4y agoShenzhen I/O, is one of the many Zachtronics games which are largely programming games.
- Behemoth66 4y agoBitburner is my favorite. https://store.steampowered.com/app/1812820/Bitburner/ https://store.steampowered.com/app/1812820/Bitburner/ It’s an idle game at its core so it feels like Factorio whereby you try to automate as much as you can as efficiently as you can.
- buescher 4y agoI think this has come up before. I'd love to know what a real elevator programmer thinks about it. I suspect real-world approaches to the problems the game presents are relatively simple, and you spend most of your time on corner cases and other issues that you would never anticipate if you weren't in the industry.
- schemescape 4y agoPun intended?
- bombcar 4y agoSomething like https://www.otis.com/en/us/products-services/products/ems-panorama https://www.otis.com/en/us/products-services/products/ems-pa... may be the place to start. I know you can program them to "idle" on different floors depending on time of day, and prioritize certain floors (e.g., try to always have one ready to go on the ground floor). I wouldn't be surprised if you could find systems that integrate with hotel doors, and when a hotel door is opened and the light turned off on floor ten, it works to get an elevator sent to floor ten.
- Nextgrid 4y agoI think this is a system where AI could shine. Trained on every possible data point you can get from the building (status of individual lights, room occupancy, etc), it might end up with a better strategy than what a human could come up with.
- jfaerge171 4y agoIt is a really great game. I am sure that the game has been on hackernews before as I think I read about it here a long time ago. In the old thread there was a comment from a poster that worked with elevators and he said it was pretty close to the real thing! However it missed one important thing… You could do the most effective algorithms, but everything broke down when partners having their own special badge summoned an elevator. They should have the first empty one, and they should ride alone to their office floor.
- PinguTS 4y agoThis reminds me of my university time as a student. In the realtime OS/programming course we needed to build an elevator with 4 cars in parallel entirely on an i386 (Embedded) in an realtime OS including the simulation of people pressing the floor numbers.
- autoexec 4y agoYeah, this is bringing back memories for me too. Is controlling an elevator a common coding exercise? When I started learning C I was just learning on my own and wrote something like this too, although it was only 2 elevators I worked to limit the amount of time people in an office building spent waiting. At one point I had over 50 fake people each assigned to a floor and a schedule (including breaks and and lunches), and even cleaning staff who went floor to floor a couple times a day. I don't remember where the idea for it came from though.
- jeffreyrogers 4y agoI have had it as an interview question before.
- daitangio 4y agoVery nice! I like it a lot and remember me the disk drive "head" algorithm for collecting data on different sectors (OS exam...24 years ago)
- swyx 4y agovery excited about this! but the docs need a lot of work what is the return signature of getPressedFloors? how do you add stuff to the destination queue? can i swap out the DQ with a priority queue? how do i store state between runs? can i run/deploy an ML model in this? so many questions
- mdaniel 4y agoAccording to https://news.ycombinator.com/item?id=27585467 https://news.ycombinator.com/item?id=27585467 the repo is https://github.com/magwo/elevatorsaga https://github.com/magwo/elevatorsaga but is also abandoned To answer your first question: https://github.com/magwo/elevatorsaga/blob/master/elevator.js#L166 https://github.com/magwo/elevatorsaga/blob/master/elevator.j... Be aware that it's just `eval(textarea.value)` so you can `console.log` or (presumably) `debugger;` in your code to inspect whatever you want. The developer tools likely will allow you to set breakpoints in the framework's code, too I was sad the `thing.on("some_event", () => { this. <-- isn't "thing"`, I had to `.bind(thing)` manually
- eyelidlessness 4y agoAt a glance (mobile sorry), it looks like .on is jQuery? If so, you don’t need bind, you just need `function`: thing.on("some_event", function() { // `this` is `thing` }) Arrow functions close over `this` from their outer scope.
- alar44 4y agoYup, I tried this a while back and gave up after not being able to figure out where/how the queue worked.
- tuukkah 4y agoYes, it's unfortunate that the game starts very easy but then immediately becomes quite difficult even requiring some reverse engineering. Basically, each elevator has a queue of the floors where it's going next. The elevator will always try to move to the floor at the front of the queue. When it stops at the destination floor, it removes that floor from the front of the queue. Whenever the queue is empty, the idle event triggers. elevator.goToFloor(floorNumber); // Adds floorNumber to the end of the queue elevator.goToFloor(floorNumber, true); // Adds floorNumber to the front of the queue (changing the destination immediately) elevator.stop(); // Clears the queue (stopping the elevator immediately) I suppose you can use your own queue data structure instead and keep at most one element in the built-in queue just to control the current direction of the elevator.
- paxys 4y agoVery cool! I'd also love to see the option of putting the floor selector outside the elevator, which seems to be getting more and more common now in tall buildings.
- anigbrowl 4y ago// Whenever the elevator is idle (has no more queued destinations) ... I don't get it. The first challenge is to fix the fact that the idle loop never sends the elevator to floor 2, fair enough. But generally when I run the simulation a person appears and calls the elevator on floor 2, plus people get into the elevator on floor 0 and don't get out on floor 1 (presumably because they dream of going to floor 2). So how are their inputs not queued? This might work better as an IDE that had a watch variable window showing the queue. As it is I feel I'm experiencing a simulation of badly documented code rather than a badly programmed elevator.
- TylerE 4y agoNothing in the starter template queues anything. You have to wire that up.
- anigbrowl 4y agoThe quoted comment is taken directly from the starter template. Hence my comment about 'badly documented code'.
- throwaway4aday 4y agoThe api documentation https://play.elevatorsaga.com/documentation.html https://play.elevatorsaga.com/documentation.html is correct, you just need to think about the problem rather than expect step by step handholding.
- shagie 4y agoA person waiting for the elevator doesn't put anything into the queue. The loop for challenge 1 is: q: [] idle -> enqueue 0, 1, 2 --- q: [0, 1, 2] go to floor 0; (noop@floor0)q: [1, 2] go to floor 1; q: [2] go to floor 2; q: [] idle -> enqueue 0, 1, 2 --- q: [0, 1, 2] go to floor 0; q: [1, 2] ... It doesn't matter if anyone wants to go to that floor who is in the elevator or wants to get on the elevator at that floor. https://play.elevatorsaga.com/documentation.html https://play.elevatorsaga.com/documentation.html And then you get into the events... something like this would likely be interesting/chaotic. elevator.on("floor_button_pressed", function(floorNum) { elevator.goToFloor(floorNum, true); })
- loloquwowndueo 4y agoThe elevators in Taipei 101 have to be among the most advanced, and yet it was insane how long I had to wait for one, how seemingly irrationally it went picking people up, and what a mess it was figuring out your floor if you were using one of the double-decker elevators (my point is : the computer should figure it out for me). I’m terribly unimpressed by people programming real elevators.
- fragmede 4y agoFun fact, elevator capacity is the limiting factor on skyscraper size. Taipei 101 (which has, creativity, 101 floors) has ultra high speed elevators, capable of running up to 37mph and it is the world's fastest elevator. It'll go from the 5th to the 89th floor in 37 seconds. The programming may seem haphazard, and it might actually be, I've never been there in person, but the elevator aren't bad for lack of trying. The new elevator system where you tell it the floor and it tells you which elevator to go to is part of the programming optimization.
- CobrastanJorji 4y agoI wonder if this is a scenario where it would make sense to advertise competence by offering more information to the user. Imagine a big visualization on the ground floor showing all 101 floors, the location of each elevator, which floors are waiting on people, where each elevator plans to stop, estimated ETAs, etc. It'd give waiting folks something pretty to idly study, and it'd also provide reassurance that the elevators are all doing quite a lot of work in a reasonably intelligent way. You'd probably need to balance this against some privacy concerns (maybe it's a bad idea to show people exactly when someone in the penthouse gets into the elevator).
- glonq 4y agoVery fun. Pro tip: the riders are random in each test run, so if you failed but were close, just re-run and you might get lucky.
- zxcvbn4038 4y agoFun, but has not been updated in a while. Adding a hall of fame with peoples algorithms ranked and available for others to improve upon would be an awesome addition.
- DonHopkins 4y agoThere needs to be a genre of elevator dating games.
- NKosmatos 4y agoNice one, reminds me of a similar programming assignment we had back in the 90s, while learning assembly for the OS-9 RTOS.
- DonHopkins 4y agoAt SciFi conventions I had a friend who was good at lock picking, and he picked the lock of the elevator control room at the top of the hotel. The elevators were controlled by cabinets of relays, and there was a schematic of the elevator controller, which was pretty straightforward to follow and not too complicated. You could trigger the elevator into going to different floors by toggling the relay corresponding to the call button with a pencil. On one of the cabinets full of relays that controlled the elevators was taped a piece of paper with the phone numbers of all the emergency phones in every elevator. It was like discovering the holy grail! Since the elevators at SciFi cons were a bottleneck and always crowded, it took a long time to wait for one and get to the lobby or the floor of the party you wanted to attend. So whenever I was in a hotel room and wanted to go somewhere else, I would call up an elevator: "Ring!" Somebody would answer and I'd say "Hello!". They'd invariably say "Hey, WTF, this is an elevator!" I'd say "What floor are you on?" They'd tell me something like "12.", and I'd ask "Are you going up or down?" If they were going the right direction, then I'd then ask them "Please press 27, I'll be waiting for you!" And sometimes I'd prank call the elevators: "Ring!" "Hello, this is Dominos Pizza!" "Hey, WTF, this is an elevator!" "What floor are you on?" "12." "Please press Ground, I'm in the lobby with your pizza. I'll be waiting for you!"
- dbcurtis 4y agoI have written elevator interface code to allow robots to call elevators for themselves. So, yeah, I had an ap for that. I used my phone for testing.
- a2h 4y agoMy first experience with this game was actually during an interview. About halfway through I found the bug. The below code snippet will successfully solve all of the challenges. { init: function(elevators, floors) { world.transportedCounter = 500 }, update: function(dt, elevators, floors) { // We normally don't need to do anything here } }