|
|
@ -54,7 +54,7 @@ namespace Reversi |
|
|
|
for (int j = -1; j <= 1; j = (j + 1)) { |
|
|
|
for (int j = -1; j <= 1; j = (j + 1)) { |
|
|
|
if (((i || j) && (@this.IsOutflanking(color, row, col, i, j)))) { |
|
|
|
if (((i || j) && (@this.IsOutflanking(color, row, col, i, j)))) { |
|
|
|
int k = (row + i); |
|
|
|
int k = (row + i); |
|
|
|
for (int l = (col + j); ((@this.squares).Get(k, l)) == (-color); l = (l + j)) { |
|
|
|
for (int l = (col + j); ((@this.squares).Get(k, l)) == -color; l = (l + j)) { |
|
|
|
(@this.squares).Set(k, l, color); |
|
|
|
(@this.squares).Set(k, l, color); |
|
|
|
k = (k + i); |
|
|
|
k = (k + i); |
|
|
|
} |
|
|
|
} |
|
|
@ -103,10 +103,10 @@ namespace Reversi |
|
|
|
private bool IsOutflanking(int color, int row, int col, int dr, int dc) |
|
|
|
private bool IsOutflanking(int color, int row, int col, int dr, int dc) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i = (row + dr); |
|
|
|
int i = (row + dr); |
|
|
|
for (int j = (col + dc); ((((i >= 0) && (i < 8)) && (j >= 0)) && (j < 8)) && (((@this.squares).Get(i, j)) == (-color)); j = (j + dc)) { |
|
|
|
for (int j = (col + dc); (((i >= 0 && i < 8) && j >= 0) && j < 8) && ((@this.squares).Get(i, j)) == -color; j = (j + dc)) { |
|
|
|
i = (i + dr); |
|
|
|
i = (i + dr); |
|
|
|
} |
|
|
|
} |
|
|
|
if (((((((i < 0) || (i > 7)) || (j < 0)) || (j > 7)) || (((i - dr) == row) && ((j - dc) == col))) || (((@this.squares).Get(i, j)) != color))) { |
|
|
|
if ((((((i < 0 || i > 7) || j < 0) || j > 7) || i - dr == row && j - dc == col) || ((@this.squares).Get(i, j)) != color)) { |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
@ -124,7 +124,7 @@ namespace Reversi |
|
|
|
V_2 = 0; |
|
|
|
V_2 = 0; |
|
|
|
for (int i = 0; i < 8; i = (i + 1)) { |
|
|
|
for (int i = 0; i < 8; i = (i + 1)) { |
|
|
|
for (int j = 0; j < 8; j = (j + 1)) { |
|
|
|
for (int j = 0; j < 8; j = (j + 1)) { |
|
|
|
if (((!(((@this.squares).Get(i, j)) == IL__ldsfld(Empty)) && (!((@this.safeDiscs).Get(i, j)))) && (!(@this.IsOutflankable(i, j))))) { |
|
|
|
if (((!(((@this.squares).Get(i, j)) == IL__ldsfld(Empty)) && !((@this.safeDiscs).Get(i, j))) && !(@this.IsOutflankable(i, j)))) { |
|
|
|
(@this.safeDiscs).Set(i, j, 1); |
|
|
|
(@this.safeDiscs).Set(i, j, 1); |
|
|
|
V_2 = 1; |
|
|
|
V_2 = 1; |
|
|
|
} |
|
|
|
} |
|
|
@ -139,7 +139,7 @@ namespace Reversi |
|
|
|
if ((!(((@this.squares).Get(i, j)) == IL__ldsfld(Empty)))) { |
|
|
|
if ((!(((@this.squares).Get(i, j)) == IL__ldsfld(Empty)))) { |
|
|
|
for (int k = -1; k <= 1; k = (k + 1)) { |
|
|
|
for (int k = -1; k <= 1; k = (k + 1)) { |
|
|
|
for (int l = -1; l <= 1; l = (l + 1)) { |
|
|
|
for (int l = -1; l <= 1; l = (l + 1)) { |
|
|
|
if (((((((k || l) && ((i + k) >= 0)) && ((i + k) < 8)) && ((j + l) >= 0)) && ((j + l) < 8)) && !(((@this.squares).Get((i + k), (j + l))) != IL__ldsfld(Empty)))) { |
|
|
|
if (((((((k || l) && i + k >= 0) && i + k < 8) && j + l >= 0) && j + l < 8) && !(((@this.squares).Get((i + k), (j + l))) != IL__ldsfld(Empty)))) { |
|
|
|
V_5 = 1; |
|
|
|
V_5 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -201,56 +201,56 @@ namespace Reversi |
|
|
|
bool V_5 = 0; |
|
|
|
bool V_5 = 0; |
|
|
|
bool V_4 = 0; |
|
|
|
bool V_4 = 0; |
|
|
|
bool V_6 = 0; |
|
|
|
bool V_6 = 0; |
|
|
|
for (int k = 0; (k < col) && (!V_3); k = (k + 1)) { |
|
|
|
for (int k = 0; k < col && !V_3; k = (k + 1)) { |
|
|
|
if ((!(((@this.squares).Get(row, k)) != IL__ldsfld(Empty)))) { |
|
|
|
if ((!(((@this.squares).Get(row, k)) != IL__ldsfld(Empty)))) { |
|
|
|
V_3 = 1; |
|
|
|
V_3 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
if (((((@this.squares).Get(row, k)) != i) || (!((@this.safeDiscs).Get(row, k))))) { |
|
|
|
if ((((@this.squares).Get(row, k)) != i || !((@this.safeDiscs).Get(row, k)))) { |
|
|
|
V_5 = 1; |
|
|
|
V_5 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
k = (col + 1); |
|
|
|
k = (col + 1); |
|
|
|
for (; (k < 8) && (!V_4); k = (k + 1)) { |
|
|
|
for (; k < 8 && !V_4; k = (k + 1)) { |
|
|
|
if ((!(((@this.squares).Get(row, k)) != IL__ldsfld(Empty)))) { |
|
|
|
if ((!(((@this.squares).Get(row, k)) != IL__ldsfld(Empty)))) { |
|
|
|
V_4 = 1; |
|
|
|
V_4 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
if (((((@this.squares).Get(row, k)) != i) || (!((@this.safeDiscs).Get(row, k))))) { |
|
|
|
if ((((@this.squares).Get(row, k)) != i || !((@this.safeDiscs).Get(row, k)))) { |
|
|
|
V_6 = 1; |
|
|
|
V_6 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if ((((V_3 && V_4) || (V_3 && V_6)) || (V_5 && V_4))) { |
|
|
|
if (((V_3 && V_4 || V_3 && V_6) || V_5 && V_4)) { |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
V_3 = 0; |
|
|
|
V_3 = 0; |
|
|
|
V_4 = 0; |
|
|
|
V_4 = 0; |
|
|
|
V_5 = 0; |
|
|
|
V_5 = 0; |
|
|
|
V_6 = 0; |
|
|
|
V_6 = 0; |
|
|
|
for (int j = 0; (j < row) && (!V_3); j = (j + 1)) { |
|
|
|
for (int j = 0; j < row && !V_3; j = (j + 1)) { |
|
|
|
if ((!(((@this.squares).Get(j, col)) != IL__ldsfld(Empty)))) { |
|
|
|
if ((!(((@this.squares).Get(j, col)) != IL__ldsfld(Empty)))) { |
|
|
|
V_3 = 1; |
|
|
|
V_3 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
if (((((@this.squares).Get(j, col)) != i) || (!((@this.safeDiscs).Get(j, col))))) { |
|
|
|
if ((((@this.squares).Get(j, col)) != i || !((@this.safeDiscs).Get(j, col)))) { |
|
|
|
V_5 = 1; |
|
|
|
V_5 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
j = (row + 1); |
|
|
|
j = (row + 1); |
|
|
|
for (; (j < 8) && (!V_4); j = (j + 1)) { |
|
|
|
for (; j < 8 && !V_4; j = (j + 1)) { |
|
|
|
if ((!(((@this.squares).Get(j, col)) != IL__ldsfld(Empty)))) { |
|
|
|
if ((!(((@this.squares).Get(j, col)) != IL__ldsfld(Empty)))) { |
|
|
|
V_4 = 1; |
|
|
|
V_4 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
if (((((@this.squares).Get(j, col)) != i) || (!((@this.safeDiscs).Get(j, col))))) { |
|
|
|
if ((((@this.squares).Get(j, col)) != i || !((@this.safeDiscs).Get(j, col)))) { |
|
|
|
V_6 = 1; |
|
|
|
V_6 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if ((((V_3 && V_4) || (V_3 && V_6)) || (V_5 && V_4))) { |
|
|
|
if (((V_3 && V_4 || V_3 && V_6) || V_5 && V_4)) { |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
V_3 = 0; |
|
|
|
V_3 = 0; |
|
|
@ -259,12 +259,12 @@ namespace Reversi |
|
|
|
V_6 = 0; |
|
|
|
V_6 = 0; |
|
|
|
j = (row - 1); |
|
|
|
j = (row - 1); |
|
|
|
k = (col - 1); |
|
|
|
k = (col - 1); |
|
|
|
for (; ((j >= 0) && (k >= 0)) && (!V_3); k = (k - 1)) { |
|
|
|
for (; (j >= 0 && k >= 0) && !V_3; k = (k - 1)) { |
|
|
|
if ((!(((@this.squares).Get(j, k)) != IL__ldsfld(Empty)))) { |
|
|
|
if ((!(((@this.squares).Get(j, k)) != IL__ldsfld(Empty)))) { |
|
|
|
V_3 = 1; |
|
|
|
V_3 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
if (((((@this.squares).Get(j, k)) != i) || (!((@this.safeDiscs).Get(j, k))))) { |
|
|
|
if ((((@this.squares).Get(j, k)) != i || !((@this.safeDiscs).Get(j, k)))) { |
|
|
|
V_5 = 1; |
|
|
|
V_5 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -272,18 +272,18 @@ namespace Reversi |
|
|
|
} |
|
|
|
} |
|
|
|
j = (row + 1); |
|
|
|
j = (row + 1); |
|
|
|
k = (col + 1); |
|
|
|
k = (col + 1); |
|
|
|
for (; ((j < 8) && (k < 8)) && (!V_4); k = (k + 1)) { |
|
|
|
for (; (j < 8 && k < 8) && !V_4; k = (k + 1)) { |
|
|
|
if ((!(((@this.squares).Get(j, k)) != IL__ldsfld(Empty)))) { |
|
|
|
if ((!(((@this.squares).Get(j, k)) != IL__ldsfld(Empty)))) { |
|
|
|
V_4 = 1; |
|
|
|
V_4 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
if (((((@this.squares).Get(j, k)) != i) || (!((@this.safeDiscs).Get(j, k))))) { |
|
|
|
if ((((@this.squares).Get(j, k)) != i || !((@this.safeDiscs).Get(j, k)))) { |
|
|
|
V_6 = 1; |
|
|
|
V_6 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
j = (j + 1); |
|
|
|
j = (j + 1); |
|
|
|
} |
|
|
|
} |
|
|
|
if ((((V_3 && V_4) || (V_3 && V_6)) || (V_5 && V_4))) { |
|
|
|
if (((V_3 && V_4 || V_3 && V_6) || V_5 && V_4)) { |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
V_3 = 0; |
|
|
|
V_3 = 0; |
|
|
@ -292,12 +292,12 @@ namespace Reversi |
|
|
|
V_6 = 0; |
|
|
|
V_6 = 0; |
|
|
|
j = (row - 1); |
|
|
|
j = (row - 1); |
|
|
|
k = (col + 1); |
|
|
|
k = (col + 1); |
|
|
|
for (; ((j >= 0) && (k < 8)) && (!V_3); k = (k + 1)) { |
|
|
|
for (; (j >= 0 && k < 8) && !V_3; k = (k + 1)) { |
|
|
|
if ((!(((@this.squares).Get(j, k)) != IL__ldsfld(Empty)))) { |
|
|
|
if ((!(((@this.squares).Get(j, k)) != IL__ldsfld(Empty)))) { |
|
|
|
V_3 = 1; |
|
|
|
V_3 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
if (((((@this.squares).Get(j, k)) != i) || (!((@this.safeDiscs).Get(j, k))))) { |
|
|
|
if ((((@this.squares).Get(j, k)) != i || !((@this.safeDiscs).Get(j, k)))) { |
|
|
|
V_5 = 1; |
|
|
|
V_5 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -305,18 +305,18 @@ namespace Reversi |
|
|
|
} |
|
|
|
} |
|
|
|
j = (row + 1); |
|
|
|
j = (row + 1); |
|
|
|
k = (col - 1); |
|
|
|
k = (col - 1); |
|
|
|
for (; ((j < 8) && (k >= 0)) && (!V_4); k = (k - 1)) { |
|
|
|
for (; (j < 8 && k >= 0) && !V_4; k = (k - 1)) { |
|
|
|
if ((!(((@this.squares).Get(j, k)) != IL__ldsfld(Empty)))) { |
|
|
|
if ((!(((@this.squares).Get(j, k)) != IL__ldsfld(Empty)))) { |
|
|
|
V_4 = 1; |
|
|
|
V_4 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
if (((((@this.squares).Get(j, k)) != i) || (!((@this.safeDiscs).Get(j, k))))) { |
|
|
|
if ((((@this.squares).Get(j, k)) != i || !((@this.safeDiscs).Get(j, k)))) { |
|
|
|
V_6 = 1; |
|
|
|
V_6 = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
j = (j + 1); |
|
|
|
j = (j + 1); |
|
|
|
} |
|
|
|
} |
|
|
|
if ((((V_3 && V_4) || (V_3 && V_6)) || (V_5 && V_4))) { |
|
|
|
if (((V_3 && V_4 || V_3 && V_6) || V_5 && V_4)) { |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|