How could I check for (in say, Tic Tac Toe) 3 x's or o's in a row? I'd like to be able to recognize when someone has won so that I can add to someone's score count and clear the board.
You would have to individually check each possible winning combination; that is, if you do this in the world class 'act' method. You could check the up-to four possible directions as each play is made. I do not think it would matter much which way you go, as there are only eight possible three-in-a-rows. To start, however, it would be best to create a two-dimensional array to hold the value of each square in the game. You could use String values "x", "o", and " " (space) as the values and concatenate the values from a row, column or diagonal to create a current value for each possible combination. If you compare these values with "xxx" and "ooo", you can determine when the game is won. You should probably count down the number of empty squares as each play is made, so you can determine when a draw occurs also.