Match-3 related algorithms?

BlitzMax Forums/BlitzMax Beginners Area/Match-3 related algorithms?

darkhog(Posted 2015) [#1]
Mainly how do you check for valid moves and "rebuild" board after move is done.

This is a little bit special for me. My Mom loves games like that and I would love to make for her such game as a x-mas gift. But without knowing necessary algorithms I can't.


Derron(Posted 2015) [#2]
Valid moves: if the move creates a connection of at least 3 connected objects (same color or specialities) it is valid.

Rebuild: just move the upcoming objects down one grid cell ... if all stones are no longer able to move down, you finished your first iteration. Next step is to check for connections again. if there was a connection, start again: removing connections, moving down, checking for connections ...

After this is done, your _turn_ is finished (important for things like combos counts).


I am pretty sure that there was a match-3-source-code posted somewhere in the forums. Above approach was just based on thoughts I had when starting to write a medieval _columns_-like game. This is not match3, but it is the same "ruleset" (except the way a user controls the game board).

Just found some small "monkey conversion" sample of that game (no special moves activated - just as demonstration of the particle effect on the torch and the title screen (press ESC)):
"play" online: http://digidea.de/dev/knb/



The relevant monkey source is this (there is surely a better way to do things - but the conversion is based on code I wrote about 9 or 10 years ago - same for the graphics).





bye
Ron


degac(Posted 2015) [#3]
Hi

In C:\BlitzMax150\samples\birdie\games there's a simple 3-match game.
You can check it how it works.