Randomizing an initial layout, with caveats

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
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Randomizing an initial layout, with caveats

Post by MarekkPie »

So, I'm in the process of making a Puzzle League clone, given that it is my favorite puzzle game of all time (got hooked back when it was Tetris Attack), and I am having trouble with thinking through the initial load stage. I want to allow for completely random placement of the initial board, with the only requirement being that it must have n blocks.

The issue has to deal with the way Puzzle League is played. It has a match-three based puzzle mechanic, so I don't want the initial layout to have any instant matches. I need to check vertically and horizontally for these potential matches.

If I were to force only block totals that layout uniformly (i.e n % (number of columns) = 0), then the problem is fairly simple, but if I allow for random undulations, then it get's a bit more difficult.

I have some ideas, but they seem a bit inelegant and likely pretty slow, so I am asking you all out there.

(This is purely a mental exercise; I have no code to show you for a starting off point. Your starting point is the description and any images on the web that show how Puzzle League works...such as this one.)

Image
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Randomizing an initial layout, with caveats

Post by kikito »

I think the simplest solution is making the game "play randomly" for a while.

Let random pieces drop aleatorily. If a match happens, let it happen; continue throwing random pieces, until either you have a "max" number of pieces on the screen, a max number of movements has been hit, certain amount of time has passed, or you reach certain height in any of the columns.

The nice thing about this approach is that most of the code used on it is the "real" game rules; you don't have to implement "rules for creating the initial layout".

The bad thing is that it isn't deterministic. It could happen that the computer gets very lucky and you get less squares than what you wanted on certain matches.
When I write def I mean function.
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Randomizing an initial layout, with caveats

Post by MarekkPie »

kikito wrote:aleatorily
Que? Wie bitte? Ce que? что? Vad?...

...huh?
utunnels
Citizen
Posts: 75
Joined: Fri Jan 06, 2012 5:20 pm

Re: Randomizing an initial layout, with caveats

Post by utunnels »

In short,

1. Add a block without considering the issue.
2. Destroy those adjacent blocks using the rule you already wrote for your game.
3. Repeat 1 and 2 until there are enough blocks on screen.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Randomizing an initial layout, with caveats

Post by coffee »

MarekkPie wrote:
kikito wrote:aleatorily
Que? Wie bitte? Ce que? что? Vad?...

...huh?
Amazing. You seem to know all languages except english. Let me help. Yes, the word exists and is correct.
aleatorily
English

Etymology
aleatory +‎ -ly
Adverb
aleatorily (comparative more aleatorily, superlative most aleatorily)
In an aleatory manner; randomly.
I'm probably the worst guy in forum talking english, but for sure understood very well kikito's words and context. :D
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Randomizing an initial layout, with caveats

Post by Nixola »

I already knew that word just because in Italian is almost the same ("aleatorio")
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Randomizing an initial layout, with caveats

Post by coffee »

Nixola wrote:I already knew that word just because in Italian is almost the same ("aleatorio")
"alea jacta est" (the dice has been cast) is also a well know latin expression. After some decades of existence Asterix still teaches worldwide some latin! No one learns anymore latin in school or at church right? :D
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Randomizing an initial layout, with caveats

Post by kikito »

I didn't have to go that far. T

But it was a consequence of me writing posts late in the night (~2:00 AM). In Spanish, my native language, the word for "ramdom" is "aleatorio"; he auto-correction in my browser didn't underline the word in red, so I assumed it existed; didn't give it another thought and went to sleep.

Had I been a bit more awake, I would have used the most common word - "randomly" :)

Now, going back on topic, do you think the suggestion will work, or do you foresee any problem?
When I write def I mean function.
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Randomizing an initial layout, with caveats

Post by MarekkPie »

I've got a lot of work to get there, as I am still in the infancy stages of the project, but I don't see why it won't work. Usually with Puzzle League (or at least with Tetris Attack) difficulty was measured both by number of initial blocks and height of the tallest column. Only thing I would need to change from your suggestion is to blot out any columns that reach a height h.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Randomizing an initial layout, with caveats

Post by Jasoco »

I would say run an initial test on the first group of blocks where if it finds a match, change one of the tiles to something else, check again and keep checking and changing until it finds no matches, then start off.

I've seen puzzle games that didn't do this test and gave you matches off the bat.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Yolwoocle and 234 guests