скачать книгу бесплатно
{
d1++;
if (((x +2) <7) && ((y – 2)> -1))
{
if (arr [x +2, y – 2] == plr)
{
d1++;
if (((x +3) <7) && ((y – 3)> -1))
{
if (arr [x +3, y – 3] == plr) d1++;
}
}
}
}
}
if (((x – 1)> -1) && ((y +1) <6))
{
if (arr [x – 1, y +1] == plr)
{
d1++;
if (((x – 2)> -1) && ((y +2) <6))
{
if (arr [x – 2, y +2] == plr)
{
d1++;
if (((x – 3)> -1) && ((y +3) <6))
{
if (arr [x – 3, y +3] == plr) d1++;
}
}
}
}
}
if (((x – 1)> -1) && ((y – 1)> -1))
{
if (arr [x – 1, y – 1] == plr)
{
d2++;
if (((x – 2)> -1) && ((y – 2)> -1))
{
if (arr [x – 2, y – 2] == plr)
{
d2++;
if (((x – 3)> -1) && ((y – 3)> -1))
{
if (arr [x – 3, y – 3] == plr) d2++;
}
}
}
}
}
if (((x +1) <7) && ((y +1) <6))
{
if (arr [x +1, y +1] == plr)
{
d2++;
if (((x +2) <7) && ((y +2) <6))
{
if (arr [x +2, y +2] == plr)
{
d2++;
if (((x +3) <7) && ((y +3) <6))
{
if (arr [x +3, y +3] == plr) d2++;
}
}
}
}
}
if ((y – 1)> -1) if (arr [x, y – 1] == plr)
{
d0++;
if ((y – 2)> -1) if (arr [x, y – 2] == plr)
{
d0++;
if ((y – 3)> -1)
if (arr [x, y – 3] == plr) d0++;
}
}
if (x – 1> -1)
{
if (arr [x – 1, y] == plr)
{
d3++;
if (x – 2> -1)
{
if (arr [x – 2, y] == plr)
{
d3++;
if (x – 3> -1)
if (arr [x – 3, y] == plr) d3++;
}
}
}
}
if (x +1 <7)
{
if (arr [x +1, y] == plr)
{
d3++;
if (x +2 <7)
{
if (arr [x +2, y] == plr)
{
d3++;
if (x +3 <7)
if (arr [x +3, y] == plr) d3++;
}
}
}
}
min = d0;
if (d1> min) min = d1;
if (d2> min) min = d2;
if (d3> min) min = d3;
if (min == 2) score = score – 4;
if (min> 2)
{
score = score – 70; thn [x, y] = plr;
if ((d1 <3) && (d2 <3) && (d3 <3))
score = score +10;
}
return score;
}
public int checkwin ()
{
int r, x, y;
r = 0;
for (y = 2; y> -1; y – )
{
for (x = 0; x <7; x++)
{
checku (x, y, ref r);
}
}
for (y = 0; y <6; y++)
{
for (x = 0; x <4; x++)
{
check2r (x, y, ref r);
}
}
for (y = 2; y> -1; y – )
{
for (x = 0; x <4; x++)
{
checkr (x, y, ref r);
}
}
for (y = 2; y> -1; y – )
{
for (x = 3; x <7; x++)
{
checkl (x, y, ref r);
}
}
return r;
}
public void checku (int x, int y, ref int r)
{
if ((arr [x, y] == 2) && (arr [x, y +1] == 2) &&
(arr [x, y +2] == 2) &&
(arr [x, y +3] == 2)) r = 2;
if ((arr [x, y] == 1) && (arr [x, y +1] == 1) &&
(arr [x, y +2] == 1) &&
(arr [x, y +3] == 1)) r = 1;
}
public void check2r (int x, int y, ref int r)
{
if ((arr [x, y] == 2) && (arr [x +1, y] == 2) &&
(arr [x +2, y] == 2) &&
(arr [x +3, y] == 2)) r = 2;
if ((arr [x, y] == 1) && (arr [x +1, y] == 1) &&
(arr [x +2, y] == 1) &&
(arr [x +3, y] == 1)) r = 1;
}
public void checkr (int x, int y, ref int r)
{
if ((arr [x, y] == 2) && (arr [x +1, y +1] == 2) &&
(arr [x +2, y +2] == 2) &&
(arr [x +3, y +3] == 2)) r = 2;
if ((arr [x, y] == 1) && (arr [x +1, y +1] == 1) &&
(arr [x +2, y +2] == 1) &&
(arr [x +3, y +3] == 1)) r = 1;
}
public void checkl (int x, int y, ref int r)
{
if ((arr [x, y] == 2) && (arr [x – 1, y +1] == 2) &&
(arr [x – 2, y +2] == 2) &&
(arr [x – 3, y +3] == 2)) r = 2;
if ((arr [x, y] == 1) && (arr [x – 1, y +1] == 1) &&
(arr [x – 2, y +2] == 1) && (
arr [x – 3, y +3] == 1)) r = 1;
}
}
}