Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int Winner(char[,] board, char userType) //בודק אם יש מנצח
- {
- int winner = 0;
- for (int n = 0; n < board.GetLength(0); n++)
- {
- for (int h = 0; h < board.GetLength(1); h++)
- {
- if (board[h, n] == userType)
- winner ++;
- else if (board[n, h] == userType)
- winner++;
- else if (board[0, 0] == userType && board[1,1] == userType && board[2,2] == userType)
- winner=3;
- else if (board[0, 2] == userType && board[1, 1] == userType && board[2, 0] == userType)
- winner=3;
- else
- winner = 0;
- }
- if (winner == 3)
- break;
- else
- winner = 0;
- }
- return winner;
- /*
- if (board[0, 0] == userType && board[1, 0] == userType && board[2, 0] == userType)
- return 1;
- else if (board[0, 1] == userType && board[1, 1] == userType && board[2, 1] == userType)
- return 1;
- else if (board[0, 2] == userType && board[1, 2] == userType && board[2, 2] == userType)
- return 1;
- else if (board[0, 0] == userType && board[1, 1] == userType && board[2, 2] == userType)
- return 1;
- else if (board[0, 2] == userType && board[1, 1] == userType && board[2, 0] == userType)
- return 1;
- else if (board[0, 0] == userType && board[0, 1] == userType && board[0, 2] == userType)
- return 1;
- else if (board[1, 0] == userType && board[1, 1] == userType && board[1, 2] == userType)
- return 1;
- else if (board[2, 0] == userType && board[2, 1] == userType && board[2, 2] == userType)
- return 1;
- else
- return 0;
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement