Logic question

I have a game board that looks like the following ( 4 3x3 tic tac toe boards):


1
2
3
4
5
6
  x | . | . | . | . | . 
  . | x | . | . | . | .
  . | . | x | . | . | . 
  . | . | . | x | . | .
  . | . | . | . | . | . 
  . | . | . | . | . | .


It is stored as a vector with each x and . being an element (the dot is a place holder to indicate the spot is open). The top row is elements 0-5 the second row is elements 6-11, third row is 12-17 etc...

The game is played like tic tac toe but you need 4 in a row and after each move you rotate one of the tic-tac-toe boards either left or right. At this point two players can play a game and rotate the board with each move and rotation being validated. The rotation does not affect the vector subscripts for the board. Top left is still vector[0]

I am trying to work out how to validate if a player has won. I don't want to use 100 if statements if i don't need to. The sample board above shows a win. The win is vector elements 0, 7, 14, 21
Last edited on
You should only need four bool functions for this: Horizontal_Win, Vertical_Win, Diagonal_LR, Diagonal_RL. You're only checking to see if any 'X' or 'O' has three consecutive neighbors in any given direction.
Topic archived. No new replies allowed.