public MoveSmell SmellMove(ChessColor color, int h1, int v1, int h2, int v2) { if (SmellMoveWeak(color, h1, v1, h2, v2) == MoveSmell.Incorrect) { return(MoveSmell.Incorrect); } using (TempMove(h1, v1, h2, v2)) { if (IsUnderCheck(color)) { return(MoveSmell.Incorrect); } if (IsUnderCheck(color.Switch())) { if (!MovesExist(color.Switch())) { return(MoveSmell.Mate); } return(MoveSmell.Check); } else if (!MovesExist(color.Switch())) { return(MoveSmell.Draw); } return(MoveSmell.Correct); } }
bool IsUnderCheck(ChessColor color) { for (int i = 0; i < Size; i++) { for (int j = 0; j < Size; j++) { for (int i_ = 0; i_ < Size; i_++) { for (int j_ = 0; j_ < Size; j_++) { if (m[i, j] is King && m[i, j].Color == color && SmellMoveWeak(color.Switch(), i_, j_, i, j) == MoveSmell.Correct) { return(true); } } } } } return(false); }