Skip to content
Snippets Groups Projects
Commit 6321af9f authored by bionic85's avatar bionic85
Browse files

binary is bijna af

parent e9ec484e
No related branches found
No related tags found
No related merge requests found
......@@ -129,8 +129,10 @@ namespace PuzzlePlayer_Namespace
// loop two times for checking 0 and 1
for (int i = 0; i <= 1; i++)
{
bool valid = false;
// middle check
MiddleCheck(x, y, boardToSolve, i);
valid = MiddleCheck(x, y, boardToSolve, i);
// side check
......@@ -145,10 +147,46 @@ namespace PuzzlePlayer_Namespace
// check if the space is surrounded on both sides by the same number. If it is, the checked space should be the opposite number
private bool MiddleCheck(int x, int y, int[,] b, int checkFor)
{
int opposite;
if (checkFor == 0)
opposite = 1;
else
opposite = 0;
// 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 (b[x - 1, y] == opposite && b[x + 1, y] == opposite)
return true;
// same for y
if (!(y - 1 < 0 || y + 1 > b.GetLength(1)))
if (b[x, y - 1] == opposite && b[x, y + 1] == opposite)
return true;
// return false if nothing was found
return false;
}
if (b[x - 1, y])
private bool SideCheck(int x, int y, int[,] b, int checkFor)
{
int opposite;
return false;
if (checkFor == 0)
opposite = 1;
else
opposite = 0;
if (!(x - 2 < 0 || x + 2 > b.GetLength(0)))
if ((b[x-2,y] == opposite && b[x-1,y] == opposite) || (b[x + 2, y] == opposite && b[x + 1, y] == opposite))
return true;
if (!(y - 2 < 0 || y + 2 > b.GetLength(1)))
if ((b[x, y - 2] == opposite && b[x, y - 1] == opposite) || (b[x, y + 2] == opposite && b[x, y + 1] == opposite))
return true;
return false;
}
}
......
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