Infinite generation

Hi everyone,

I’m working on a project and need some help with generating an infinitely repeating set of random points. Here’s what I’m trying to achieve:

Start at the point (0,0).
Trigger an arrow event (e.g., pressing a button).
Keep the initial point at (0,0) and add a new point at a random location.
Store all generated points in a list.
Repeat the process infinitely.

I’m using this to make a procedurally generating room

Thanks in advance for your help!

Here is one approach, using the action button to capture a randomized values for x and y generated in the graph, and then sinking the history of those values as lists back in the graph.

I wasn’t sure if you mean having it continue the process with clicks or by itself. I made a second screen that shows how you can use a ticker and actions to have it repeat the process by itself.

Let me know if you have questions about either approach.

Yes this does help, thank you very much, could you explain how the first approach works, since i believe i tried a simular approach and it didn’t work for me. I’m confused about what the S_eed variable is for and what [-10,…,10].random(1,S_eed)[1], i understand [-10,…,10] is all whole numbers from -10->10, but i don’t understand why you have .random, aswell as what the [1] is. my guess is its for how many variables you want.

I’ve been working with your second iteration since you provided the update command, and now I’m attempting to make it choose either to change X or Y and keep the other the same, randomly, and have it move by one, ie, press the button it changes X from it adds a point at (1,0), then I press it again and it changes Y and it adds a point at (1,-1), my attempts so far have given me feed back loops when trying to allow it to add or subtract one from the restrictions

Is there any way to make it not repeat i solved my previous problem but now when i run it, it just makes a blob, and runs around in itself and doesn’t add any new points

I added in a 3rd screen which I think does what you are asking for.

The randomizer I am using works like this:

[-10…10] creates a list of integers from -10 to 10. This list can be any list of values you want to use. When you use .random(n, seed), it will pick a set of n values from the list. The seed value is the random seed that the randomizer function uses. The value of seed is unimportant, but what is important is that when you change the seed value, the randomizer rerolls. So in the CL, the seed is determined by the action button’s pressCount. So every time the button is pressed, the seed changes, which causes new values to be generated.

When I use .random(1, seed), it is creating a list of 1 element. Since we want to use that value as a number and not a list element, we use the notation that access a value from a list, in this case [1].

As a different example, say I used [1…10].random(5, seed)[3]. That would pick 5 random elements from the set 1 to 10, and then return the 3rd one picked. If I just did [1…10].random(5, seed), that would return a list of the 5 elements.

So whichVar = [0,1].random(1,seed)[1] will create a list of 1 element picked from the set [0,1], and return the first value of that list. Thus this is like flipping a coin.

In the third screen I added in a conditional, which is of the form {condition: value if true, value if false}.

So the new x coordinate is formed liked this:

P (list of all points so far)
P.x (list x-coordinates of P)
P.x[length(P)] (accesses the last element of the list)
P.x[length(P)] + {whichVar = 0: randVal, 0} (if 0 was selected, add the random value, otherwise add 0).

The newX and newY values are then captured by the button click. Captures fire every time the button is clicked. The history source of a button returns a list of all the captured values. So in the graph component, I am sinking the entire list (using history) into the Xlist and Ylist variables which are then plotted.

I hope that helps explain it! Let me know if you have more questions.

1 Like

I got that far in my lates graph, and the explanation helps a ton thank you. However for my project, I would preferably want it to be more efficient with placing points, as of right now it overlaps itself ~75% of the time. I was looking into ways of having now repeats, but all i found was using Shuffle of points so you don’t get repeats, but i couldn’t figure out a way to use it in my current graph. if that is something that can be fixed that would be great, however that’s not my priority right now. I’ve done something like this in the past with randomly generating mazes. and it was very inefficient, but it had randomly rotating ‘walls’ in an 8x8 grid to make it, I wanted to see if i could do a slightly more advanced interpretation of that and have it function so that it creates an outline around the points 0.5 spaces out, ie. if we only had point (0,0), then we would have a square around the point with (0.5,0.5), etc, do you have any idea how to do that?

I added a 4th screen that works differently. It got a bit messy, but basically it looks for all the points around the last point in the list that are not currently in the list, and then picks one of those at random. (If all are in the list, it moves 2 spaces right and starts again).

Making an outline is trickier and I need to think about that. I made it create a square around each point, and that is easy enough. But if you want to remove all of the interior lines to just have the outline it will need some more thought.

I also added a 5th screen that limits the movement to vertical and horizontal, and then I have it stop if it has no available move (if it circles back into itself or hits the borders). I wasn’t sure on the exact behavior you are looking for but hopefully this gives some ideas of how it can be done.

1 Like

Yes, this is so helpful thank you very much, Daniel.
I was thinking, for outline detection, and or further room customization, I don’t know if this is even possible, but we could try and detect any points to the sides/in front/behind and remove that part of the polygon, or we could change from using a polygon, to four separate equations that will act as the walls of each direction, do you know how possible that would be? or if you have any other ideas I could see if i could try and implement them into my current graph.

Im very confused on some of the variables and on how they work, do you think you could explain some of the new added variables? thank you

basically anything with the f(x) format and how does x,y stuff work, its kinda way over my head.

Also would you like to see the other parts i have made for the dungeon crawler, I have made the random loot, walking character, health, loot usage ie gold, swords, etc. and am working on making enemy spawning with pathfinding.

Sure, I’d like to see that. I had an idea about how to do the outline only - check out the last screen now. I don’t have more time now but later tonight I will go through and try to clean it a bit as well as explain what is going on.

1 Like

Okay give me a second Im trying to understand this guys Pathfinding algorithm and implement it into an AI

this is the Pathfinding bot im using to aid me in the Enemy.

Heres is a running animation I might use for the dude

Here is Treasure chest generation, to be honest, I’ve almost forgotten how I made it, but I think most of it is self-explanatory, other than some of the randomly named variables.

Finals Here is the “Main” build, its the walking dude, with a joystick

Hi,Your project and approach are really impressive! :star2: The steps and code you’ve shared show great creative thinking and problem-solving skills. Keep up the fantastic work! :clap: