public bool IsEmpty() { for (int i = 0; i < symbols.GetLength(0); i++) { if (RowIsEmpty(i) == false) { return(false); } } return(true); }
public BoardLogic() { state = new Symbol[3, 3]; currentTurn = Symbol.X; for (int row = 0; row < state.GetLength(0); row++) { for (int column = 0; column < state.GetLength(1); column++) { state[row, column] = Symbol.U; } } }
private void Flip(string direction) { direction = direction.ToLower(); byte[,] Result; switch (direction) { case "clockwise": Result = new byte[Content.GetLength(1), Content.GetLength(0)]; break; case "counterclockwise": Result = new byte[Content.GetLength(1), Content.GetLength(0)]; break; } }
/// <summary> /// Checks if n positions in a row (direction determined by di and dj) all are symbol s. /// </summary> /// <param name="s">Symbol to look for.</param> /// <param name="n">Length of straight.</param> /// <param name="i">Starting row index.</param> /// <param name="j">Starting column index.</param> /// <param name="di">Change in row index for each step.</param> /// <param name="dj">Change in column index for each step.</param> private bool NInARow(Symbol s, int n, int i, int j, int di, int dj) { int extremeI = i + (n - 1) * di; int extremeJ = j + (n - 1) * dj; //i too large/small for n if (extremeI < 0 || extremeI >= places.GetLength(0)) { return(false); } //j too large/small for n if (extremeJ < 0 || extremeJ >= places.GetLength(1)) { return(false); } //not all symbol s for (int k = 0; k < n; k++) { if (places[i + k * di, j + k * dj] != s) { return(false); } } //Passed all tests return(true); }
public void ShowField(Symbol[,] field) { Console.Clear(); for (int h = field.GetLength(0) - 1; h >= 0; h--) { for (int w = 0; w < field.GetLength(1); w++) { if (field[w, h] == Symbol.empty) { Console.Write(" - "); } else if (field[w, h] == Symbol.x) { Console.Write(" x "); } else { Console.Write(" o "); } } Console.WriteLine("\n"); } }
// 0 | 1 | 2 // 3 | 4 | 5 // 6 | 7 | 8 public bool BoardCheck(Player p) { //vertical win for (int row = 0; row < state.GetLength(0); row++) { if (state[row, 0] == p.PlayerMark && state[row, 1] == p.PlayerMark && state[row, 2] == p.PlayerMark) { return(true); } } //horizontal win for (int columns = 0; columns < state.GetLength(0); columns++) { if (state[0, columns] == p.PlayerMark && state[1, columns] == p.PlayerMark && state[2, columns] == p.PlayerMark) { return(true); } } //diagonal wins if (state[1, 1] == p.PlayerMark) { //upper left to lower right if (state[0, 0] == p.PlayerMark && state[2, 2] == p.PlayerMark) { return(true); } //upper right to lower left else if (state[0, 2] == p.PlayerMark && state[2, 0] == currentTurn) { return(true); } } return(false); }
private void CheckFreeSpins(Symbol[,] board) { int freeSpinsCounter = 0; //loops through entire board and counts Free Spins for (int k = 0; k < board.GetLength(0); k++) { for (int l = 0; l < board.GetLength(1); l++) { if (board[k, l].Name == Figures.FreeSpin) { freeSpinsCounter++; } } } if (freeSpinsCounter == 4) { victoriesNotifications.Add("For hitting 4 FreeSpin symbols you won 3 Free Spins with value 2x of your bet: " + betValue * 2); for (int i = 0; i < 3; i++) { player.Freespins.Add(new Freespin(betValue * 2)); } } if (freeSpinsCounter == 5) { victoriesNotifications.Add("For hitting 5 FreeSpin symbols you won 7 Free Spins with value 5x of your bet: " + betValue * 5); for (int i = 0; i < 5; i++) { player.Freespins.Add(new Freespin(betValue * 7)); } } }
private void CheckField(Player currentPlayer, int rowINDX, int colINDX) { bool IsEnd = false; for (int i = 0; i < Field.GetLength(0); i++) { for (int j = 0; j < Field.GetLength(1); j++) { if (Field[i, j] != currentPlayer.Symbol) { IsEnd = false; break; } else { IsEnd = true; } } if (IsEnd) { break; } } if (!IsEnd) { for (int i = 0; i < Field.GetLength(0); i++) { for (int j = 0; j < Field.GetLength(1); j++) { if (Field[j, i] != currentPlayer.Symbol) { IsEnd = false; break; } else { IsEnd = true; } } if (IsEnd) { break; } } } if (!IsEnd) { for (int i = 0; i < Math.Min(Field.GetLength(0), Field.GetLength(1)); i++) { if (Field[i, i] != currentPlayer.Symbol) { IsEnd = false; break; } else { IsEnd = true; } } } if (!IsEnd) { for (int i = 0; i < Math.Min(Field.GetLength(0), Field.GetLength(1)); i++) { if (Field[i, Field.GetLength(1) - i - 1] != currentPlayer.Symbol) { IsEnd = false; break; } else { IsEnd = true; } } } if (IsEnd) { CrossPlayer.Winner = currentPlayer.Symbol == Symbol.Cross; CirclePlayer.Winner = currentPlayer.Symbol == Symbol.Circle; IsOver = IsEnd; } }