{"_id":"@alex-c/map-generator","_rev":"1-eb71c54f8225e51f6f93a28f14b65e59","name":"@alex-c/map-generator","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@alex-c/map-generator","version":"0.1.0","description":"Generates dungeon-like 2d maps of connected spaces using either random walk or procedural generation from a seed.","main":"index.js","types":"index.d.ts","scripts":{"test":"node node_modules/jasmine/bin/jasmine.js --config=spec/support/jasmine.json"},"repository":{"type":"git","url":"git+https://github.com/alex-c/map-generator.git"},"keywords":["map-generation","map-generator","2d","2d-map","dungeon-generator","dungeon","random-walk","random-generation","procedural-generation"],"author":{"name":"Alexandre Charoy"},"license":"Apache-2.0","bugs":{"url":"https://github.com/alex-c/map-generator/issues"},"homepage":"https://github.com/alex-c/map-generator#readme","devDependencies":{"jasmine":"^3.4.0"},"dependencies":{"seedrandom":"^3.0.3"},"gitHead":"9fbf2046bcae84c8406c2ade9b82a109d20266c8","_id":"@alex-c/map-generator@0.1.0","_nodeVersion":"12.7.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-+PumUwWVdcCaJPAqoBxdXHdGrCsVf51EkPxjQNGWGGiHn05D2panuH3B8ASUFXTqmjJfBru6r/GhiIgMrs7yYA==","shasum":"2cd8eb7d6ce077fb3df8ff6103426fe90358114c","tarball":"https://registry.npmjs.org/@alex-c/map-generator/-/map-generator-0.1.0.tgz","fileCount":7,"unpackedSize":20169,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdYuKMCRA9TVsSAnZWagAAahsP/AkYQB5bxKKLvbx2GqUO\nMobacMRWD/knBjH6gbg46954b0oDL2+FVYBVk98VKiGEwjSSI/R3dvPo8ERx\nuqJ7mDuzGmt+bR+IjdWJwmr7yUoccriDXeSgRGdoeknUk9WAcM50BOik5TYO\nyLAUR72q71gebPF118EXuxrBt5YBviaSbPqP/OSUMW3sBu2L6+tguZbos9Vt\n9rs9+1wWH6c94vCr6hs3PkMx2Eoi5vs29ocQtX6WMBZC3TI6hQQQJNaQ9D/i\nXBv1tPNKkpDLA8ugI/V545Peb+medoie6asra0mceNyLhZ4R6Zo2Z4Cqrc90\nxhHVrC2jLOCuv6+SRWZMlof5/jBO69YbqeBNwHCmLdPYDhtK8+buikFYfo2S\n8nQ+qyZWGB5NhM87UE2Nukk9iwc5RrmSTJ+3ZgVFT+pT6osDeFhNDw3HlLJF\n7oosYKJ5hjGuAO3UZD1hLXjpC5u1xWasOTbdYb+w1p4TkvxmHKliYopB098B\nruknisvclARd18FuHSz+Fkz6hZz2lwyykYm44RnH+IQxOFjlI6b9oYP//5MK\ni7w32xmAxnQA3bc8zO++gWXKqjfTPC8ik5lmMJML+G1HHQUGuWpcKnLjamR4\n/r38mFiG4HCdtMNg3te2capu8SDRE6/NlLWgVbNZDDWpiQ/kgW8TvtOr/jXO\ngffw\r\n=R8CQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDjqpZPUXsCMqA8iNK5M8GMeB89LQNqz/rINw2zZab8VAIhANJv9geoy8DanJQ5ZdwaIVqyjmOVpNQ3lF6wxaI6itfv"}]},"maintainers":[{"name":"alex-c","email":"alexandre.charoy@gmail.com"}],"_npmUser":{"name":"alex-c","email":"alexandre.charoy@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/map-generator_0.1.0_1566761612224_0.15685346847438542"},"_hasShrinkwrap":false}},"time":{"created":"2019-08-25T19:33:32.011Z","0.1.0":"2019-08-25T19:33:32.364Z","modified":"2022-04-04T12:38:20.114Z"},"maintainers":[{"name":"alex-c","email":"alexandre.charoy@gmail.com"}],"description":"Generates dungeon-like 2d maps of connected spaces using either random walk or procedural generation from a seed.","homepage":"https://github.com/alex-c/map-generator#readme","keywords":["map-generation","map-generator","2d","2d-map","dungeon-generator","dungeon","random-walk","random-generation","procedural-generation"],"repository":{"type":"git","url":"git+https://github.com/alex-c/map-generator.git"},"author":{"name":"Alexandre Charoy"},"bugs":{"url":"https://github.com/alex-c/map-generator/issues"},"license":"Apache-2.0","readme":"# map-generator\r\n\r\n`map-generator` generates dungeon-like 2d maps of connected spaces using either random walk or procedural generation from a seed. Maps are generated as arrays of number arrays, in which 0 means there is no path/room at the given coordinates, and 1 means that there is.\r\n\r\nExample output:\r\n\r\n```javascript\r\nmap =[[0, 0, 0, 0, 1],\r\n      [0, 0, 0, 0, 1],\r\n      [0, 1, 1, 0, 1],\r\n      [0, 0, 1, 1, 1],\r\n      [0, 0, 0, 0, 0]]\r\n```\r\n\r\nAccessing a map location at coordinates (x, y) is done with `map[y][x]`. With the (0, 0) coordinate at the bottom left, the map above represents the following map:\r\n\r\n```javascript\r\n    +---+---+---+---+---+\r\ny=4 | 0 | 0 | 0 | 0 | 0 |\r\n    +---+---+---+---+---+\r\n    | 0 | 0 | 1 | 1 | 1 |\r\n    +---+---+---+---+---+\r\n    | 0 | 1 | 1 | 0 | 1 |\r\n    +---+---+---+---+---+\r\n    | 0 | 0 | 0 | 0 | 1 |\r\n    +---+---+---+---+---+\r\ny=0 | 0 | 0 | 0 | 0 | 1 |\r\n    +---+---+---+---+---+\r\n     x=0             x=4\r\n```\r\n\r\n## Installation\r\n\r\nInstall with `npm`: `npm install --save @alex-c/map-generator`.\r\n\r\n## Usage\r\n\r\nThe package exposes a `MapGenerator` class.\r\n\r\n```javascript\r\n// Import package\r\nconst MapGenerator = require('@alex-c/map-generator');\r\n\r\n// Instantiate a generator\r\nconst generator = new MapGenerator();\r\n```\r\n\r\nCall the `generateMap` method to generate maps.\r\n\r\n```javascript\r\n// Generate a random map with default parameters\r\nconst map1 = generator.generateMap();\r\n\r\n// Generate a map from a seed\r\nconst map2 = generator.generateMap({\r\n  seed: 'my-awesome-seed'\r\n});\r\n```\r\n\r\n### Map generation parameters\r\n\r\nThe following map generation parameters are available:\r\n\r\n```javascript\r\n// Generate a map with custom parameters\r\nconst map = generator.generateMap({\r\n    numberOfPaths: 10,           // Number of paths to draw\r\n    minPathLength: 1,            // Minimal length of a path\r\n    maxPathLength: 5,            // Maximal length of a path\r\n    maxWidth: 24,                // Maximum width of the map - x index will go from 0 to 23\r\n    maxHeight: 18,               // Maximum height of the map - y index will go from 0 to 17\r\n    startPosition: {x: 0, y: 0}  // Position at which to start drawint paths\r\n    seed: 'some-other-seed'      // Seed for procedural generation\r\n});\r\n```\r\n\r\nMaps generated with a given seed and the same parameters will always produce the same map!\r\n\r\n## Other methods\r\n\r\nOther `MapGenerator` methods that are used internally but are also exposed:\r\n\r\n- `generateEmptyMap(width: number, height: number): number[][]`: Generates an empty map of dimensions `width*height`.\r\n- `step(x: number, y: number, direction: number[]): number[]`: Returns new coordinates from the given coordinates by stepping to the left (`[-1, 0]`), right (`[1, 0]`), up (`[0, 1]`) or down (`[0, -1]`).\r\n- `validatePosition(map: number[][], x: number, y: number): boolean`: Returns whether a given position is within the bounds of the map.","readmeFilename":"README.md"}