Git Product home page Git Product logo

isingfantasymapgenerator's Introduction

repository_cover

Introduction

Ising Fantasy Map Generator is a C++ code for the procedural generation of fantasy world maps.

repository_cover

The algorithm generates sea/terrain patterns using a 2D spin-lattice whose dynamic is regulated by the Ising Hamiltonian. The lattice undergoes an annealing procedure that takes the system below its critical temperature, where macroscopic correlations are still present at a large scale.

A height map is generated starting from these sea/terrain patterns by using the distance from the "coastline." Finally, trees, mountains, and rivers are generated using the height map.

Note

The code can be upgraded by adding cities and roads within them. Moreover, noise functions can be used, which will help avoid the uniformity often associated with distance-from-coastline-based approaches, as can be seen in the image generated so far by this code.

A detailed description of the whole procedure can be found here.

Installation

The only required dependencies are SDL2 and CMake.

Linux

On Linux, you should be able to compile the code using the provided CMakeLists.txt.

Create a build directory inside the repository one as follow:

mkdir build && cd build

and then run cmake and make:

cmake ..
make

Usage

To initiate the program, the lattice dimension and the desired number of generated images must be provided as command-line arguments.

./IsingFantasyMapGenerator --lattice-size <L> --num-generated-images <N>

or:

./IsingFantasyMapGenerator -L <L> -N <N>

Warning

The image on the cover was generated using the number of iterations that you can find hardcoded in the main.cpp file with a lattice size of dimension 500. However, the number of iterations to get a pleasing result depends on the lattice size and must be tuned. Using too many iterations below critical temperature will yield a sea-only map.

output example:

 ___     _                _____           _                          
|_ _|___(_)_ __   __ _   |  ___|_ _ _ __ | |_ __ _ ___ _   _         
| |/ __| | '_ \ / _`  |  | |_ / _` | '_ \| __/ _` / __| | | |        
| |\__ \ | | | | (_|  |  |  _| (_| | | | | || (_| \__ \ |_| |        
|___|___/_|_| |_|\__, |  |_|  \__,_|_| |_|\__\__,_|___/\__, |        
                  |___/                                 |___/         
 __  __                ____                           _             
|  \/  | __ _ _ __    / ___| ___ _ __   ___ _ __ __ _| |_ ___  _ __ 
| |\/| |/ _` | '_ \  | |  _ / _ \ '_ \ / _ \ '__/ _` | __/ _ \| '__|
| |  | | (_| | |_) | | |_| |  __/ | | |  __/ | | (_| | || (_) | |   
|_|  |_|\__,_| .__/   \____|\___|_| |_|\___|_|  \__,_|\__\___/|_|   
             |_|                                                    

-------------------------------------------------------------------------------- 
version : 1.0
--------------------------------------------------------------------------------                       
    

Starting annealing procedure for map #1
[========================================] 100% 
Freezing the lattice: 
[========================================] 100% 
Generating heightmap from spin lattice:
[========================================] 100% 
Generating rivers . . .
Generating mountains . . .
Generating trees . . .
Rendering the map . . .
Map saved into /home/mors/Documents/IsingFantasyMapGenerator/build/map1.bmp

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.