Anonymous asked in Computers & InternetProgramming & Design · 1 decade ago

How can I know if someone won in connect four?

Without checking every square in the board matrix?

3 Answers

  • 1 decade ago
    Favorite Answer

    A win will occur after a player has made a move (dropped a checker). Check the last dropped checker and determine if it causes a win (four in a row). Do this after each turn and you will never need to check the entire board matrix.

  • Anonymous
    1 decade ago

    you can keep track of each person's selections in two seperate matrices where each slot is 0 or 1 depending on whether it has a chip in it....keep a running sum of each column and row as chips are placed, i.e. if a chip was placed at 1, 3 then row 1 and column 3 would both be incremented by one...whenever a row or column equals four you can check to see if they are consecutive...technically that counts as not checking the entire matrix.....if that doesn't work for you then maybe some kind of Matrix transformation math will do the trick....

  • 1 decade ago

    To see four of the same color in a shouldn't be that hard to spot with a glance at the board.

Still have questions? Get your answers by asking now.