public IEnumerable <Action> onFrame(ResponseObservation observation) { Stopwatch stopWatch = Stopwatch.StartNew(); actions = new List <Action>(); DrawRequest = null; TextLine = 0; long time1 = 0; long time2 = 0; long time3 = 0; try { if (observation.Observation == null) { return(actions); } if (Frame == 1) { Chat(Monday ? "Happy monday! :D" : "Good luck, have fun! :D"); } Observation = observation; ReservedMinerals = 0; ReservedGas = 0; EnemyStrategyAnalyzer.OnFrame(this); time1 = stopWatch.ElapsedMilliseconds; foreach (Manager manager in Managers) { manager.OnFrame(this); } time2 = stopWatch.ElapsedMilliseconds; Build.OnFrameBase(this); time3 = stopWatch.ElapsedMilliseconds; UnitManager.AddActions(actions); if (!Surrendered) { Surrendered = CheckSurrender(); if (Surrendered) { Chat("gg"); SurrenderedFrame = Frame; FileUtil.Register("result " + EnemyRace + " " + Build.Name() + " Defeat"); } } if (Surrendered && Frame - SurrenderedFrame >= 118) { GameConnection.RequestLeaveGame().Wait(); } TrySenDay9(); DrawText("Minerals: " + Minerals()); DrawText("Gas: " + Gas()); } catch (System.Exception e) { if (!loggedError) { FileUtil.Log("Error occured: " + e.ToString()); loggedError = true; } DebugUtil.WriteLine("Exception in OnFrame: " + e.ToString()); } Frame++; stopWatch.Stop(); totalExecutionTime += stopWatch.ElapsedMilliseconds; maxExecutionTime = System.Math.Max(maxExecutionTime, stopWatch.ElapsedMilliseconds); DrawText("Average ms per frame: " + totalExecutionTime / Frame + " Max ms per frame: " + maxExecutionTime); DrawText("Managers time: " + (time2 - time1) + " Build order time: " + (time3 - time2)); if (DrawRequest != null) { GameConnection.SendRequest(DrawRequest).Wait(); } return(actions); }
public IEnumerable <Action> onFrame(ResponseObservation observation) { Stopwatch stopWatch = Stopwatch.StartNew(); actions = new List <Action>(); DrawRequest = null; TextLine = 0; long time1 = 0; long time2 = 0; long time3 = 0; try { if (observation.Observation == null) { return(actions); } if (ProbotsChatMessages) { if (Observation.Chat != null && SendTempestText == -1) { foreach (ChatReceived chat in Observation.Chat) { if (chat.PlayerId == PlayerId) { continue; } if (chat.Message.ToLower().Contains("op strat detected")) { SendTempestText = Frame + 67; } } } if (Frame == (int)(22.4 * 30)) { if (EnemyRace == Race.Terran && !StrategyAnalysis.Cyclone.Get().DetectedPreviously && !StrategyAnalysis.Banshee.Get().DetectedPreviously && !StrategyAnalysis.Marauder.Get().DetectedPreviously) { Chat("Tempests are not OP. They are perfectly balanced, as all things should be."); } else { List <string> messages = new List <string>() { "Fun isn't something one considers when balancing the universe.", "I am inevitable.", "The hardeset choices require the strongest wills." }; int message = new System.Random().Next(messages.Count); Chat(messages[message]); } } } else if (Frame == 1) { Chat(Monday ? "Happy monday! :D" : "Good luck, have fun! :D"); } Observation = observation; ReservedMinerals = 0; ReservedGas = 0; foreach (Plugin plugin in Plugins) { plugin.OnFrame(); } EnemyStrategyAnalyzer.OnFrame(this); time1 = stopWatch.ElapsedMilliseconds; foreach (Manager manager in Managers) { manager.OnFrame(this); } time2 = stopWatch.ElapsedMilliseconds; Build.OnFrameBase(this); time3 = stopWatch.ElapsedMilliseconds; UnitManager.AddActions(actions); if (!Surrendered) { Surrendered = CheckSurrender(); if (Surrendered) { Chat("gg"); SurrenderedFrame = Frame; FileUtil.Register("result " + EnemyRace + " " + Build.Name() + " Defeat"); } } if (Surrendered && Frame - SurrenderedFrame >= 118) { GameConnection.RequestLeaveGame().Wait(); } TrySenDay9(); DrawText("Minerals: " + Minerals()); DrawText("Gas: " + Gas()); } catch (System.Exception e) { if (!loggedError) { FileUtil.Log("Error occured: " + e.ToString()); loggedError = true; } DebugUtil.WriteLine("Exception in OnFrame: " + e.ToString()); } Frame++; stopWatch.Stop(); totalExecutionTime += stopWatch.ElapsedMilliseconds; maxExecutionTime = System.Math.Max(maxExecutionTime, stopWatch.ElapsedMilliseconds); DrawText("Average ms per frame: " + totalExecutionTime / Frame + " Max ms per frame: " + maxExecutionTime); DrawText("Managers time: " + (time2 - time1) + " Build order time: " + (time3 - time2)); if (DrawRequest != null) { GameConnection.SendRequest(DrawRequest).Wait(); } return(actions); }