Skip to content
Snippets Groups Projects
Commit 1d51cff3 authored by Floris's avatar Floris
Browse files

fixes

parent 17ab22c1
No related branches found
No related tags found
No related merge requests found
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;
}
......
......@@ -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));
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment