A small adaptation of Gabriel Cirulli's original 2048.
If you know people with an obsession for 2048 that has gotten out of hand then subtly redirect them to play this version!
Instead of just generating either a 2 tile or 4 tile each move, around the time that the player has successfully generated the 256 tile (i.e., after the player has already committed enough time to become attached to the outcome of the game) this version of 2048 will begin to generate tiles with random prime numbers! The probability of generating a prime-numbered tile continues to increase as gameplay continues! See if your friend can still make it to the 2048 tile with more and more of the gameboard is occupied with prime-numbered junk tiles!
Try out the web version of this Prime 2048 code here!
An apk for a (very) basic android port can be found here in case you want to attempt to surreptitiously install it on your problem-friend's phone. (You can extract the .apk file for yourself and verify that the source code is the same as the code present in this repository!) This apk was tested on Android API level 24.
Modifications were made to the original game to allow for additional values to be generated. Specifically modifications include:
-
GameManager.prototype.addRandomTile : modified so that if the value generated by 'Math.random()' is below the value specified by 'primeGenerationProb()' it uses a value from a call to 'randPrime()'
-
GameManager.prototype.randPrime : created to generate a random prime number for use in a cell
-
GameManager.prototype.isPrime : created to check if the passed number is prime
-
GameManager.prototype.primeNotInBoard : created to check to make sure the prime has not been generated before
-
GameManager.prototype.primeGenerationProb : calculates the probability of the next generated tile being prime
- probability increases as the sum of tiles in play approaches 2048 (i.e., the longer the game has been played)
- probability is zero if sum of tiles is less than 512, probability maxes out at 1/8
-
GameManager.prototype.totalValueOfTiles : created to sum the value of all tiles currently in play