You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Needs to be in roadmap submodule as flooded areas have to set the population density to 0.
roadmap/config_functions before or after roadmap/config_functions/setup_heightmap would be a good place.
Before caring about a GUI we need:
A function flood which floods the heightmap when water is added at a certain height. It could look something like this:
def flood(heightmap, pos, h):
"""
pos is a pair of indices on heightmap (position where it gets flooded)
h is the corresponding height
"""
flooded=np.zeros(heightmap.shape)
stencil=np.array([
[-1,0],
[1,0],
[0,1],
[0,-1]
])
front=[pos]
while len(front)>0:
new_front=[]
for x in front:
if heightmap[x]<h:
flooded[x]=True
new_front.extend(
[new for new in x+stencil if not flooded[new] and not np.any(x<0) and not x[0]>heightmap.shape[0] and not x[1]>heightmap.shape[1]]
)
front=new_front
return flooded
This is called every time the user wants to flood. When supplying a water image, this method has to be called until every flooded pixel was returned by flood() at least once.
We then need a function that finds bodies of land. If there is only one body of land (we have an ocean or something) then there is exactly one body of land. If we have e.g. a river seperating our land masses, then we need bridges. A draft for this function can be found in roadmap/config_functions/seperate
No description provided.
The text was updated successfully, but these errors were encountered: