Update 'level2.md'

master
Andrey Prokhorov 6 years ago
parent 81c7cbba98
commit 92985cb1be

@ -1,4 +1,6 @@
### v0.1
### v0.2
It's not really optimal, as elevator builds it's destination queue in plain format without thinking about it's current movement direction.
```js
{
@ -35,16 +37,17 @@
if (!getFreeElevator(floor)) {
// We didn't found free elevator
var less_loaded = getLessLoaded()[0];
if (!less_loaded.destinationQueue.includes(floor)) {
less_loaded.destinationQueue.push(floor);
//less_loaded.destinationQueue = superSort(less_loaded);
less_loaded.checkDestinationQueue();
// debug
console.log("Added floor " + floor + " to less loaded elevator");
console.log("Elevator queue: ");
console.log(less_loaded.destinationQueue);
}
}
}
// Get distance of elevator from floor
getDistance = function(elevator, floor) {
@ -123,7 +126,11 @@
//console.log("Elevator " + elev + " pressed floors:");
//console.log(elevator.getPressedFloors());
elevator.goToFloor(floor);
//elevator.goToFloor(floor);
if (!elevator.destinationQueue.includes(floor)) {
elevator.destinationQueue.push(floor);
elevator.checkDestinationQueue();
}
});
// Stopped on a particulat floor

Loading…
Cancel
Save