Code Monkey home page Code Monkey logo

karta's Introduction

Karta

Just playing around with Voronoi diagrams.

GoDoc

Karta progress 012

The goal is to create something similar to what is described in the article Polygonal Map Generation for Games

Installation

# Basic command line tool
go install github.com/peterhellberg/karta/cmd/karta@latest

# A web server generating maps based on query parameters
go install github.com/peterhellberg/karta/cmd/karta-server@latest

Development

I spend most of my time in iTerm 2 and this project is no different.

This is how I preview the map in a split pane:

rerun -p "**/*.go" -c -x -b -- \
"go run cmd/karta/main.go -width 55 -height 55 && aimg -w 55 karta.png"

Karta development

Usage

The project includes two binaries karta and karta-server, the latter serving both PNG and JPEG.

Command line arguments

Usage of karta:
  -count=2048: The number of sites in the voronoi diagram
  -height=512: The height of the map in pixels
  -iterations=1: The number of iterations of Lloyd's algorithm to run (max 16)
  -output="karta.png": Output filename
  -seed=3: The starting seed for the map generator
  -show=false: Show generated map using Preview.app
  -width=512: The width of the map in pixels

Query string parameters

  • s - size
  • w - width
  • h - height
  • c - count
  • i - iterations

Progress

First i just plotted out random dots:

Karta progress 001

Then drew a voroni diagram:

Karta progress 002

Found the centroids:

Karta progress 003

Ran the diagram through Lloyd's algorithm:

Karta progress 004

A few iterations later:

Karta progress 005

Animating 0-16 iterations:

Lloyd Relaxation 0-16 iterations

Started coloring the map according to the distance from the center:

Karta progress 006

Added some randomness:

Karta progress 007

Added a different types of elevation:

Karta progress 008

Removed the centroid markers:

Karta progress 009

Started working on using Simplex noise for island shape and elevation:

Karta progress 010

Elevation based on noise + distance from center of map:

Karta progress 011

Tweaked noise and yellow beaches:

Karta progress 012

License

The MIT License (MIT)

Copyright (C) 2014 Peter Hellberg

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

karta's People

Contributors

peterhellberg avatar stanim 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

karta's Issues

fatal: repository 'https://bitbucket.org/s_l_teichmann/simplexnoise/' not found

Thanks for this wonderful project. I get an error. Could you help solve the problem?

go install github.com/peterhellberg/karta/cmd/karta@latest

go: finding module for package github.com/pzsz/voronoi
go: finding module for package bitbucket.org/s_l_teichmann/simplexnoise
go: finding module for package github.com/pzsz/voronoi/utils
go: finding module for package github.com/llgcode/draw2d/draw2dimg
go: found github.com/llgcode/draw2d/draw2dimg in github.com/llgcode/draw2d v0.0.0-20210904075650-80aa0a2a901d
go: found github.com/pzsz/voronoi in github.com/pzsz/voronoi v0.0.0-20130609164533-4314be88c79f
go: found github.com/pzsz/voronoi/utils in github.com/pzsz/voronoi v0.0.0-20130609164533-4314be88c79f
go: finding module for package bitbucket.org/s_l_teichmann/simplexnoise
../../go/pkg/mod/github.com/peterhellberg/[email protected]/noise/noise.go:3:8: cannot find module providing package bitbucket.org/s_l_teichmann/simplexnoise: module bitbucket.org/s_l_teichmann/simplexnoise: git ls-remote -q origin in /Users/dimir/go/pkg/mod/cache/vcs/2b6156a231bb81581fe42a1b84979a1c525744be6d29826c2b9adf2fabd377d8: exit status 128:
remote: You may not have access to this repository or it no longer exists in this workspace. If you think this repository exists and you have access, make sure you are authenticated.
fatal: repository 'https://bitbucket.org/s_l_teichmann/simplexnoise/' not found

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.