I have an issues with my int array, i have a game where its like a mega version of Tic Tac Toe where you need 5 to win instead of 3 and i have tried to come up with a system of checking for a winner or not (right now iv just been concerning myself with horizontal and vertical lines, im not gunna worry about diagonal atm). recent attemps i have tryed to solving this is to code the W's and B's as 0's and 1's, then put a check into a bool statement and only repeat the program while ture, but if somone gets 5 in a row then the statement turns false, this seems to work in my head but has not turned out so well in code. (code thus far)
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n, point_B, point_W;
int position_x, position_y;
int game_board[700][700];
int value(1);
int winner(true);
do{
cout << "Inpute Board size between 10 and 50" << endl;
cin >> n;
}while(n < 10 || n>50);
for(int y=0; y<n; y++)
for(int x=0; x<n; x++)
game_board[x][y] = value++;
for(int y=0; y<n; y++){
cout << endl;
for(int x=0; x<n; x++){
if(game_board[x][y] <= 9)
cout << game_board[x][y]<< " ";
else
cout<<game_board[x][y]<<" ";
}
}
cout << endl;
do{
for( int i(0); i<=n*n; i++){
if ( i%2 == 0){
cout << endl;
cout << "Black Enter Your Position: ";
cin >> point_B;
position_y = ceil(point_B/n);
if (point_B%n==0)
{
position_x=n-1;
position_y--;
}
else
position_x=(point_B%n)-1;
game_board[position_x][position_y] = -1;
for(int y=0; y<n; y++){
cout << endl;
for(int x=0; x<n; x++) {
if(game_board[x][y] <= 9){
if(game_board[x][y] == -1) {
cout << "B ";
} else if(game_board[x][y] == -2) {
cout << "W ";
} else cout << game_board[x][y]<< " ";
} else {
cout<<game_board[x][y] << " ";
}
}
}
cout << endl;
}
else{
cout << endl;
cout << "White Enter Your Position: ";
cin >> point_W;
position_y = ceil(point_W/n);
if (point_W%n==0)
{
position_x=n-1;
position_y--;
}
else
position_x=(point_W%n)-1;
game_board[position_x][position_y] = -2;
for(int y=0; y<n; y++){
cout << endl;
for(int x=0; x<n; x++) {
if(game_board[x][y] <= 9){
if(game_board[x][y] == -1) {
cout << "B ";
} else if(game_board[x][y] == -2) {
cout << "W ";
} else cout << game_board[x][y]<< " ";
} else {
cout<<game_board[x][y] << " ";
}
}
}
cout << endl;
}
}
}while(winner);
system("PAUSE");
return 0;
}