2048 AI

Original AI for the game 2048.

See my new AI for this game here --> 2048AI

This fork is focused on the implementation of several AI methods geared towards effectively teaching these various methods. Below is a list of the AI methods I plan to implement:

1. IDA* Search
2. Backtracking Search

I advise the community to help with implementing more AI programs and perhaps involving their own kinds of heuristics to help generate new methodologies for Game Theory.

Understanding how the game works:

The Key Files

  1. animframe_polyfill.js :: This is used with Firefox or Chrome to:
* preload animation frames
  1. application.js :: Prevents game from glitching. Calls the GameManager to begin

  2. bind_polyfill.js :: ???

  3. classlist_polyfill.js :: ???

  4. game_manager.js :: The Core Game Manager contains methods for:

* Beginning/Terminating/Restarting a game
* Setting up the grid
* Holds 4 parameters => Grid Size, Input Manager, Actuator, Storage Manager
* Adding a tile at random
* Serializing the Grid
* Performing movement
* Merging tiles
* Detecting available moves/game score
* Saving game progress
  1. grid.js :: Contains various funcitions for manipulating the game grid
* Checking cells
* Insertions and removal of tiles
  1. html_actuator.js :: Contains various functions for interface, tile mechanics and scoring
* Adding a tile
* Changing the look of a tile using classes
* Updating the score
  1. keyboard_input_manager.js :: Handles the listening to the inputs for movement
* Attaches event listeners for button events (Restart,KeepPlaying) 
  1. local_storage_manager.js :: Saves game state and best score in local storage

  2. tile.js :: Class object for the tiles

* Save/Update position
* Serialize (JSON)
  1. application.js :: requests an animation frame and generates a new game manager with Keyboard Manager, Actuator, and Local Storage

Implementing Custom Tile Movements

Within the game manager, simple call the move function with the specified movement direction. For movement directions, see the translate function in ai.js

Built With

Share this project:

Updates