lundi 12 août 2019

Parenthesis Position Changes Result of Noise Generation With OpenSimplex

This isn't really as much of a problem as it is me trying to figure out why my code is working a certain way. Basically, I am trying to make a 2d randomized grid using OpenSimplex. Certain value ranges are assigned to certain cells to make 'biomes' and small clumps of resources.

Originally, when I tried using randomized generation to make clumps of resources, I would get the resources to generate in the outline of a circle instead of a clump.

Here is a picture (black is the resource in question): https://gyazo.com/76a863b5389e9f4e36bee57c10a91cbd

So, I decided to try the math function tan, just to see if that would work. It doesn't work on its own, but I made a mistake and placed the closing parenthesis in the wrong place.

Here is a picture of the result: https://gyazo.com/07b073bf43944e8b10bd058cdefd88d3

if math.tan(grid[row][column]['type']) <= -.8 and math.tan(grid[row][column]['type'] >= -.85):
    color = black

'grid' is the list of all of the cells, 'row' is what row the cell is in, and 'column' is what column the cell is in. This is inside a for loop that goes through every single cell and determines its value, ['type'] (assigned by OpenSimplex) and assigns it a color.

My question is, why does the code create clumps of resources when the parenthesis is misplaced like above (the math.tan parenthesis extend to the operator), but doesn't work properly when the parenthesis is placed like below?

if math.tan(grid[row][column]['type']) <= -.8 and math.tan(grid[row][column]['type']) >= -.85:
    color = black

I tried changing the parenthesis position on the first condition of the if statement, and it doesn't affect anything.

Aucun commentaire:

Enregistrer un commentaire