//public Move GetNextMove(CellType[][] inputBoard) //{ // if (isFirstMove) // { // isFirstMove = false; // isSecondMove = true; // QueueRandomMove(); // lastMove = moveQueue.Dequeue(); // return lastMove; // } // else if (isSecondMove) // { // isSecondMove = false; // InitializeBoard(inputBoard); // } // UpdateBoard(inputBoard); // if (moveQueue.Count > 0) // { // lastMove = moveQueue.Dequeue(); // return lastMove; // } // else // { // AddMovesToQueue(); // lastMove = moveQueue.Dequeue(); // return lastMove; // } //} public Solver(Game game) { moveQueue = new Queue <Move>(); lastMove = new Move(); isFirstMove = true; isSecondMove = false; width = game.GetWidth(); height = game.GetHeight(); board = new Square[width][]; for (int i = 0; i < game.GetWidth(); i++) { board[i] = new Square[height]; } InitializeBoard(game.GameData.board); }
static void DisplayBoard(Game game) { for (int x = 0; x < game.GetWidth(); x++) { for (int y = 0; y < game.GetHeight(); y++) { DisplayBoardElem(game.GameData.board[x][y]); } Console.WriteLine(); } }
private void InitializeBoard(Game Game) { game = Game; board = new StackPanel() { Orientation = Orientation.Vertical, }; rows = new StackPanel[game.GetWidth()]; cells = new Button[game.GetWidth()][]; for (int x = 0; x < game.GetWidth(); x++) { rows[x] = new StackPanel() { Orientation = Orientation.Horizontal, }; cells[x] = new Button[game.GetHeight()]; for (int y = 0; y < game.GetHeight(); y++) { Button button = new Button() { Width = 32, Height = 32, Tag = string.Format("{0},{1}", x, y), }; button.BorderThickness = new Thickness(1.5); button.FontSize = 20; button.FontWeight = FontWeights.Bold; button.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(BoardClick); button.MouseUp += new MouseButtonEventHandler(BoardClick); cells[x][y] = button; rows[x].Children.Add(button); } board.Children.Add(rows[x]); } }
public void UpdateBoard() { for (int x = 0; x < game.GetWidth(); x++) { for (int y = 0; y < game.GetHeight(); y++) { switch (game.GameData.board[x][y]) { case CellType.NotVisible: cells[x][y].Content = ""; break; case CellType.Bomb: cells[x][y].Content = "B"; cells[x][y].Background = new SolidColorBrush(Color.FromRgb(255, 92, 92)); break; case CellType.Flag: cells[x][y].Content = "F"; cells[x][y].Background = new SolidColorBrush(Color.FromRgb(163, 206, 255)); break; case CellType.Zero: cells[x][y].Content = ""; cells[x][y].Background = new SolidColorBrush(Color.FromRgb(245, 245, 245)); break; case CellType.One: cells[x][y].Content = "1"; cells[x][y].Background = new SolidColorBrush(Color.FromRgb(245, 245, 245)); break; case CellType.Two: cells[x][y].Content = "2"; cells[x][y].Background = new SolidColorBrush(Color.FromRgb(245, 245, 245)); break; case CellType.Three: cells[x][y].Content = "3"; cells[x][y].Background = new SolidColorBrush(Color.FromRgb(245, 245, 245)); break; case CellType.Four: cells[x][y].Content = "4"; cells[x][y].Background = new SolidColorBrush(Color.FromRgb(245, 245, 245)); break; case CellType.Five: cells[x][y].Content = "5"; cells[x][y].Background = new SolidColorBrush(Color.FromRgb(245, 245, 245)); break; case CellType.Six: cells[x][y].Content = "6"; cells[x][y].Background = new SolidColorBrush(Color.FromRgb(245, 245, 245)); break; case CellType.Seven: cells[x][y].Content = "7"; cells[x][y].Background = new SolidColorBrush(Color.FromRgb(245, 245, 245)); break; case CellType.Eight: cells[x][y].Content = "8"; cells[x][y].Background = new SolidColorBrush(Color.FromRgb(245, 245, 245)); break; } } } }