Third, I started to scan the board left to right on the first pass and then right to left on the second pass. Second, I stopped reading all the pixels in the squares. First it appears the more RAM memory and CPU the Minesweeper solver has, the faster it will run. I found some interesting things that really sped up the time that it took the program to solve the game. That is how long it took the program to solve the game. When starting a game or when the program would get stuck, I would randomly pick the next box to click. Once the brain method made a decision on what should be done, I would either send right mouse clicks or left mouse clicks. ToolStripStatusLabel1.Text = " Error on "+errorNumber+ " processing too many bombs!" RightClickUnknowns(top, topRight, right, bottomRight, bottom,Įlse if (maxBombs >= 6 & bombCnt = 6 & unKnownsCnt = (maxBombs - 6))Įlse if (maxBombs >= 5 & bombCnt = 5 & unKnownsCnt = (maxBombs - 5))Įlse if (maxBombs >= 4 & bombCnt = 4 & unKnownsCnt = (maxBombs - 4))Įlse if (maxBombs >= 3 & bombCnt = 3 & unKnownsCnt = (maxBombs - 3))Įlse if (maxBombs >= 2 & bombCnt = 2 & unKnownsCnt = (maxBombs -2))Įlse if (bombCnt = 1 & unKnownsCnt = (maxBombs - 1))Įlse if (bombCnt = 0 & unKnownsCnt = maxBombs) ProcessUnknowns(top, topRight, right, bottomRight, bottom,Įlse if (maxBombs >= 7 & bombCnt = 7 & unKnownsCnt = (maxBombs - 7)) Right, bottomRight, bottom, bottomLeft, left, topLeft) Int unKnownsCnt = GetCounts(SquareType.Unknown, top, topRight, Int bombCnt = GetCounts(SquareType.Bomb,top,topRight,right,īottomRight,bottom,bottomLeft,left,topLeft) SquareType bottom, SquareType bottomLeft, SquareType left, SquareType topRight, SquareType right, SquareType bottomRight, Private Boolean TheBrain(SquareType currPos, SquareType top, I was surprised to find how simple the brain method ended up being: Then I pass all this info into TheBrain method. Next I wrote some code to help me figure out what all the surrounding boxes are to the current box I am looking at. I use the colors found in the boxes to help me figure out which number I have clicked, etc. Next I use the screen print of the Minesweeper game to figure out which boxes I have found. Base off the screen width of the Minesweeper game I make an assumption on which level the user is playing at. This is important so I have an idea of where I need to be sending mouse clicks. Then I get the handle to the program and force it to the forefront and put it in the upper left hand corner of the screen.
0 Comments
Leave a Reply. |