Mindwerks / worldengine

World generator using simulation of plates, rain shadow, erosion, etc.
MIT License
981 stars 127 forks source link

Possible bug in rivers algorithm #219

Open ftomassetti opened 8 years ago

ftomassetti commented 8 years ago

Lines 385-390 of worldengine/simulations/erosion.py

                    newElevation = world.layers['elevation'].data[y, x] + (
                        diff * curve)
                    if newElevation <= world.layers['elevation'].data[ry, rx]:
                        print('newElevation is <= than river, fix me...')
                        newElevation = world.layers['elevation'].data[r, x]
                    world.layers['elevation'].data[y, x] = newElevation

I think that world.layers['elevation'].data[r, x] is wrong. It should be instead orld.layers['elevation'].data[ry, rx]. Am I missing something?

psi29a commented 8 years ago

You can always link to the line of code instead: https://github.com/Mindwerks/worldengine/blob/master/worldengine/simulations/erosion.py#L390

                   if newElevation <= world.layers['elevation'].data[ry, rx]:
                        print('newElevation is <= than river, fix me...')
                        newElevation = world.layers['elevation'].data[r, x]

^-- I put that in there to catch issues newElevation being lower than current elevation (it mustn't be lower than the river itself) so we reset it back to the original value. However, this could be 'dead' code and is never run. Might have just been lucky.

There are a few things in that code that don't make sense... right now (page miss!). Like line: https://github.com/Mindwerks/worldengine/blob/master/worldengine/simulations/erosion.py#L371 I'll give it an eye-over.