public EulerProblemEngine() { StatisticsWriter = new StatisticsWriter(); ProblemsToSolve = new Dictionary <BatchModes, List <Problem> >(); ProblemsToSolve.Add(BatchModes.All, AllProblems); ProblemsToSolve.Add(BatchModes.Slow, SlowProblems); ProblemsToSolve.Add(BatchModes.Wrong, WrongProblems); }
public EulerProblemEngine() { StatisticsWriter = new StatisticsWriter(); ProblemsToSolve = new Dictionary<BatchModes, List<Problem>>(); ProblemsToSolve.Add(BatchModes.All, AllProblems); ProblemsToSolve.Add(BatchModes.Slow, SlowProblems); ProblemsToSolve.Add(BatchModes.Wrong, WrongProblems); }
/// <summary> /// Used to setup all major components in the project. /// </summary> void Awake() { UnityEngine.Random.seed = 42; string gardenWorldXML; string projectParamsXML; string [] argv = Environment.GetCommandLineArgs(); if (argv.Length < 3) { // Files used during testing inside the Unity Editor gardenWorldXML = Path.Combine("..", "experiment_garden.xml"); projectParamsXML = Path.Combine("..", "smartmower_params.xml"); } else { // Use filenames from command line gardenWorldXML = argv[1]; projectParamsXML = argv[2]; } // Load parameters projectParamSet = new ParamSet(projectParamsXML); showUI = projectParamSet.BoolParam(ParamSet.ParamGroupSetupManager, ParamSet.ParamShowUI); autoRun = projectParamSet.BoolParam(ParamSet.ParamGroupSetupManager, ParamSet.ParamAutoRun); // Create garden garden = GardenFactory.CreateGardenFromFile(gardenWorldXML, projectParamSet); // Handle UI if (showUI) { guiGarden.Init(garden); } else { guiGarden.gameObject.SetActive(false); GameObject.Find("EpisodeLabel").SetActive(false); GameObject.Find("StepLabel").SetActive(false); } // Set episode limit EpisodeManager.EpisodeLimit = projectParamSet.IntParam(ParamSet.ParamGroupEpisodeManager, ParamSet.ParamEpisodeLimit); // Create statistics writer this.statisticsWriter = new StatisticsWriter(garden, projectParamSet); }
static void Main(string[] args) { var inputFile = args[0]; var updateDate = args[1]; var reader = new CsvReader(inputFile, ';'); var lines = reader.ReadLines(true); var scales = lines .SelectMany(l => l.Scales) .GroupBy(l => l); var generators = scales .Select(g => new ScaleFilterStatistic(g.Key)) .ToList <IStatisticGenerator>(); var authorsWithScale = scales .Where(s => s.Count() >= 10) .Select(g => new TopTenAuthorsStatistic(g.Key)) .ToList <IStatisticGenerator>(); generators.AddRange(authorsWithScale); var producersWithScale = scales .Where(s => s.Count() >= 10) .Select(g => new TopTenProducersStatistic(g.Key)) .ToList <IStatisticGenerator>(); generators.AddRange(producersWithScale); generators.Add(new ScaleCounterStatistic()); generators.Add(new TopTenAuthorsStatistic()); generators.Add(new TopTenProducersStatistic()); StatisticsWriter.WriteStatistics(ConfigurationManager.AppSettings["OutputDir"], lines, generators, updateDate); }
void Update() { GameObject helicopter = GameObject.FindGameObjectWithTag("Helicopter"); // Check if the rescue helicopter is nearby and grounded if (HelicopterController.isGrounded && Vector3.Distance(helicopter.transform.position, transform.position) < 30f) { // Get the helicopter position RunTowards(helicopter.transform.position); if (SpawnController.missingFriendlySoldiers.Contains(gameObject)) { SpawnController.missingFriendlySoldiers.Remove(gameObject); } if (SpawnController.foundFriendlySoldiers.Contains(gameObject)) { SpawnController.foundFriendlySoldiers.Remove(gameObject); } SpawnController.rescuedFriendlySoldiers.Add(gameObject); Destroy(gameObject); // Update the statistics StatisticsWriter.Rescued(); } // Go to idle state if we have reached the destination if (isMoving && destination.x - transform.position.x < 5 && destination.z - transform.position.z < 5) { state = AnimationState.IDLE; isMoving = false; } else { Travel(); } // Animate depending on state if (state == AnimationState.IDLE || !controller.isGrounded) { aniBody.CrossFade(anim.idle.name, DEFAULT_FADE_LENGTH); } else if (state == AnimationState.RUNNING) { aniBody.CrossFade(anim.run.name, DEFAULT_FADE_LENGTH); } else if (state == AnimationState.WALKING) { aniBody.CrossFade(anim.walk.name, DEFAULT_FADE_LENGTH); } else if (state == AnimationState.HIT) { aniBody.CrossFade(anim.hit.name, DEFAULT_FADE_LENGTH); } else if (state == AnimationState.DEATH) { aniBody.CrossFade(anim.death.name, DEFAULT_FADE_LENGTH); } }
void Update() { // Update the destination y to the current y (as it will depend on the terrain) destination.y = transform.position.y; // If we have just spawned at the helicopter if (initial) { if (controller.isGrounded) { initial = false; } else { destination.x = transform.position.x + xOffset; destination.z = transform.position.z + zOffset; } } else { // Check if this drone has found a target if (Vector3.Distance(transform.position, destination) < 1f) { switch (SpawnController.droneStrategy) { case SpawnController.DroneStrategy.RANDOM: // Pick a random point within the terrain to be the next destination destination = new Vector3(Random.Range(SpawnController.MIN_X, SpawnController.MAX_X), 0f, Random.Range(SpawnController.MIN_Z, SpawnController.MAX_Z)); break; case SpawnController.DroneStrategy.ZONES: destination = new Vector3(Random.Range(SpawnController.currentZone.MIN_X, SpawnController.currentZone.MAX_X), 0f, Random.Range(SpawnController.currentZone.MIN_Z, SpawnController.currentZone.MAX_Z)); break; } } // Check if the velocity of the drone has decreased below the allowed threshold else if (velocity < 1f) { switch (SpawnController.droneStrategy) { case SpawnController.DroneStrategy.RANDOM: // Pick a random point within the terrain to be the next destination destination = new Vector3(Random.Range(SpawnController.MIN_X, SpawnController.MAX_X), 0f, Random.Range(SpawnController.MIN_Z, SpawnController.MAX_Z)); break; case SpawnController.DroneStrategy.ZONES: // destination = new Vector3(Random.Range (SpawnController.currentZone.MIN_X, SpawnController.currentZone.MAX_X), // 0f, // Random.Range (SpawnController.currentZone.MIN_Z, SpawnController.currentZone.MAX_Z)); int currentZoneIndex = SpawnController.zones.IndexOf(SpawnController.currentZone); float minX = 0; float maxX = 0; float minZ = 0; float maxZ = 0; if (currentZoneIndex > 0) { minX = SpawnController.zones[currentZoneIndex - 1].MIN_X; } else { minX = SpawnController.zones[SpawnController.zones.Count - 1].MIN_X; } if (currentZoneIndex < SpawnController.zones.Count - 1) { maxX = SpawnController.zones[currentZoneIndex + 1].MAX_X; } else { maxX = SpawnController.zones[0].MAX_X; } minZ = SpawnController.MIN_Z; maxZ = SpawnController.MAX_Z; destination = new Vector3(Random.Range(minX, maxX), 0f, Random.Range(minZ, maxZ)); break; } } // Check for soldiers in the cameras view GameObject[] soldiers = GameObject.FindGameObjectsWithTag("Friendly"); for (int i = 0; i < soldiers.Length; i++) { SoldierController soldierController = soldiers[i].GetComponent <SoldierController>(); if (soldierController.status == SoldierController.Status.NOT_FOUND) { if (CheckLineOfSight(soldiers[i])) { soldierController.status = SoldierController.Status.FOUND; SpawnController.missingFriendlySoldiers.Remove(soldiers[i]); SpawnController.foundFriendlySoldiers.Add(soldiers[i]); SpawnController.foundFriendlySoldierCount++; // Mark this as an area of interest to search around areaOfInterest = soldiers[i].transform.position; areaOfInterestSearch = true; // Update Statistics StatisticsWriter.Found(); } } } } previousPosition = transform.position; Travel(); // Calculate the current velocity velocity = (Vector3.Distance(transform.position, previousPosition)) / Time.deltaTime; }
public static void Login() { LocalizationController.SetLanguage(Core.Config.language); Logger.Logger.Info("Logining "); // Get big token var tempuid = string.Empty; var baseAddress = new Uri("https://portal.pixelfederation.com/"); var cookieContainer = new CookieContainer(); var loc_cookies = Cookies.ReadCookiesFromDisk(); //var pxcookie = loc_cookies.GetCookies(new Uri("https://portal.pixelfederation.com")); //if (pxcookie.Count != 0) //{ // if (pxcookie["_pf_login_server_token"].Value == Core.Config.server_token) // { // cookieContainer = loc_cookies; // } //} using (var handler = new HttpClientHandler { CookieContainer = cookieContainer }) using (var client = new HttpClient(handler) { BaseAddress = baseAddress }) { cookieContainer.Add(baseAddress, new Cookie("_pf_login_server_token", Core.Config.server_token)); Logger.Logger.Info(Localization.NETWORKING_LOGIN_1); client.DefaultRequestHeaders.UserAgent.ParseAdd( "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36"); try { var result = client.GetAsync("en/seaport/").Result; result = client.GetAsync("en/seaport/").Result; Logger.Logger.Info(Localization.NETWORKING_LOGIN_2); var stringtext = result.Content.ReadAsStringAsync().Result; var regex = new Regex( "portal.pixelfederation.com\\/(_sp\\/\\?direct_login=portal&portal_request=(.*))\" allowfullscreen>"); var match = regex.Match(stringtext); if (match.Success) { var data = client.GetAsync(match.Groups[1].Value).Result.Content.ReadAsStringAsync().Result; Logger.Logger.Info(Localization.NETWORKING_LOGIN_3); regex = new Regex(@"session_id': '(.*)', 'test"); Core.Ssid = regex.Match(data).Groups[1].Value; regex = new Regex(@"pid': '(.*)', 'platform"); tempuid = regex.Match(data).Groups[1].Value; Logger.Logger.Info(Localization.NETWORKING_LOGIN_SUCCESS + Core.Ssid); regex = new Regex(@"'definition_filelist_url1': 'https:\/\/r4a4v3g4\.ssl\.hwcdn\.net\/definitions\/filelists\/(.+)\.xml', 'definition_filelist_url2'"); var mtch = regex.Match(data); if (mtch.Success) { DefenitionCache.Update(mtch.Groups[1].Value); } regex = new Regex( @"loca_filelist_url2': 'https:\/\/static\.seaportgame\.com\/localization\/(.+?)\.xml', '"); mtch = regex.Match(data); if (mtch.Success) { LocalizationCache.Update(mtch.Groups[1].Value); } regex = new Regex("clientPath = \"(.+)\";"); mtch = regex.Match(data); if (mtch.Success) { Client.DefaultRequestHeaders.Referrer = new Uri(mtch.Groups[1].Value); } Client.DefaultRequestHeaders.Host = "portal.pixelfederation.com"; Client.DefaultRequestHeaders.Add("Origin", "https://r4a4v3g4.ssl.hwcdn.net"); Client.DefaultRequestHeaders.AcceptEncoding.TryParseAdd("gzip, deflate, br"); Client.DefaultRequestHeaders.Accept.TryParseAdd(@"*/*"); Client.DefaultRequestHeaders.AcceptLanguage.TryParseAdd( "en-GB,en-US;q=0.9,en;q=0.8,ru;q=0.7,uk;q=0.6"); Client.DefaultRequestHeaders.Add("DNT", "1"); Client.DefaultRequestHeaders.Add("X-Requested-With", "ShockwaveFlash/32.0.0.114"); } else { Logger.Logger.Fatal(Localization.NETWORKING_LOGIN_CANT_LOGIN); return; } } catch (Exception e) { Logger.Logger.Fatal(Localization.NETWORKING_LOGIN_CANT_LOGIN + e); } } var values = new Dictionary <string, string> { { "pid", tempuid }, { "session_id", Core.Ssid } }; var s = SendRequest(values, "client.login"); SendRequest(values, "client.update"); if (s.StartsWith("<xml>")) { Core.GlobalData = Parser.ParseXmlToGlobalData(s); var rand = new Random(); var loadtime = rand.Next(5000, 13000); if (!Core.Debug) { Logger.Logger.Info(string.Format(Localization.NETWORKING_LOGIN_FAKE_LOAD, loadtime / 1000D)); Thread.Sleep(loadtime); Logger.Logger.Info( string.Format(Localization.NETWORKING_LOGIN_FAKE_LOAD_ELAPSED, loadtime / 1000D)); } values.Add("loading_time", loadtime.ToString()); SendRequest(values, "tracking.finishedLoading"); Cookies.WriteCookiesToDisk(cookieContainer); Events.Events.LoginedEvent.Logined.Invoke(); StatisticsWriter.Start(); } else { Logger.Logger.Fatal("Server responded " + s); Core.StopBot(); } }
public Interfaces.IWriter CreateWriter() { writer = new StatisticsWriter(config, receiver); return(writer); }