Page 1 of 1

[SOLVED] I tried writing a procedural generation algorithm but it doesn't seem to be working and I'm not sure why

Posted: Fri Sep 08, 2023 10:19 pm
by MaxGamz
I based my code off of a video I saw in which a guy does the same thing I'm trying to do but in unity. Even though the code was simple and easy to understand. I wasn't able to get it working in love. It is basically meant go check if the tiles around each tiles are empty (0) or walls (1) and if walls are greater than 4 it becomes a wall tile but if it's less than 4 it turns into an empty tile. However when I loop over the algorithm, nothing happens. It's just noise.
map.love
(621 Bytes) Downloaded 60 times

Re: I tried writing a procedural generation algorithm but it doesn't seem to be working and I'm not sure why

Posted: Fri Sep 08, 2023 10:26 pm
by MaxGamz
MaxGamz wrote: Fri Sep 08, 2023 10:19 pm I based my code off of a video I saw in which a guy does the same thing I'm trying to do but in unity. Even though the code was simple and easy to understand. I wasn't able to get it working in love. It is basically meant go check if the tiles around each tiles are empty (0) or walls (1) and if walls are greater than 4 it becomes a wall tile but if it's less than 4 it turns into an empty tile. However when I loop over the algorithm, nothing happens. It's just noise.

map.love
Edit, I commented out the part of the code that smooths the map, keep in mind even if left as is (without comments) it still doesn't work

Re: I tried writing a procedural generation algorithm but it doesn't seem to be working and I'm not sure why

Posted: Fri Sep 08, 2023 11:48 pm
by keharriso
Look at your getBorderCount function:

Code: Select all

wallCount = wallCount + map[gridX][gridY]
should be:

Code: Select all

wallCount = wallCount + map[a][b]
That way, your smooth function actually works!

Re: I tried writing a procedural generation algorithm but it doesn't seem to be working and I'm not sure why

Posted: Sat Sep 09, 2023 1:26 am
by MaxGamz
keharriso wrote: Fri Sep 08, 2023 11:48 pm Look at your getBorderCount function:

Code: Select all

wallCount = wallCount + map[gridX][gridY]
should be:

Code: Select all

wallCount = wallCount + map[a][b]
That way, your smooth function actually works!
Oh my God that actually worked! I can't thank you enough. Only thing I need to figure out is how but at least I got something working