Comments (3)
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.
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.
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
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 2048-2600.