public void Reburse() { Piece.Status stat = new Piece.Status(); if (Turn == 1) { stat = Piece.Status.black; } else if (Turn == 2) { stat = Piece.Status.white; } for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { if (pieces[x, y].isPossible) { pieces[x, y].Set_Status(stat); pieces[x, y].isPossible = false; } } } }
public void Scan(int x, int y, int index) { pieces[x, y].isPossible = false; Piece.Status stat = new Piece.Status(); if (Turn == 1) { stat = Piece.Status.white; } else if (Turn == 2) { stat = Piece.Status.black; } Piece[] piece_Array = new Piece[9]; for (int i = 0; i < 9; i++) { switch (i) { case 0: piece_Array[i] = pieces[x, y]; break; case 1: if (x == 0 || y == 0) { piece_Array[i] = null; } else { piece_Array[i] = pieces[x - 1, y - 1]; } break; case 2: if (y == 0) { piece_Array[i] = null; } else { piece_Array[i] = pieces[x, y - 1]; } break; case 3: if (x == 7 || y == 0) { piece_Array[i] = null; } else { piece_Array[i] = pieces[x + 1, y - 1]; } break; case 4: if (x == 0) { piece_Array[i] = null; } else { piece_Array[i] = pieces[x - 1, y]; } break; case 5: if (x == 7) { piece_Array[i] = null; } else { piece_Array[i] = pieces[x + 1, y]; } break; case 6: if (x == 0 || y == 7) { piece_Array[i] = null; } else { piece_Array[i] = pieces[x - 1, y + 1]; } break; case 7: if (y == 7) { piece_Array[i] = null; } else { piece_Array[i] = pieces[x, y + 1]; } break; case 8: if (x == 7 || y == 7) { piece_Array[i] = null; } else { piece_Array[i] = pieces[x + 1, y + 1]; } break; } } if (index == 0) { if (piece_Array[0].status == Piece.Status.empty) { for (int j = 1; j < 9; j++) { if (piece_Array[j] != null) { if (piece_Array[j].status == stat) { switch (j) { case 1: Scan(x - 1, y - 1, j); break; case 2: Scan(x, y - 1, j); break; case 3: Scan(x + 1, y - 1, j); break; case 4: Scan(x - 1, y, j); break; case 5: Scan(x + 1, y, j); break; case 6: Scan(x - 1, y + 1, j); break; case 7: Scan(x, y + 1, j); break; case 8: Scan(x + 1, y + 1, j); break; } } else { piece_Array[j].isPossible = false; } piece_Array[0].isPossible |= piece_Array[j].isPossible; } } } else { piece_Array[0].isPossible = false; } } else { if (piece_Array[index] != null) { if (piece_Array[index].status == stat) { switch (index) { case 1: Scan(x - 1, y - 1, index); break; case 2: Scan(x, y - 1, index); break; case 3: Scan(x + 1, y - 1, index); break; case 4: Scan(x - 1, y, index); break; case 5: Scan(x + 1, y, index); break; case 6: Scan(x - 1, y + 1, index); break; case 7: Scan(x, y + 1, index); break; case 8: Scan(x + 1, y + 1, index); break; } } else if (piece_Array[index].status == Piece.Status.empty) { piece_Array[0].isPossible = false; piece_Array[index].isPossible = false; } else { piece_Array[index].isPossible = true; } piece_Array[0].isPossible |= piece_Array[index].isPossible; } else { piece_Array[0].isPossible = false; } } }