Skip to content

Instantly share code, notes, and snippets.

@LinuxDoku
Created November 8, 2011 12:30
Show Gist options
  • Save LinuxDoku/1347636 to your computer and use it in GitHub Desktop.
Save LinuxDoku/1347636 to your computer and use it in GitHub Desktop.
private bool check(int player)
{
for (int x = 7; x > 0; x--)
{
for (int y = 6; y > 0; y--)
{
int[] tmp = fields[x, y];
if (tmp[0] == 1 && tmp[1] == player)
{
for (int xCurrent = (x - 1); xCurrent > (x + 1); xCurrent++)
{
for (int yCurrent = y - 1; yCurrent > y + 1; yCurrent++)
{
int[] tmpCurrent = fields[xCurrent, yCurrent];
Debug.WriteLine(xCurrent + "_" + yCurrent);
if (tmpCurrent[0] == 1 && tmpCurrent[1] == player)
{
int xDirection = xCurrent - x;
int yDirection = yCurrent - y;
int[] tmpDirection = fields[xDirection, yDirection];
if (tmpDirection[0] == 1 && tmpDirection[1] == player)
{
// go deeper
int[] tmpDoubleDirection = fields[xDirection * 2, yDirection * 2];
if (tmpDoubleDirection[0] == 1 && tmpDoubleDirection[1] == player)
{
return true;
}
else
{
int[] tmpDoubleAlternateDirection = fields[(xDirection * -1) * 2, (xDirection * -1) * 2];
if (tmpDoubleAlternateDirection[0] == 1 && tmpDoubleAlternateDirection[1] == player)
{
return true;
}
}
}
}
}
}
}
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment