Tic Tac Toe Problem.

My Tic Tac toe Win32 game is malfunctioning.
|............|
|............|
|............|
|............|
|............|
|............|

The above is the game board. The game needs 5 in a row to win. When I play 3 rows vertically at the extreme top and then play 2 at the extreme bottom(but one step to the left/right), it thinks that it's 5 in a row.
|.....x......|
|.....x......|
|.....x......|
|............|
|...x........|
|...x........|
Like the above. It also happens diagonally. Maybe there's something wrong with my FOR LOOP which checks for rows. Here is the code for the FOR LOOP.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
for (int i=0; i<BOARD_SIZE; i++) 
		    for (int j=0; j<BOARD_SIZE; j++)
		{
		if (board[i][j] == 2 && board[i][j+1] == 2 && board[i][j+2] == 2 && board[i][j+3] == 2 && board[i][j+4]==2){//////////Vertical 
			 redpoints++;playerturn =2;board[i][j] =9; board[i][j+1] =9;board[i][j+2] =9;board[i][j+3] =9; board[i][j+4]=9;}

		if (board[i][j] == 2 && board[i+1][j] == 2 && board[i+2][j] == 2 && board[i+3][j] == 2&& board[i+4][j] == 2){//////////horizontal
			 redpoints++;playerturn =2;board[i][j] =9; board[i+1][j] =9; board[i+2][j] =9; board[i+3][j] =9;board[i+4][j] =9;}

		if (board[i][j+3] == 2 && board[i+1][j+2] == 2 && board[i+2][j+1] == 2 && board[i+3][j] == 2&& board[i+4][j-1] == 2){////diagonal 1 
			   redpoints++;playerturn =2;board[i][j+3] =9;board[i+1][j+2] =9; board[i+2][j+1] =9; board[i+3][j] =9; board[i+4][j-1] =9;}

		if (board[i][j+2] == 2 && board[i+1][j+3] == 2 && board[i+2][j+4] == 2 && board[i+3][j+5] == 2 && board[i+4][j+6]==2){////diagonal 2 
			redpoints++;playerturn =2;board[i][j+2] =9; board[i+1][j+3] =9; board[i+2][j+4] =9; board[i+3][j+5] =9; board[i+4][j+6]=9;}

		 
		}





The Code below is the code that builds the grid.
1
2
3
4
5
6
for (int i=0; i<=BOARD_SIZE; i++)///////////////Draws rectangles in window
			for (int j=0; j<=BOARD_SIZE; j++){
			SelectObject(hdc, purple);
	    	SelectObject(hdc, transparent);
			Rectangle(hdc, i*BOX_SIZE,j*BOX_SIZE,i*BOX_SIZE+BOX_SIZE, j*BOX_SIZE+BOX_SIZE);
			DeleteObject(purple);
Topic archived. No new replies allowed.