Creating Connect four

Hello i am trying to create connect four as the title says I went to make the check win function and went well I don't want to write a couple hundred if's to check that if a player one is there a better way to check this

edit: decided i should clarify but i created an array for the board and really was trying to as if there was a way to just say if adjacent part of the array are equal rather than than type out an if for each possibility
Last edited on
When a piece is placed, you could add up the number of consecutive pieces of the same color in each direction (n, s, w, e, nw, ne, se, sw) and then add the adjacent directions to see if there are now 4 in a row.

player places piece
left = consecutive same pieces to the left
right = consecutive same pieces to the right
if left + right + 1 (account for the piece just added) >= 4
    that player won
then do the same for the other directions (3 more sets)
Topic archived. No new replies allowed.