Slightly related - SimTower was originally created as an elevator simulator - if you right click on an elevator engine room in the game you get a wealth of programming options
Elevator Saga – An elevator programming game
71–80 of 108 posts
Re: Elevator Saga – An elevator programming game
#72Earlier quoted context omitted.
You're probably hitting an issue with the way that closures work in javascript (and many other languages). for(var i = 0; i Doesn't do what one might expect. When the anonymous function is invoked, it looks up the value of the 'i' identifier, which will have changed it's value to elevators.length by the end of the loop. To get the behavior you want, I've seen people do for(var i = 0; i This creates a new scope, which…
Thank you! Your suggestion makes sense indeed and works fine!
elevators.forEach(function(elevator, elevatorNumber) {...});
This will provide each elevator with its index in the elevators array.Re: Elevator Saga – An elevator programming game
#73Re: Elevator Saga – An elevator programming game
#74First, why do you have to call checkDestinationQueue after modifying the queue? It's awfully redundant. I assume this is due to some kind of limitation.
And second, goingUpIndicator and goingDownIndicator are kind of sketchy. Can you activate both at the same time? What effect would that have? There should be a single property, directionIndicator of an enum type with the possible values up, down, and none. I don't think you can make enums in javascript though, but I don't know the language very well. I'm just explaining this in terms that I know; there probably is a suitable javascript equivalent or replacement.
Re: Elevator Saga – An elevator programming game
#75Re: Elevator Saga – An elevator programming game
#76I can't help but feel like there is something deeply wrong with me
Re: Elevator Saga – An elevator programming game
#77Re: Elevator Saga – An elevator programming game
#78Can work for all up to 9, except 5. Can't get it to work. When it has to be done within 'x' moves, change foreach 'e' variable to var `e = `
Main 'pattern' behind it: the elevators decide everything. Each elevator does the same based on a global array of where passengers are waiting.
Re: Elevator Saga – An elevator programming game
#79The game would be a lot more fun with realistic or even real measured workloads.
Re: Elevator Saga – An elevator programming game
#80How are the passengers generated? Do they follow a realistic distribution, or are they just completely random? The game would be a lot more fun with realistic or even real measured workloads.
They spawn at a fixed rate, but at random floors, with 50% spawning at the bottom floor.
I agree it would be more interesting if there were patterns, distributions, more popular floors etc. Haven't gotten around to implementing it. There's a small unused bit of code here intended for this: https://github.com/magwo/elevatorsaga/blob/master/challenges...