diff --git a/PuzzlePlayer/Binary.cs b/PuzzlePlayer/Binary.cs index ac67090dc42d4f501c9ba6c6010caa9dbe1534b5..70c72e0baaf5d74a3989b6423da1e8bf2e587f05 100644 --- a/PuzzlePlayer/Binary.cs +++ b/PuzzlePlayer/Binary.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; using System.Runtime.CompilerServices; @@ -173,12 +174,12 @@ namespace PuzzlePlayer_Namespace { // first check if x-1 and x+1 aren't out of bounds // after that do the check if the move is valid - if(!(x-1 < 0 || x+1 > b.GetLength(0))) + if(!(x-1 < 0 || x+1 > b.GetLength(0) - 1)) if (b[x - 1, y] == checkFor && b[x + 1, y] == checkFor) return true; // same for y - if (!(y - 1 < 0 || y + 1 > b.GetLength(1))) + if (!(y - 1 < 0 || y + 1 > b.GetLength(1) - 1)) if (b[x, y - 1] == checkFor && b[x, y + 1] == checkFor) return true; @@ -189,13 +190,17 @@ namespace PuzzlePlayer_Namespace // check if the two spaces left, right, up or down of the space are the opposite number. if so return true private bool SideCheck(int x, int y, int[,] b, int checkFor) { - if (!(x - 2 < 0 || x + 2 > b.GetLength(0))) + if (!(x - 2 < 0 || x + 2 > b.GetLength(0)-1)) if ((b[x-2,y] == checkFor && b[x-1,y] == checkFor) || (b[x + 2, y] == checkFor && b[x + 1, y] == checkFor)) return true; - if (!(y - 2 < 0 || y + 2 > b.GetLength(1))) + if (!(y - 2 < 0 || y + 2 > b.GetLength(1)-1)) + { + Debug.WriteLine($"{x}, {y}"); if ((b[x, y - 2] == checkFor && b[x, y - 1] == checkFor) || (b[x, y + 2] == checkFor && b[x, y + 1] == checkFor)) return true; + } + return false; } diff --git a/PuzzlePlayer/PuzzleForm.cs b/PuzzlePlayer/PuzzleForm.cs index 7c70587197b641bc6870def576c7c04a6025d72c..31713df8bb9775c9239e9fe697eb4e12241864fb 100644 --- a/PuzzlePlayer/PuzzleForm.cs +++ b/PuzzlePlayer/PuzzleForm.cs @@ -45,8 +45,10 @@ namespace PuzzlePlayer_Namespace { UpdateUI(); }; - Board.boardState[1, 1] = 1; - Board.boardState[2, 2] = 0; + Board.boardState[4, 4] = 1; + Board.boardState[4, 5] = 1; + Board.boardState[5, 4] = 1; + Board.boardState[5, 5] = 1; } private void CreateUI() { @@ -73,7 +75,7 @@ namespace PuzzlePlayer_Namespace solvebutton.Text = "Solve"; solvebutton.MouseClick += (object sender, MouseEventArgs mea) => { - //board = board.Solve(); + board.Solve(); board.Draw(graphics, new Point(220, 30), new Size(400, 400)); };