From 1d51cff33eabc4c4f49ae26b1eb948fbf5f7af45 Mon Sep 17 00:00:00 2001
From: Floris <f.k.h.vandezande@students.uu.nl>
Date: Wed, 20 Nov 2024 14:05:45 +0100
Subject: [PATCH] fixes

---
 PuzzlePlayer/Binary.cs     | 13 +++++++++----
 PuzzlePlayer/PuzzleForm.cs |  8 +++++---
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/PuzzlePlayer/Binary.cs b/PuzzlePlayer/Binary.cs
index ac67090..70c72e0 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 7c70587..31713df 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));
             };
 
-- 
GitLab