Git Product home page Git Product logo

Comments (5)

magwo avatar magwo commented on September 1, 2024

Good point. I have thought about this in the past and there are some todos in the code, but I have not yet figured out a good design for this.

For example, have a look at these function stubs that are not used:
https://github.com/magwo/elevatorcrush/blob/master/elevator.js#L138

Would you want the "going up" and "going down" indications to be user-code controllable? Or do you think it should be automatic? As in.. if the next queued floor is above, then the elevator reports it is going up.

In other words, I'm not sure if this "going up/down" indicator is something that can always be deduced from the current travel queue, or if it is something that the scheduler/planner code needs to inform the system about - to reveal its intentions.

from elevatorsaga.

toonvr avatar toonvr commented on September 1, 2024

I think there are pro's and cons for both solutions. At first thought it seems logical to deduce the direction from the queue, but what if my only instruction is "go to floor X"? WIll people not get on because the queue is empty upon arrival?

On the other hand, if you make the users indicate the next direction, that will lead to additional difficulty for the earlier levels. (or all people get on if no direction is indicated)

By the way, thanks for the fun game and the quick reply :)

from elevatorsaga.

backtick avatar backtick commented on September 1, 2024

You could by default indicate both directions, but make it user controllable.

Also, in real life, there's always that one guy that steps into the wrong elevator, so maybe add a random chance a passenger ignores the indicated direction.

from elevatorsaga.

magwo avatar magwo commented on September 1, 2024

Yeah.. it's probably the best design, to make it default true for both direction and then expose setters and getters in the API..

elevator.goingUp(true);
if(elevator.goingDown()) { ... }

etc.

from elevatorsaga.

magwo avatar magwo commented on September 1, 2024

Added support for this, just need to update the documentation.

elevator.goingUpIndicator() // true by default
elevator.goingUpIndicator(false) // set to false

from elevatorsaga.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.