{"id":21870625,"url":"https://github.com/matthewstyler/ruby-perlin-2d-map-generator","last_synced_at":"2025-07-26T09:35:21.801Z","repository":{"id":179184201,"uuid":"662836870","full_name":"matthewstyler/ruby-perlin-2D-map-generator","owner":"matthewstyler","description":"Procedurally generate seeded and customizable 2D maps with optional towns and roads, rendered with ansi colours or described in a 2D array of hashes","archived":false,"fork":false,"pushed_at":"2024-03-11T10:07:50.000Z","size":101,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-29T09:48:40.350Z","etag":null,"topics":["astar-algorithm","astar-pathfinding","map-generation","map-generator","perlin","perlin-noise","perlin-noise-algorithm","perlin-noise-generator","perlin-noise-texture","perlin-terrain","poisson-disk-sampling","prims-algorithm","procedural-content-generation","procedural-generation","procedural-terrain","procedurally-generated","ruby-gem","terrain-generation","terrain-generator"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/ruby-perlin-2D-map-generator","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matthewstyler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-06T02:03:43.000Z","updated_at":"2025-05-23T17:00:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"25de95f5-4e67-4e7c-8c34-c925f9bb8b27","html_url":"https://github.com/matthewstyler/ruby-perlin-2D-map-generator","commit_stats":null,"previous_names":["matthewstyler/ruby-perlin-2d-map-generator"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/matthewstyler/ruby-perlin-2D-map-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewstyler%2Fruby-perlin-2D-map-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewstyler%2Fruby-perlin-2D-map-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewstyler%2Fruby-perlin-2D-map-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewstyler%2Fruby-perlin-2D-map-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matthewstyler","download_url":"https://codeload.github.com/matthewstyler/ruby-perlin-2D-map-generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewstyler%2Fruby-perlin-2D-map-generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267145761,"owners_count":24042652,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astar-algorithm","astar-pathfinding","map-generation","map-generator","perlin","perlin-noise","perlin-noise-algorithm","perlin-noise-generator","perlin-noise-texture","perlin-terrain","poisson-disk-sampling","prims-algorithm","procedural-content-generation","procedural-generation","procedural-terrain","procedurally-generated","ruby-gem","terrain-generation","terrain-generator"],"created_at":"2024-11-28T06:12:01.668Z","updated_at":"2025-07-26T09:35:21.770Z","avatar_url":"https://github.com/matthewstyler.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ruby Perlin 2D Map Generator\n\n[![Gem Version](https://badge.fury.io/rb/ruby-perlin-2D-map-generator.svg)](https://badge.fury.io/rb/ruby-perlin-2D-map-generator)\n![CI Status](https://github.com/matthewstyler/ruby-perlin-2D-map-generator/actions/workflows/main.yml/badge.svg)\n![CodeQL](https://github.com/matthewstyler/ruby-perlin-2D-map-generator/workflows/CodeQL/badge.svg)\n\u003ca href=\"https://codeclimate.com/github/matthewstyler/ruby-perlin-2D-map-generator/test_coverage\"\u003e\u003cimg src=\"https://api.codeclimate.com/v1/badges/b99aae29d02b7a8a4cc6/test_coverage\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://codeclimate.com/github/matthewstyler/ruby-perlin-2D-map-generator/maintainability\"\u003e\u003cimg src=\"https://api.codeclimate.com/v1/badges/b99aae29d02b7a8a4cc6/maintainability\" /\u003e\u003c/a\u003e\n[![Downloads](https://img.shields.io/gem/dt/ruby-perlin-2D-map-generator.svg?style=flat)](https://rubygems.org/gems/ruby-perlin-2D-map-generator)\n\nA gem that procedurally generates seeded and customizable 2D map with optional roads and towns using perlin noise.\n\nInclude the gem in your project, or use the executable from the command line.\n\nMap can be rendered in console using ansi colors or returned as 2D array of hashes describing each tile and binome. Completely customizable, use the --help option for full usage details.\n\n\n![2D-maps](https://github.com/matthewstyler/ruby-perlin-2D-map-generator/assets/4560901/6234ebc1-f3bd-48b5-9b78-4d286d2c8d6e)\n\n\n# Installation\n\n### Bundler\n\n```ruby\ngem 'ruby-perlin-2D-map-generator'\n```\n\n### Manual\n\n```sh\ngem install ruby-perlin-2D-map-generator\n```\n\n# Customization examples\n\nSee Command line Usage for full customization, below are some examples. Alter the temperature, moisture or elevation seeds to alter these maps:\n\n- Plains with random terrain evens: `ruby-perlin-2D-map-generator render`\n- Plains with random terrain events and two roads: `ruby-perlin-2D-map-generator render --roads=2`\n- Desert (increase temperature, decrease moisture): `ruby-perlin-2D-map-generator render --temp=100 --moisture=-100`\n- Mountainous with lakes (increase elevation, increase moisture) `ruby-perlin-2D-map-generator render --elevation=25 --moisture=25`\n- Islands (decreaes elevation, increase moisture): `ruby-perlin-2D-map-generator render --elevation=-40 --moisture=25`\n- Taiga map (decrease temperature, increase moisture): `ruby-perlin-2D-map-generator render --temp=-60 --moisture=30 `\n\n## Common customization\n```bash\n--width=int        The width of the generated map (default 128)\n--height=int       The height of the generated map (default 128)\n\n--roads=int        Add this many roads through the map,\n                     starting and ending at edges \n                         (default 0)\n--towns=int        Add this randomly sized towns\n                         (default 0)\n--hs=int           The seed for a terrains height perlin generation\n                         (default 10)\n--ms=int           The seed for a terrains moist perlin generation\n                         (default 300)\n--ts=int           The seed for a terrains temperature perlin generation\n                         (default 3000)\n--rs=int            The seed for generating roads\n                         (default 100)\n\n--elevation=float  Adjust each generated elevation by this percent (-100 -\n                         100) (default 0.0)\n--moisture=float   Adjust each generated moisture by this percent (-100 -\n                         100) (default 0.0)\n--temp=float       Adjust each generated temperature by this percent (-100\n                         - 100) (default 0.0)\n```\n\n## Roads and the heuristic\nRoads can be generated by providing a positive integer to the `roads=` argument. Roads are randomly seeded to begin\nand start at an axis (but not the same axis).\n\nA* pathfinding with a priority queue, along with prim's algorithn and a minimum spanning tree is used to generate the roads. The heuristic uses manhattan distance, and favours existing roads and similar elevations in adjacent tiles. \n\nRoads can be configured to include/exclude generating paths thorugh water, mountains and flora.\n\nTiles containing roads are of type `road`, those without are of type `terrain`. \n\nThe `--roads_to_make` option allows you to specify multiple pairs of coordinates to attempt to build paths, subject to the heuristic and other option constraints. Expects a a single list, but must be sets of 4, example of two roads: `--roads_to_make=0,0,50,50,0,0,75,75`\n\n## Towns\nWith Poisson Disk Sampling, towns can be generated randomly or with a provided x,y coordinate used as a centroid with radius. The result will be tiles that contain `Building` `items`. Buildings in a town are connected by roads, and additionally towns are connected to other towns by roads.\n# Generate without rendering\n\n```irb\nirb(main):001:0\u003e map = Map.new\n```\n\nMap can then be manipulated via traditional x,y lookup\n```irb\nmap[x, y].to_h\n=\u003e\n{:x=\u003e0,                                                        \n :y=\u003e1,                                                        \n :height=\u003e0.29251394359649563,                                 \n :moist=\u003e0.29100678755603004,                                  \n :temp=\u003e0.6034041566100443,                                    \n :biome=\u003e{:name=\u003e\"deep_valley\", :flora_range=\u003e1, :colour=\u003e\"\\e[48;5;47m\"},\n :items=\u003e[]}\n```\nor the less intuitative multidimensional lookup (reversed axis):\n\n```irb\nmap.tiles[y][x].to_h\n=\u003e \n{:x=\u003e0,                                                        \n :y=\u003e1,                                                        \n :height=\u003e0.29251394359649563,                                 \n :moist=\u003e0.29100678755603004,                                  \n :temp=\u003e0.6034041566100443,                                    \n :biome=\u003e{:name=\u003e\"deep_valley\", :flora_range=\u003e1, :colour=\u003e\"\\e[48;5;47m\"},\n :items=\u003e[]}\n```\n\nor from the command line:\n\n```bash\n$ ruby-perlin-2D-map-generator describe coordinates=0,1\n\n{:x=\u003e0,                                                        \n :y=\u003e1,                                                        \n :height=\u003e0.29251394359649563,                                 \n :moist=\u003e0.29100678755603004,                                  \n :temp=\u003e0.6034041566100443,                                    \n :biome=\u003e{:name=\u003e\"deep_valley\", :flora_range=\u003e1, :colour=\u003e\"\\e[48;5;47m\"},\n :items=\u003e[]}\n```\n\n# Full Command line Usage\n```bash\n$ ruby-perlin-2D-map-generator --help\n```\n```bash\nUsage: ruby-perlin-2D-map-generator [OPTIONS] (DESCRIBE | RENDER)\n\nGenerate a seeded customizable procedurally generated 2D map with optional roads.\nRendered in the console  using ansi colours, or described as a 2D array of\nhashes with each tiles information.\n\nArguments:\n  (DESCRIBE | RENDER)  command to run: render prints the map to standard\n                       output using ansi colors. describe prints each tiles\n                       bionome information in the map, can be combined with the\n                       coordinates keyword to print a specific tile.\n                       (permitted: describe, render)\n\nKeywords:\n  COORDINATES=INT_LIST  Used with the describe command, only returns the given\n                        coordinate tile details\n\nOptions:\n      --elevation=float                  Adjust each generated elevation by\n                                         this percent (-100 - 100) (default 0.0)\n      --fhx=float                        The frequency for height generation\n                                         across the x-axis (default 2.5)\n      --fhy=float                        The frequency for height generation\n                                         across the y-axis (default 2.5)\n      --fmx=float                        The frequency for moist generation\n                                         across the x-axis (default 2.5)\n      --fmy=float                        The frequency for moist generation\n                                         across the y-axis (default 2.5)\n      --ftx=float                        The frequency for temp generation\n                                         across the x-axis (default 2.5)\n      --fty=float                        The frequency for temp generation\n                                         across the y-axis (default 2.5)\n      --gf=bool                          Generate flora, significantly affects\n                                         performance\n      --height=int                       The height of the generated map\n                                         (default 128)\n  -h, --help                             Print usage\n      --hs=int                           The seed for a terrains height perlin\n                                         generation (default 10)\n      --moisture=float                   Adjust each generated moisture by\n                                         this percent (-100 - 100) (default 0.0)\n      --ms=int                           The seed for a terrains moist perlin\n                                         generation (default 300)\n      --oh=int                           Octaves for height generation\n                                         (default 3)\n      --om=int                           Octaves for moist generation (default\n                                         3)\n      --ot=int                           Octaves for temp generation (default\n                                         3)\n      --ph=float                         Persistance for height generation\n                                         (default 1.0)\n      --pm=float                         Persistance for moist generation\n                                         (default 1.0)\n      --pt=float                         Persistance for temp generation\n                                         (default 1.0)\n      --road_exclude_flora_path=bool     Controls if roads will run tiles\n                                         containing flora\n      --road_exclude_mountain_path=bool  Controls if roads will run through\n                                         high mountains\n      --road_exclude_water_path=bool     Controls if roads will run through\n                                         water\n      --roads=int                        Add this many roads through the map,\n                                         starting and ending at edges (default\n                                         0)\n      --roads_to_make ints               Attempt to create a road from a start\n                                         and end point (4 integers), can be\n                                         supplied multiple paths \n                                         (default [])\n      --rs=int                           The seed for generating roads\n                                         (default 100)\n      --temp=float                       Adjust each generated temperature by\n                                         this percent (-100 - 100) (default 0.0)\n      --town_seed=int                    The seed for generating towns\n                                         (default 500)\n      --towns=int                        Add this many randomly sized towns\n                                         throughout the map \n                                         (default 0)\n      --towns_to_make ints               Attempt to create a town at given x,y\n                                         coordinate, with z points and v radius\n                                         (4 integers). Can be supplied multiple\n                                         towns. \n                                         (default [])\n      --ts=int                           The seed for a terrains temperature\n                                         perlin generation (default 3000)\n      --width=int                        The width of the generated map\n                                         (default 128)\n\nExamples:\n  Render with defaults\n    $ ruby-perlin-2D-map-generator render\n\n  Render with options\n    $ ruby-perlin-2D-map-generator render --elevation=-40 --moisture=25 --hs=1\n  \n  Render with roads\n    $ ruby-perlin-2D-map-generator render --roads=2\n  \n  Render with 5 roads, 1 provided road, 10 random towns and 1 provided town\n    $ ruby-perlin-2D-map-generator render --roads=5 --roads_to_make=0,0,50,50 --towns=10 --towns_to_make=5,5,10,3\n\n  Describe tile [1, 1]\n    $ ruby-perlin-2D-map-generator describe coordinates=1,1\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewstyler%2Fruby-perlin-2d-map-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthewstyler%2Fruby-perlin-2d-map-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewstyler%2Fruby-perlin-2d-map-generator/lists"}