|
|
@ -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
|
|
|
|
```js
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -35,14 +37,15 @@
|
|
|
|
if (!getFreeElevator(floor)) {
|
|
|
|
if (!getFreeElevator(floor)) {
|
|
|
|
// We didn't found free elevator
|
|
|
|
// We didn't found free elevator
|
|
|
|
var less_loaded = getLessLoaded()[0];
|
|
|
|
var less_loaded = getLessLoaded()[0];
|
|
|
|
less_loaded.destinationQueue.push(floor);
|
|
|
|
if (!less_loaded.destinationQueue.includes(floor)) {
|
|
|
|
//less_loaded.destinationQueue = superSort(less_loaded);
|
|
|
|
less_loaded.destinationQueue.push(floor);
|
|
|
|
less_loaded.checkDestinationQueue();
|
|
|
|
//less_loaded.destinationQueue = superSort(less_loaded);
|
|
|
|
|
|
|
|
less_loaded.checkDestinationQueue();
|
|
|
|
// debug
|
|
|
|
// debug
|
|
|
|
console.log("Added floor " + floor + " to less loaded elevator");
|
|
|
|
console.log("Added floor " + floor + " to less loaded elevator");
|
|
|
|
console.log("Elevator queue: ");
|
|
|
|
console.log("Elevator queue: ");
|
|
|
|
console.log(less_loaded.destinationQueue);
|
|
|
|
console.log(less_loaded.destinationQueue);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -123,7 +126,11 @@
|
|
|
|
//console.log("Elevator " + elev + " pressed floors:");
|
|
|
|
//console.log("Elevator " + elev + " pressed floors:");
|
|
|
|
//console.log(elevator.getPressedFloors());
|
|
|
|
//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
|
|
|
|
// Stopped on a particulat floor
|
|
|
@ -188,8 +195,8 @@
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
update: function(dt, elevators, floors) {
|
|
|
|
update: function(dt, elevators, floors) {
|
|
|
|
// We normally don't need to do anything here
|
|
|
|
// We normally don't need to do anything here
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
```
|