Code Monkey home page Code Monkey logo

prime-2048's Introduction

PRIME 2048

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.

Screenshot

Prank 2048 Screenshot

Technical Details

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

prime-2048's People

Contributors

chrisprice avatar cinedan avatar codekonami avatar coding46 avatar david-risney avatar gabrielecirulli avatar ghoullier avatar harimohanraj89 avatar iharosi avatar iirelu avatar janschoenherr avatar jasonkleban avatar jimminning avatar jnohavica avatar johankj avatar leereilly avatar maciejczyzewski avatar marcingajda avatar marg51 avatar marvin08 avatar mfrederiksen avatar remram44 avatar sigod avatar timpetricola avatar zg avatar

Watchers

 avatar  avatar

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.