Coder Social home page Coder Social logo

Need a game over state about 2048-2600 HOT 3 CLOSED

chesterbr avatar chesterbr commented on June 2, 2024
Need a game over state

from 2048-2600.

Comments (3)

unwiredben avatar unwiredben commented on June 2, 2024

OK, just played some more, and this is more complicated than I thought... you enter this state when all tiles are full and there's no way to move in any direction. This means detecting this requires running the shift logic in both directions, but without doing the actual shift. I think it's still worthy to implement, but it's not as easy as I thought.

from 2048-2600.

chesterbr avatar chesterbr commented on June 2, 2024

Yep... if memory was not an issue, it might be possible to do it that way. A cheaper option is traversing once with +1 vector, then 4 times with +5 with increasing delta searching for duplicates, but for now simply not allowing any move should suffice. Will likely return to this problem when/if I tackle multiplayer, I suppose. Thanks for investigating!

from 2048-2600.

chesterbr avatar chesterbr commented on June 2, 2024

Just FYI, I added the game over detection. I figured out that it was easier to find if the game is NOT over: that happens when you either

  • have at least one empty cell (regardless of merge possibilities)
  • have two adjacent cells with the same value (meaning you can shift even if there is no empty space)

The code only iterates once, searching for either of these conditions and stopping once it finds one. If it passes the last cell and neither is found, we have a game over situation.

from 2048-2600.

Related Issues (7)

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.