buckinha / diamondsquare Goto Github PK
View Code? Open in Web Editor NEWA python implementation of a diamond-square algorithm
License: MIT License
A python implementation of a diamond-square algorithm
License: MIT License
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.
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.
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.
Aiming at making this easier to install, so clearly it needs to have some setup.py goodness and so on.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.