Problems randomly generating tiles in sequence

Get help using Construct 2

Post » Sat Apr 29, 2017 9:19 pm

Heya guys,

I'm having some problems randomly generating sprites.

The goal of the event system is to populate the layout with randomly generated square sprites which represent rooms with doors on either side.

The array "RoomFormation" represents the population of possible room combinations. Green sides represent doors where the object is named after the orientation of the doors (t=top, r=right, b=bottom, l=left).
The size of "RoomFormation" is 16x5 where there are 16 different sprite objects (x-axis), the name of the sprite object (y-axis=0), and the possible relative locations where the sprite can be placed (x.1, x.2, x.3, x.4 where the 1 refers to placement in the north, 2 is east, 3 is south, and 4 is west; i.e a "1.3 means a 't' tile placed in the south.)

Theory:
The function "TileRoll" goes through a process of scanning the "Grid" array for previously placed tiles and eliminates (zeroes the value) incompatible tile objects from "TilePool" (a copy of "RoomFormation"), then it draws a random value from "TileLottery" (a contracted "TilePool" array containing no zero values), from the randomly chosen value a tile is placed in the appropriate location.
[[The "TileRoll" function is made in such a way to prevent 3-way intersections from occuring randomly]]

Problem:
Randomly, the process halts before MaxRoom tiles are placed.

In the time being I've added the highlighted condition in Event2-3 to restart if the process fails, however this is not something I want to keep in.

Image

Screenshot examples of successful and failure layout generation:

http://imgur.com/a/5Wyv3

Cap file itself:

https://www.dropbox.com/s/u1zjtvg31mbp2 ... .capx?dl=0
B
10
S
2
G
2
Posts: 87
Reputation: 1,274

Post » Sun Apr 30, 2017 5:14 pm

How exactly do you determine which sides have doors?
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822

Post » Tue May 02, 2017 10:34 pm

gumshoe2029 wrote:How exactly do you determine which sides have doors?


The sprites for each room have green sides to represent a door or doors and are named appropriately.

For example:
Image

That sprite is named 'tr' to show that it has a door on the top and right.
B
10
S
2
G
2
Posts: 87
Reputation: 1,274

Post » Wed May 03, 2017 7:28 pm

So how to you check the nearby tiles to see if their doors match up?

Something like:

Array.At(x+1,y) > contains('t') or contains('r') ... etc. ?
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822

Post » Wed May 10, 2017 9:35 pm

gumshoe2029 wrote:So how to you check the nearby tiles to see if their doors match up?

Something like:

Array.At(x+1,y) > contains('t') or contains('r') ... etc. ?


When checking the arrays for which door they contain I chose not to use strings or characters to label the types of rooms.
Instead the room configurations have an identity by number (1-15). I'll include the diagram (it's not sorted, but it's labeled)
I felt that numbers and characters would probably have worked the same; thinking that using comparisons between integers would be faster than comparing characters.

Image
B
10
S
2
G
2
Posts: 87
Reputation: 1,274

Post » Mon May 15, 2017 9:46 am

Bump.
B
10
S
2
G
2
Posts: 87
Reputation: 1,274

Post » Mon May 15, 2017 5:40 pm

Sorry, I have been insanely busy lately.

But you need a better schema for identifying which tile has which doors.

Sadly, I have not developed such a system yet, only theorized about what I might do in such a system, so I will be of limited help.

I would recommend studying @cesisco 's work here: viewtopic.php?f=159&t=189186
You might have to ask if he will share his capx with you (Or publicly).
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822

Post » Mon May 15, 2017 11:24 pm

Maybe this could help, it's a different way to look at the problem without using arrays. It first creates the rooms with door in between so everything is connected. Then as a second pass it has a chance to add a few more random doors to make looping passages.
https://www.dropbox.com/s/45t57qr04dzht ... .capx?dl=1

It's similar to what i've done previously here:
roguelike-map-system-untiled_p590128?#p590128
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Tue May 16, 2017 9:03 pm

gumshoe2029 wrote:Sorry, I have been insanely busy lately.

But you need a better schema for identifying which tile has which doors.

Sadly, I have not developed such a system yet, only theorized about what I might do in such a system, so I will be of limited help.

I would recommend studying @cesisco 's work here: viewtopic.php?f=159&t=189186
You might have to ask if he will share his capx with you (Or publicly).


Not a problem man. Thanks for looking into this.

R0J0hound wrote:Maybe this could help, it's a different way to look at the problem without using arrays. It first creates the rooms with door in between so everything is connected. Then as a second pass it has a chance to add a few more random doors to make looping passages.
https://www.dropbox.com/s/45t57qr04dzht ... .capx?dl=1

It's similar to what i've done previously here:
roguelike-map-system-untiled_p590128?#p590128


That simplifies things quite a bit, which is awesome. I was originally thinking that working with arrays would be best as it would be easy to reference what the current values are, which would be useful for mini-maps and such. Thanks a ton!
B
10
S
2
G
2
Posts: 87
Reputation: 1,274


Return to How do I....?

Who is online

Users browsing this forum: Alvaro2, Hadyurik and 8 guests