private void ExecCommand() { if (Battery.Status - Battery.Consumption(CurrentAction) < 0) { return; } Battery.Status = Battery.Status - Battery.Consumption(CurrentAction); if (CurrentAction == Action.A || CurrentAction == Action.B) { PreviousCoordinate = CurrentCoordinate; CurrentCoordinate = GetCurrentCoordinate(CurrentFacing, CurrentAction, CurrentCoordinate); } else if (CurrentAction == Action.TL || CurrentAction == Action.TR) { CurrentFacing = (Facing)Enum.Parse(typeof(Facing), FacingAction.Result[(int)CurrentFacing][(int)CurrentAction]); } if (!IsObstacle()) { if ((CurrentAction == Action.A || CurrentAction == Action.B) && (!Visited.Any(m => m.X == CurrentCoordinate.X && m.Y == CurrentCoordinate.Y))) { Visited.Add(CurrentCoordinate); } else if ((CurrentAction == Action.C) && (!Cleaned.Any(m => m.X == CurrentCoordinate.X && m.Y == CurrentCoordinate.Y))) { Cleaned.Add(CurrentCoordinate); } } }
public bool IsNew(string url) { if (Queue.Any(i => i.Value == url)) { return(false); } byte[] hash = GetMd5Hash(url); if (Visited.Any(i => i.Value.SequenceEqual(hash))) { return(false); } if (Found.Any(i => i.Value == url)) { return(false); } return(true); }
// ================================================== // Helpers public bool IsVisited(GeoCountryInfo country) { return(Visited.Any(x => x.CountryID == country.CountryID)); }