static void Main(string[] args) { int tileWidth = 30; int tileHeight = 30; var handle = GetConsoleWindow(); Console.SetWindowSize(100, 40); ShowWindow(handle, SW_HIDE); Thread.Sleep(300); ScreenShot screen = new ScreenShot(); Bitmap playField = screen.GetPlayField(); try { int boardWidth = playField.Size.Width / tileWidth; int boardHeight = playField.Size.Height / tileHeight; Console.WriteLine("Screen width: {0} Screen height: {1}", boardWidth, boardHeight); Tile[,] board = new Tile[boardWidth, boardHeight]; List <Tile> numberedTiles = new List <Tile>(); List <Tile> columns = new List <Tile>(); for (int i = 0; i < board.GetLength(0); i++) { for (int j = 0; j < board.GetLength(1); j++) { board[i, j] = new Tile(TileType.Unknown, i, j); } } LeftMouseClick(screen.GetScreenLeft() + 15, screen.GetScreenTop() + 15); while (true) { RemoveMouseFromPlay(screen.GetScreenLeft() - 30, screen.GetScreenTop() - 30); screen.UpdateField(); UpdateBoard(screen.GetPlayField(), board); ShowWindow(handle, SW_SHOW); for (int i = 0; i < board.GetLength(1); i++) { for (int j = 0; j < board.GetLength(0); j++) { Console.Write(board[j, i]); } Console.Write("\n"); } FindNumberedTiles(board, numberedTiles); List <List <int> > solvingMatrix = BuildSolvingMatrix(columns, numberedTiles); rref(solvingMatrix); FindBombs(solvingMatrix, columns, numberedTiles, screen); numberedTiles.Clear(); solvingMatrix.Clear(); columns.Clear(); //Console.ReadLine(); } } catch (NullReferenceException) { Console.WriteLine("play field not found"); } Console.ReadLine(); }
static void Main(string[] args) { int tileWidth = 30; int tileHeight = 30; var handle = GetConsoleWindow(); Console.SetWindowSize(100, 40); ShowWindow(handle, SW_HIDE); Thread.Sleep(300); ScreenShot screen = new ScreenShot(); Bitmap playField = screen.GetPlayField(); try { int boardWidth = playField.Size.Width / tileWidth; int boardHeight = playField.Size.Height / tileHeight; Console.WriteLine("Screen width: {0} Screen height: {1}", boardWidth, boardHeight); Tile[,] board = new Tile[boardWidth, boardHeight]; List<Tile> numberedTiles = new List<Tile>(); List<Tile> columns = new List<Tile>(); for (int i = 0; i < board.GetLength(0); i++) { for (int j = 0; j < board.GetLength(1); j++) { board[i, j] = new Tile(TileType.Unknown, i, j); } } LeftMouseClick(screen.GetScreenLeft() + 15, screen.GetScreenTop() + 15); while (true) { RemoveMouseFromPlay(screen.GetScreenLeft() - 30, screen.GetScreenTop() - 30); screen.UpdateField(); UpdateBoard(screen.GetPlayField(), board); ShowWindow(handle, SW_SHOW); for (int i = 0; i < board.GetLength(1); i++) { for (int j = 0; j < board.GetLength(0); j++) { Console.Write(board[j, i]); } Console.Write("\n"); } FindNumberedTiles(board, numberedTiles); List<List<int>> solvingMatrix = BuildSolvingMatrix(columns, numberedTiles); rref(solvingMatrix); FindBombs(solvingMatrix, columns,numberedTiles, screen); numberedTiles.Clear(); solvingMatrix.Clear(); columns.Clear(); //Console.ReadLine(); } } catch (NullReferenceException) { Console.WriteLine("play field not found"); } Console.ReadLine(); }