{"_id":"2048-danyo","_rev":"2-b9956210aa6e58552496dd1b9bd59c76","name":"2048-danyo","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"2048-danyo","version":"1.0.0","keywords":["2048"],"author":{"name":"Danyo"},"license":"MIT","_id":"2048-danyo@1.0.0","maintainers":[{"name":"danielhong35","email":"danielhong35@gmail.com"}],"homepage":"https://github.com/dhong9/2048-danyo#readme","bugs":{"url":"https://github.com/dhong9/2048-danyo/issues"},"dist":{"shasum":"a2af38132c03326f088a6fb62d10a3f44f7b8411","tarball":"https://registry.npmjs.org/2048-danyo/-/2048-danyo-1.0.0.tgz","fileCount":4,"integrity":"sha512-UGd8jfEt57iJAB+XJJTzrDNkt/5p764gzUyCYFHB9fgxwm6D7WphL6mHpPH68XFp2fEQYCRAgQwbCw1T9lX+6w==","signatures":[{"sig":"MEQCIFtzPbh6A4M/HGG4zPSdcPJqJ827fNiCELogEV6J1LUdAiB8fU9V8pxyjXvt96IFK7sHr2cyovwg69AW8+2arOLCYA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8691},"main":"index.js","type":"commonjs","gitHead":"8541e1ebe246731064bdc851e0dfb3e5aaf48da3","scripts":{"test":"echo \"Error: no tests found\" && exit 1"},"_npmUser":{"name":"danielhong35","email":"danielhong35@gmail.com"},"repository":{"url":"git+https://github.com/dhong9/2048-danyo.git","type":"git"},"_npmVersion":"11.2.0","description":"2048 game utility","directories":{},"_nodeVersion":"23.9.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/2048-danyo_1.0.0_1745160108232_0.2630059550987034","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"2048-danyo","version":"1.0.1","description":"2048 game utility","keywords":["2048"],"homepage":"https://github.com/dhong9/2048-danyo#readme","bugs":{"url":"https://github.com/dhong9/2048-danyo/issues"},"repository":{"type":"git","url":"git+https://github.com/dhong9/2048-danyo.git"},"license":"MIT","author":{"name":"Danyo"},"type":"commonjs","main":"index.js","scripts":{"test":"echo \"Error: no tests found\" && exit 1"},"_id":"2048-danyo@1.0.1","gitHead":"d6458eaa9cf0ff9197ec9554a6d92c82919af7cd","_nodeVersion":"23.9.0","_npmVersion":"11.2.0","dist":{"integrity":"sha512-ek3KdmdUNnoNI/Ra0SJzSBBrgoSBS0F+nS9XmOQbJLczmZZZxR6u0hdiIWACbUtJjRnHymIU8Rz3aOnCTQGh8Q==","shasum":"ec691d2149db3d25caa6db10bd942a5ec1f36593","tarball":"https://registry.npmjs.org/2048-danyo/-/2048-danyo-1.0.1.tgz","fileCount":4,"unpackedSize":8683,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCbQNfGMFwrZccbQjn3G6BL3u17S6dFWa9+Osrvyq+LYwIhAM904VkWlVQ5odiUG2n6dDmK+rL4u1rFbGPVE9h80zoX"}]},"_npmUser":{"name":"danielhong35","email":"danielhong35@gmail.com"},"directories":{},"maintainers":[{"name":"danielhong35","email":"danielhong35@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/2048-danyo_1.0.1_1745160214672_0.36932002267933317"},"_hasShrinkwrap":false}},"time":{"created":"2025-04-20T14:41:48.231Z","modified":"2025-04-20T14:43:35.004Z","1.0.0":"2025-04-20T14:41:48.446Z","1.0.1":"2025-04-20T14:43:34.830Z"},"bugs":{"url":"https://github.com/dhong9/2048-danyo/issues"},"author":{"name":"Danyo"},"license":"MIT","homepage":"https://github.com/dhong9/2048-danyo#readme","keywords":["2048"],"repository":{"type":"git","url":"git+https://github.com/dhong9/2048-danyo.git"},"description":"2048 game utility","maintainers":[{"name":"danielhong35","email":"danielhong35@gmail.com"}],"readme":"# 2048 Game Utility\n\nA lightweight and extensible Node.js utility for managing the core logic of the classic 2048 game. This utility includes board initialization, tile spawning, movement logic, and game-over detection - ideal for building 2048 game UIs, simulations, or reinforcement learning environments.\n\n## Installation\n\nYou can install this package using npm:\n\n```sh\nnpm install 2048-danyo\n```\n\n## Usage\n\n### Importing the Module\n\n```js\nconst Twenty48 = require('2048-danyo');\n```\n\n### Creating a Game Instance\n\n```js\nconst game = new Twenty48();\nconsole.log(game.board); // Prints the initial board\n```\n\n### Spawning a tile\n\nSpawns a tile on a random empty square\n\n```js\ngame.spawnTile(game.board, true);\nconsole.log(game.board); // Prints the board after spawning a tile\n```\n\n### Copying a board\n\nReturns a deep copy of the provided board\n\n```js\nconst boardCopy = game.copyBoard(game.board);\nconsole.log(boardCopy); // Prints the copied board\n```\n\n### Rotating a board\n\nRotates a board 90 degrees counter clockwise\n\n```js\nconst rotatedBoard = game.rot90(game.board);\nconsole.log(rotatedBoard); // Prints the rotated board\n```\n\n### Making a move\n\nPerforms a move in the specified direction, where:\n- `L` is left\n- `R` is right\n- `U` is up\n- `D` is down\n\n```js\ngame.makeMove(game.board, 'L');\nconsole.log(game.board) // Prints the board after moving tiles left\n```\n\n### Checking for an empty square\n\nOne of the conditions for the game to still be playable is for it to have at least one empty square.\n\n```js\nconst hasEmptySquare = game.hasEmptySquare(game.board);\nconsole.log(hasEmptySquare); // true or false\n```\n\n### Checking for tiles that can be merged\n\nOne of the conditions for the game to still be playable is for it to have at least one pair of tiles that can be merged.\n\n```js\nconst hasMergableTiles = game.hasMergableTiles(game.board);\nconsole.log(hasMergableTiles); // true or false\n```\n\n### Checking game over status\n\nChecks for any remaining legal moves\n\n```js\nconst isGameOver = game.gameOver(game.board);\nconsole.log(isGameOver); // true or false\n```\n\n### String representation of the game board\n\nReturns a string representation of the current board. Empty cells are shown as `.`.\n\n```js\nconst str = game.toString();\nconsole.log(str);\n```\n\n**Example Output**\n```txt\n2..2\n....\n....\n....\n```\n\n## License\n\nThis project is licensed under the MIT License.","readmeFilename":"README.md"}