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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
MaxGamz
Party member
Posts: 100
Joined: Fri Oct 28, 2022 3:09 am

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

Post 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 28 times
Last edited by MaxGamz on Sat Sep 09, 2023 1:39 am, edited 1 time in total.
MaxGamz
Party member
Posts: 100
Joined: Fri Oct 28, 2022 3:09 am

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

Post 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
User avatar
keharriso
Citizen
Posts: 98
Joined: Fri Nov 16, 2012 9:34 pm

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

Post 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!
LÖVE-Nuklear - a lightweight immediate mode GUI for LÖVE games
MaxGamz
Party member
Posts: 100
Joined: Fri Oct 28, 2022 3:09 am

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

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 56 guests