Giter Club home page Giter Club logo

piratemap's Introduction

Pirate Maps

Procedurally generated pirate treasure maps. X marks the spot!

Example

Dependencies

I used several excellent third party libraries...

  • cairo for rendering
  • colour for color interpolation
  • noise for simplex noise
  • Pillow for saving debug images of noise layers
  • pyhull for delaunay triangulation
  • Shapely for all kinds of 2D geometry operations

How to Run

The script will generate several random maps and save them as PNG files.

git clone https://github.com/fogleman/PirateMap.git
cd PirateMap
pip install -r requirements.txt
python main.py

How it Works

It took me a while to decide on an approach for generating the land masses. I didn't want to just generate some simplex noise, threshold it and render it. I wanted to actually compute a polygonal shape that I could do further operations on. So here's how that works...

  • generate a layer of simplex noise with several octaves, with decreasing values as the edge of the image is approached
  • fill the screen with randomly positioned points evenly spaced using the poisson disc algorithm
  • filter the poisson points to those where the corresponding noise value is above some threshold
  • take these points and compute a "concave" hull or alpha shape with them

Shapely's buffer function is used heavily for padding or cleaning up shapes.

I also wrote an xkcdify function to add some perturbations to some of the polygons, namely the different water color gradations.

piratemap's People

Contributors

fogleman avatar jaredhalpern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

piratemap's Issues

Cannot build on linux

Here is the output of: pip install -r requirements.txt

Collecting Shapely==1.5.13 (from -r requirements.txt (line 1))
  Using cached Shapely-1.5.13.tar.gz
    Complete output from command python setup.py egg_info:
    Failed `CDLL(libgeos_c.so.1)`
    Failed `CDLL(libgeos_c.so)`
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-build-o2tamrn1/Shapely/setup.py", line 38, in <module>
        from shapely._buildcfg import geos_version_string, geos_version, \
      File "/tmp/pip-build-o2tamrn1/Shapely/shapely/_buildcfg.py", line 167, in <module>
        fallbacks=['libgeos_c.so.1', 'libgeos_c.so'])
      File "/tmp/pip-build-o2tamrn1/Shapely/shapely/_buildcfg.py", line 161, in load_dll
        libname, fallbacks or []))
    OSError: Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so']

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-o2tamrn1/Shapely

I fixed it by installing libgeos-dev manually.

Although, the fault is not your's, It would be good if you could add this step in build instructions -

sudo apt-get install libgeos-dev

Also does it only run on python 2.7?

Building fails on Windows

pip install -r requirements.txt

Collecting Shapely==1.5.13 (from -r requirements.txt (line 1))
  Using cached Shapely-1.5.13.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "<redacted>\AppData\Local\Temp\pip-build-1s6hmccw\Shapely\setup.py", line 38, in <module>
        from shapely._buildcfg import geos_version_string, geos_version, \
      File "<redacted>\appdata\local\temp\pip-build-1s6hmccw\shapely\shapely\_buildcfg.py", line 200, in <module>
        lgeos = CDLL("geos.dll")
      File "c:\python352\lib\ctypes\__init__.py", line 347, in __init__
        self._handle = _dlopen(self._name, mode)
    OSError: [WinError 126] The specified module could not be found

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in <redacted>\AppData\Local\Temp\pip-build-1s6hmccw\Shapely\

Specify that it needs Python2 and not 3

Hi!
I love that project, it's really fun and neat! โ˜ ๏ธ โš”๏ธ !

Could you specify, both on the main.py shebang and on the README.md file, that the project runs on Python2 ?

Also, Pillow could be removed from the requirements (and the lines #39,40 of layers.py commented) as it is only needed for debugging.
(I failed to pip install the requirements on a virtualenv only because of a Pillow-related bug)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.