{"_id":"@derhuerst/2048","_rev":"2-37dee8d0df4fb539c6f46f284e72c853","name":"@derhuerst/2048","description":"A deterministic version of 2048.","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.1":{"name":"@derhuerst/2048","version":"1.0.1","description":"A deterministic version of 2048.","main":"index.js","scripts":{"test":"mocha","start":"nakedjs src/application.js"},"repository":{"type":"git","url":"git+https://github.com/voltrevo/2048.git"},"browserify":{"transform":["babelify","html2jsify","scssify"]},"keywords":["2048","deterministic","ai","bot","game"],"author":{"name":"Andrew Morris"},"license":"MIT","bugs":{"url":"https://github.com/voltrevo/2048/issues"},"homepage":"https://github.com/voltrevo/2048#readme","dependencies":{"brace":"^0.8.0","lodash":"^4.16.4","sha256":"^0.2.0","voltrevo-event-emitter":"^1.1.2"},"devDependencies":{"babelify":"^7.2.0","babel-preset-es2015":"^6.6.0","eslint":"^2.4.0","eslint-config-airbnb":"^6.1.0","eslint-plugin-react":"^4.2.3","html2jsify":"0.0.2","nakedjs":"^0.1.0","scssify":"^0.3.7","tape":"^4.6.2"},"gitHead":"141c8d0f6a719476af0105f5f4ae9e5cd39e4e26","_id":"@derhuerst/2048@1.0.1","_shasum":"f17a1c54e8c250f5e44e8d47dac6ec3457cbbeb5","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.1.0","_npmUser":{"name":"derhuerst","email":"mail@jannisr.de"},"dist":{"shasum":"f17a1c54e8c250f5e44e8d47dac6ec3457cbbeb5","tarball":"https://registry.npmjs.org/@derhuerst/2048/-/2048-1.0.1.tgz","integrity":"sha512-ohaoDJcbXRbHaUUMjtiuGEbIvNjqC5YKiC8X/Ck5dyNePdgAOPMPpWbdeYVGUAQrcirjEKnx5gixl7g9Ro+ZGg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCELRKG+SFrrz22sa77qAwbhhDCluv7Murm3L0gvgva6gIhAOA04X6axwWZUAOeYgava7FPwy3ADRm6UJxExlT0Z1vy"}]},"maintainers":[{"name":"derhuerst","email":"mail@jannisr.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/2048-1.0.1.tgz_1498340892612_0.9363993948791176"}}},"readme":"# 2048\nThis is a fork of Gabriele Cirulli's 2048 project with some changes around deterministic play and unlimited undos.\n\nLive here: https://andrewmorris.io/2048.\n\n# The Challenge\nAs you start playing, you'll notice that your moves are displayed in the url hash. This makes your game state and its history shareable ([usually](#url-hash-format)). Your mission is to produce a url with the highest score you can find.\n\n# Headless Version\nSince you are a developer, you will likely desire to separate your algorithmic number crunching domination from the fancy schmancy graphical frontend I have provided. Fear not my friend, simply add `\"voltrevo-2048\": \"voltrevo/2048\"` to your `package.json` and access the `Board` factory via:\n\n```js\n'use strict';\n\nconst Board = require('voltrevo-2048/src/Board.js');\n\nconst b = Board();\n\nb.up();\nb.down();\nb.left();\nb.right();\n\nconsole.log(b.prettyString()); /*\n  +------------+\n  | 0  0  0  4 |\n  | 0  0  2  0 |\n  | 0  0  0  0 |\n  | 0  0  4  2 |\n  +------------+\n*/\n```\n\nYou can also experiment with this in the developer console as `window.Board`. Boards also provide `.getCells()` and `.clone()`, and you can specify the game seed and starting state like this:\n\n```js\nBoard({\n  gameSeed: 'foobar',\n  cells: [\n    [0, 0, 0, 4],\n    [0, 0, 2, 0],\n    [0, 0, 0, 0],\n    [0, 0, 4, 2],\n  ],\n})\n```\n\n# The Suggestion Engine\nSpeaking of the headless version, you may have noticed that the game displays move suggestions for you. These suggestions are generated by `trivialGetSuggestion.js` which looks like this:\n\n```js\nmodule.exports = (board) => {\n  const movePriority = ['right', 'down', 'up', 'left'];\n\n  for (let i = 0; i !== movePriority.length; i++) {\n    const move = movePriority[i];\n\n    if (board[move]()) {\n      return move;\n    }\n  }\n\n  // Nowhere to go, but still need to return something\n  return 'right';\n};\n```\n\nThese suggestions are very weak, as they simply attempt right, down, up, left, in that order. If you create a headless AI, you might want to fork this project and incorporate it here to interact with and see what your AI moves look like. You might even use this to team up with your AI to produce a better outcome together.\n\nThis is also accessible to you in the console of the official version by overwriting `window.gameManager.getSuggestion`.\n\n# URL Hash Format\nIf your move sequence becomes *very* long, it may become abbreviated using a fake url that is not shareable. The format looks like this:\n\n`https://andrewmorris.io/2048/#<game-seed>;<move-sequence-url>;<undo-count-after-url>;<raw-moves>`\n\nSo if your `move-sequence-url` is something like `2048://wwxzcbyyzo`, that url will only work inside the page that generated it. To fix this, you can print your raw moves in the developer console with this command:\n\n`gameManager.moveStore.resolve().then(moves => console.log(moves));`\n\nThen, I suggest creating a url for those moves using a [github gist](https://gist.github.com/) (use the **raw** button), and then shortening it using [goo.gl](https://goo.gl/), and then you can create a shareable url like this:\n\n`https://andrewmorris.io/2048/#<game-seed>,<url-you-created>`\n\n**Note**: `<game-seed>` might be an empty string. That's ok.\n\n# Run Your Own Instance\n\n```sh\ngit clone git@github.com:voltrevo/2048\ncd 2048\nnpm install\nnpm start\n# see localhost:8080\n```\n\n**Note**: You will need [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [node](https://nodejs.org/en/download/).\n\n## License\n2048 is licensed under the [MIT license.](https://github.com/gabrielecirulli/2048/blob/master/LICENSE.txt)\n","maintainers":[{"name":"derhuerst","email":"mail@jannisr.de"}],"time":{"modified":"2022-06-12T17:01:10.856Z","created":"2017-06-24T21:48:13.604Z","1.0.1":"2017-06-24T21:48:13.604Z"},"homepage":"https://github.com/voltrevo/2048#readme","keywords":["2048","deterministic","ai","bot","game"],"repository":{"type":"git","url":"git+https://github.com/voltrevo/2048.git"},"author":{"name":"Andrew Morris"},"bugs":{"url":"https://github.com/voltrevo/2048/issues"},"license":"MIT","readmeFilename":"README.md"}