Is there a way to track a win in Connect 4 without accounting for every possibility?

I’m making Connect 4 and I’m trying to make it so that once 4 of 1 players’ disks are next to each other, it sends a win message. I already have all the other things set up, like the game placing the disks on the board, but I don’t know how to track wins. Can anyone help?

1 Like

Don’t you have a thing checking whether if you can place disks somewhere?

Yes. I have counters set up to track the total number of discs in a column, so the disks can ‘drop’ into the slots.

can it detect what color and which collum it is in?

Yes, I have wire repeaters that are team specific to track colors, and the triggers they are attached to send out color-specific messages.

Why don’t you use that?

I would, but it would have a bug that would count if there’s 4 of a color, instead of 4 of a color next to eachother.
Example:

Hmmm, that’s weird… Maybe double check it. (good luck with double checking it)

Off-topic

Do you have an account on the wix so that I could add you to the FORERUNNER game development team?

What do you mean double-check it?

No, I do not.

Like, check for any faults in the system.

Thats a shame. :frowning:

That’s a broad solution.

If you find any faults we can start from there and figure out how to fix it.

If you don’t find any, then I have to actually think.

1 Like

Well, I know that for each column, there’s 4 combinations for wins.
A1 | A2 | A3 | A4
A2 | A3 | A4 | A5
A3 | A4 | A5 | A6
A4 | A5 | A6 | A7

And for each row, it’d go
A1 B1 C1 D1
-----------------
B1 C1 D1 E1
-----------------
C1 D1 E1 F1
-----------------
D1 E1 F1 G1

I recommend that for each move that is made, you prevent any inputs until this program runs:

  1. First like a grid pattern the game starts at (0,0) or the bottom left square, knowing that the game then finds what square the player put a chip at, it then checks the color value for it and sets its x position, y position, and color to multiple properties.

  2. Make each tile in your game has a property named with their x and y position, for example the bottom left square would be called “00” due to its position being (0,0).

  3. In block code, make a simple system with two variables called X and Y. Set them to the current tile you are analyzing and then increment the X value by one three time, checking the adjacent tiles to the right for if they are the same color as the original tile.

  4. Set both the X and Y variables to 0, then do the same as step 3 but change the X variable by -1 instead of 1, this will check three tiles to the left to see if they are the same color.

  5. Next have the program add +1 to both x and y to check for diagonal spaces, then add -1 to one of them at a time until you fully invert the values.

  6. Finally if add a broadcast to each of these checks so that if any of them pass the respective player wins!

Please note that none of this has actually been tested, nor do I have any pictures that could be used as an example, all of this works in theory based on previously discovered and used tech in Gimkit Creative.

2 Likes

In order to do this, I’d have to throw my entire grid-placement system out. Currently, the placement system is based on block code broadcasting on a channel, that channel being based on Color, Column, and Row.
For example, if the Red Player dropped a disk on top of two other disks in column A, the channel broadcasted on would RA3.

If lists were added to block code, this would be 10x easier.

1 Like

Alright. I figured it out using concatenation and triggers.


(theres more to it I’m just showing that I figured it out.)
I VERY MUCH CUT DOWN ON TRIGGERS AND COUNTERS. THIS ONLY USES 1 TRIGGER AND 1 PROPERTY.

This topic was automatically closed 3 hours after the last reply. New replies are no longer allowed.