- #1
Veronica_Oles
- 142
- 3
Homework Statement
I am working on the diagonal check for the game Connect Four in C#. I need help with trying to figure out what is wrong with the diagonal check. I noticed a trend pertaining to the points. The j which is the rows goes down by 1 and the i which is the columns up by 1. I am struggling with the for loops now, I put j is equal to 5 since when you count the amount of rows it goes 0, 1, 2, 3, 4, 5, yet I still don't know what's wrong any suggestions would be greatly appreciated.
Homework Equations
The Attempt at a Solution
Code:
private Boolean diagonal_winner_up()
{
Boolean winner = false;
{
for (int i = 0; i< 7; i++)
{
for (int j = 5; j > 6; j++)
{
if (board[i,j] == 1 && board[j - 1, i + 1] == 1&& board[j - 2, i + 2] == 1 && board[j - 3, i + 3] == 1 || board[i,j] == 2 && board[j - 1, i + 1] == 2 && board[j - 2, i + 2] == 2 && board[j - 3, i + 3] == 2)
{
winner = true;
if (board[i, j] == 1)
{
player1_wins = 1;
}
else
{
player2_wins = 2;
}
}
}
}
}
return winner;
}