Skip to content

pcnelson/2048web

 
 

Repository files navigation

2048

A derivation of [2048] by https://github.com/gabrielecirulli/2048 that adds automated play.

Play the modified version here:

The modified game adds:

  • an "AI Play" button or Shift-X to toggle automated play
  • X to make a single automated move
  • a log window of moves and messages from the AI

The automated player is implemented as a web service at ai.py on the game host that's passed info about the game's current state and returns a text response with the first line oneof up,left,right,down and the second line as an optional message.

Probe the web service here: http://2048.calebn.com/ai/ai.py?ai=left&score=228&board=32,16,8,2,16,4,0,0,2,0,0,0,2,2,0,0&prior=lullll&drop=3,1,2

Arguments to the ai service include

  • ai= which algorithm to use (specified on the url to the game)
  • arg= optional args for the algo (also specified on the url to the game)
  • gid= id of game, autogenerated by the client
  • score= current score
  • board= current board, by row in format "4,2,0,0, 4,0,0,0, 0,0,0,0, 0,0,0,0"
  • prior= recent prior moves as string (e.g. "udlr" where 'u' was the most recent move)
  • drop= cell dropped by game after last move as [row, col, value] (e.g. "1,0,4")

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 46.6%
  • CSS 43.7%
  • HTML 9.3%
  • Ruby 0.4%