# Matching Algoritm

Get help using Construct 2

### » Tue May 12, 2015 4:36 pm

@mindfaQ: your code works great! there's one problem tho. you can easily replicate it. put two pieces of the same color together (only 2) and then do the same for 2 pieces of a different color. the four of them will be counted as a match, and they shouldn't be. i'm trying to fix it, but i'm only making it worse. any help is appreciated!

i believe i can fix it if i reset all of the pieces' status to 0 after matches are checked. i'll repost if it works.
B
6
S
2
Posts: 18
Reputation: 536

### » Mon Aug 17, 2015 10:39 am

alextro wrote:My approach for matching puzzle swap that utilize flood-fill

@alextro

Just had a look at your code and trying to reverse it. I want the blocks to be destroyed if neighbour blocks are of different colors.

Example: Instead of 3 red blocks being destroyed on matched, it will be red, purple, blue destroyed on matched. Hope it makes sense.

I set invert: Animation frame = Self.AnimationFrame but it doesn't seem to work.
B
23
S
10
G
2
Posts: 104
Reputation: 3,071

### » Mon Aug 17, 2015 10:16 pm

That would be unusual gameplay, but can be done by counting animation frame. For example red=0, purple=1, blue=2. Say first pick is purple, so we store the animation frame value to variable "pick_color". Then we add 1 for second pick that will equal to 2 which is blue. Third pick will return value 3, so set variable "pick_color" %3 everytick to loop the value back to 0.

Anyway you may found auto-match interesting:
viewtopic.php?f=147&t=150699&p=956438#p956438
B
133
S
55
G
24
Posts: 802
Reputation: 24,412

Previous