public static void printGrid(int[,] g){
for(int x = 0; x < 6; x++){
for(int y = 0; y < 7; y++){
Console.WriteLine(g[x, y]);
public static void play1(int[,] array, int i){
}else if(array[4, i] == 0){
}else if(array[3, i] == 0){
}else if(array[2, i] == 0){
}else if(array[1, i] == 0){
}else if(array[0, i] == 0){
Console.WriteLine("Invalid column, please choose a valid column.");
public static void play2(int[,] array, int i){
}else if(array[4, i] == 0){
}else if(array[3, i] == 0){
}else if(array[2, i] == 0){
}else if(array[1, i] == 0){
}else if(array[0, i] == 0){
public static string win1Check(int[,] array){
for(int x = 0; x < 6; x++){
for(int y = 0; y < 7; y++){
if(((d1==1)&&(d2==1))&&(d3==1)){
if(((l1==1)&&(l2==1))&&(l3==1)){
if(x-3 >= 0 && y-3 >= 0){
int bl1 = array[x-1, y-1];
int bl2 = array[x-2, y-2];
int bl3 = array[x-3, y-3];
if(((bl1==1)&&(bl2==1))&&(bl3==1)){
int br1 = array[x-1, y+1];
int br2 = array[x-2, y+2];
int br3 = array[x-3, y+3];
if(((br1==1)&&(br2==1))&&(br3==1)){
public static string win2Check(int[,] array){
for(int x = 0; x < 6; x++){
for(int y = 0; y < 7; y++){
if(((d1==2)&&(d2==2))&&(d3==2)){
if(((l1==2)&&(l2==2))&&(l3==2)){
if(x-3 >= 0 && y-3 >= 0){
int bl1 = array[x-1, y-1];
int bl2 = array[x-2, y-2];
int bl3 = array[x-3, y-3];
if(((bl1==2)&&(bl2==2))&&(bl3==2)){
int br1 = array[x-1, y+1];
int br2 = array[x-2, y+2];
int br3 = array[x-3, y+3];
if(((br1==2)&&(br2==2))&&(br3==2)){
public static void Main()
int[,] grid = new int[6, 7];
Console.WriteLine("Please enter Player 1.");
string player1 = Console.ReadLine();
Console.WriteLine("Please enter Player 2.");
string player2 = Console.ReadLine();
Console.WriteLine("Welcome " +player1 +" and " +player2 +".");
Console.WriteLine("Today, we will be playing Connect Four.");
Console.WriteLine("The goal is to connect 4 of your pieces in one uninterrupted line horizontally, diagonally, or vertically.");
Console.WriteLine("Once a player has 4 or more pieces in a row, the game is over.");
Console.WriteLine("Each player will take turns putting in pieces, and will type in columns 1 to 7 (left to right).");
Console.WriteLine("Without furtherado, let's begin.");
if(win2Check(grid)=="win"){
Console.WriteLine("The game has ended, " +player2 +" has won!");
Console.WriteLine(player1 + ", choose a column.");
string tempNum1 = Console.ReadLine();
int num1 = Int32.Parse(tempNum1);
if(num1 < 1 || num1 > 7){
Console.WriteLine("Invalid column, please choose a valid column.");
}else if(grid[0, num1-1] != 0){
Console.WriteLine("Invalid column, please choose a valid column.");
if(win1Check(grid)=="win"){
Console.WriteLine("The game has ended, " +player1 +" has won!");
Console.WriteLine(player2 +", choose a column.");
string tempNum1 = Console.ReadLine();
int num1 = Int32.Parse(tempNum1);
if(num1 < 1 || num1 > 7){
Console.WriteLine("Invalid column, please choose a valid column.");
}else if((grid[0, num1-1] == 1) || (grid[0, num1-1] == 2)){
Console.WriteLine("Invalid column, please choose a valid column.");
if((grid[0,0] != 0) ){column1Full = 1;}
if((grid[0,1] != 0) ){column2Full = 1;}
if((grid[0,2] != 0) ){column3Full = 1;}
if((grid[0,3] != 0) ){column4Full = 1;}
if((grid[0,4] != 0) ){column5Full = 1;}
if((grid[0,5] != 0) ){column6Full = 1;}
if((grid[0,6] != 0) ){column7Full = 1;}
if((column1Full + column2Full + column3Full +column4Full +column5Full +column6Full+column7Full) == 7){
Console.WriteLine("The game has ended, there no more available spaces.");
Console.WriteLine("Would you like to play again?");
Console.WriteLine("Type Yes if you would like to continue, or type No if you would like to finish.");
string answer = Console.ReadLine();
Console.WriteLine("Please play again!");
Console.WriteLine("Invalid answer.");