Coder Social home page Coder Social logo

diamondsquare's People

Contributors

buckinha 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

Watchers

 avatar  avatar

diamondsquare's Issues

Unrealistic images

Hello. I use the plotly module to easily create 3d visualizations of the resulting images. And when using your code, I noticed such a feature that virtually every created landscape necessarily has very unrealistic maximum and minimum points.
You can check this for yourself by running the provided code snippet.

from hkb_diamondsquare import DiamondSquare
import numpy as np
import plotly.graph_objects as go

def show_terrain(terrain_array):
    fig = go.Figure(data=[go.Surface(z=terrain_array)])
    fig.update_layout(
        title="Terrain Visualization",
        autosize=True,
        scene=dict(
            zaxis=dict(range=[np.min(terrain_array), np.max(terrain_array)]), aspectratio=dict(x=1, y=1, z=0.5)
        ),
    )
    fig.show()

map = DiamondSquare.diamond_square(shape=(250, 250), min_height=0, max_height=5, roughness=0.35)
show_terrain(map)

It feels like there is some kind of flaw in the algorithm. I'm pretty sure this problem is not related to rendering issues. But this code in its current form is very poorly applicable for real use.
I understand that the repository is already quite old, but I poorly understand the operation (or rather the implementation) of the presented algorithm, so I cannot say what exactly the problem is.
I would be grateful for any comments.

image

Square-step efficiency

The "square step" is not being done as efficiently as possible. Namely, A grid of 2n points are being checked for each n points that need to be changed, so half of those that are iterated over are just being skipped.

Python 3

Thanks for the implementation, this is very useful. If you would change some of the '/' to '//' to make them integer division, the code would also work for Python 3.

Needs setup.py

Aiming at making this easier to install, so clearly it needs to have some setup.py goodness and so on.

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.