Comments (7)
Nice find, pretty serious bug. Will take a look.
from elevatorsaga.
It's kind of sporadic, but I managed to make a test that consistently fails.
https://github.com/magwo/elevatorsaga/blob/floorpassing/test/tests.js#L302
It seems that if you overshoot some certain "magic" amount or something, the bug manifests.
The code that generates the passing_floor events is not very clean. I'd like to make it more simple and obviously correct.
The reason it is complicated, I think, is because sometimes elevators overshoot slightly when stopping at a floor, causing it to pass the floor and then go back down. This is a tiny amount and that should not trigger the passing_floor event again, which complicates the code.
from elevatorsaga.
Might have to completely rewrite the code that generates these events.
from elevatorsaga.
Now rewritten and kind of fixed. You can still sometimes get multiple events for the same floor when stopping very close to the floor, due to slightly bouncy control system. But all the events should be expected and arguably correct.
from elevatorsaga.
I'm still seeing this behavior and it does not seem correct. When the elevator is moving from floor 2 to floor 0, on the first "passing_floor" (1) event I direct it to goToFloor(1). This results in several new "passing_floor" (0) events.
Floor 1 has not yet been passed, and floor 0 is not being passed (it is scheduled to be visited after the visit to floor 1).
I should add, the number of redundant passing_floor events is dependent on the timescale. At 1x, there are about 20 extraneous passing_floor(0) events. At 2x, there are about 9 events; at 55x there are 1 or 2.
from elevatorsaga.
You are correct. Will investigate.
from elevatorsaga.
Code to reproduce:
{
init: function(elevators, floors) {
var elevator = elevators[0]; // Let's use the first elevator
// Whenever the elevator is idle (has no more queued destinations) ...
elevator.on("idle", function() {
// let's go to all the floors (or did we forget one?)
elevator.goToFloor(2);
elevator.goToFloor(0);
});
elevator.on("passing_floor", function(floorNum, direction) {
console.log("passing floor", floorNum, direction);
if(floorNum === 1 && direction === "down") {
elevator.stop();
elevator.goToFloor(1);
}
});
},
update: function(dt, elevators, floors) {
// We normally don't need to do anything here
}
}
from elevatorsaga.
Related Issues (20)
- Add a restart button while running elevator HOT 2
- On MS Edge, clicking "Next Challenge" doesn't do anything HOT 2
- Doesn't work on Chromium HOT 1
- Provide a "playground" mode where you can try out for debugging purpose
- Elevator moves while passengers enter the elevator
- Can't select code on Android Chrome
- Allow importing libraries?
- how are we supposed to know how many elevators we have access to? HOT 3
- How to update world (floors,elevators count) without changing challenge?
- Passengers not rehitting button
- Only last configured elevator behaves HOT 2
- Is this repo will be maintend HOT 4
- New levels based on real life
- I don't get this error HOT 2
- Turn off the code auto-formatter HOT 1
- Sharing Website doesn't load a preview-image
- Bug: User doesn't enter the elevator when it stops enroute HOT 1
- TypeScript for the API HOT 2
- Specify which passenger waited too long. HOT 4
- goingUp and goingDown indicators are always true HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elevatorsaga.