public CodeBrowser() : base(Constants.WINDOW_ID_CODEBROWSER, "Ribbon Codes") { STYLE_CODE.stretchWidth = false; STYLE_CODE.fixedWidth = 100; STYLE_CODE.alignment = TextAnchor.MiddleLeft; STYLE_NAME.stretchWidth = true; STYLE_NAME.alignment = TextAnchor.MiddleLeft; // // copy activitiesfor sorting into code list Log.Detail("adding action codes to code browser " + ActionPool.Instance()); foreach (Activity activity in ActivityPool.Instance()) { Pair <String, String> code = new Pair <String, String>(activity.GetCode(), activity.GetName()); codes.Add(code); } // sort by code Log.Detail("sorting codes in code browser"); codes.Sort( delegate(Pair <String, String> left, Pair <String, String> right) { return(left.first.CompareTo(right.first)); }); }
public static T CreateAction <T>(ChaActionType type) where T : IAction, new() { Queue <IAction> pool = null; if (!ActionPool.TryGetValue(type, out pool)) { pool = new Queue <IAction>(); ActionPool.Add(type, pool); } IAction action = null; if (pool.Count == 0) { action = new T(); action.SetType(type); } else { action = pool.Dequeue(); } if (action != null) { return(action as T); } return(null); }
public DpsOptimizationDeepQLearn(Client client) : base(client) { ci = client.ControlInterface; me.LuaEventListener.Bind("SWING_DAMAGE", DamageEvent); me.LuaEventListener.Bind("RANGE_DAMAGE", DamageEvent); me.LuaEventListener.Bind("SPELL_DAMAGE", DamageEvent); me.LuaEventListener.Bind("SPELL_PERIODIC_DAMAGE", DamageEvent); me.LuaEventListener.Bind("DAMAGE_SHIELD", DamageEvent); me.LuaEventListener.Bind("DAMAGE_SPLIT", DamageEvent); me.LuaEventListener.Bind("do", ControlEvent); /* * turn on no-cost spells * assume training agent has GM powers(training on own server emulator) */ ci.remoteControl.FrameScript__Execute("SendChatMessage('.cheat power on')", 0, 0); actionPool = new ActionPool(me, new[] { typeof(WrathAction), typeof(StarfireAction), }); SetupConnection(new IPEndPoint(IPAddress.Parse(ip), port)); SendObject(new { StateCount = EnvironmentState.GetTotalStateCount(), ActionCount = actionPool.ActionCount() }); ResetSession(); Console.WriteLine("Running."); this.Active = true; if (!me.GetObjectMgrAndPlayer()) { return; } GameObject target = SelectTrainingTarget(); if (target == null) { return; } currentState = EnvironmentState.GetState(me); SendObject(new { State = currentState.ToInt(), Reward = 0 }); }
// public static ActionPool Instance() { if (instance == null) { instance = new ActionPool(); Log.Info("new action pool instance created"); } return(instance); }
public static void DeleteAction(IAction action) { ChaActionType type = action.mType; Queue <IAction> pool = null; if (!ActionPool.TryGetValue(type, out pool)) { return; } pool.Enqueue(action); }
public void MouseUp() { if (Mathf.Abs(actionClone.transform.position.x - actionPoolPos.transform.position.x) <= 1.2f && Mathf.Abs(actionClone.transform.position.y - actionPoolPos.transform.position.y) <= 3.7f) { ActionPool actionPool = actionPoolPos.GetComponent <ActionPool>(); actionPool.SetToPool(left); } _hit = false; actionPoolPos.GetComponent <ActionPool>().ResetImageColor(); Destroy(actionClone); }
public DpsOptimization(Client client) : base(client) { ci = client.ControlInterface; me.LuaEventListener.Bind("SWING_DAMAGE", DamageEvent); me.LuaEventListener.Bind("RANGE_DAMAGE", DamageEvent); me.LuaEventListener.Bind("SPELL_DAMAGE", DamageEvent); me.LuaEventListener.Bind("SPELL_PERIODIC_DAMAGE", DamageEvent); me.LuaEventListener.Bind("DAMAGE_SHIELD", DamageEvent); me.LuaEventListener.Bind("DAMAGE_SPLIT", DamageEvent); me.LuaEventListener.Bind("do", ControlEvent); /* * turn on no-cost spells * assume training agent has GM powers(training on own server emulator) */ ci.remoteControl.FrameScript__Execute("SendChatMessage('.cheat power on')", 0, 0); actionPool = new ActionPool(me); QMatrix = new float[ EnvironmentState.GetTotalStateCount(), actionPool.ActionCount() ]; ResetSession(); Console.WriteLine("Running."); this.Active = true; /* * perform initial random action * initial state is needed to not perform actions prohibited by state */ if (!me.GetObjectMgrAndPlayer()) { return; } GameObject target = SelectTrainingTarget(); if (target == null) { return; } /* initialize learning */ currentState = GetState(target); }
public MainClass() { // Catch unhandled exceptions in tasks TaskScheduler.UnobservedTaskException += (sender, args) => { Console.WriteLine(args.Exception.Message); args.SetObserved(); }; // Update check Console.WriteLine("Performing startup checks..."); Updater.Instance.StartupCheck(); // Basic config IRC_HOST = "int0x10.com"; IRC_PORT = 6697; // Get instances network = NetworkManager.Instance; actions = ActionPool.Instance; // IRC upstream Console.WriteLine("Connecting to IRC..."); ircUpstream = new IrcUpstream(); ircUpstream.Connected += (sender, e) => ircUpstream.Join("#OperationMythicDawn"); ircUpstream.Connect(IRC_HOST, IRC_PORT); network.RegisterUpstream(ircUpstream); // Telnet upstream Console.WriteLine("Connecting to Telnet..."); network.RegisterUpstream(new TelnetUpstream()); // Actions Console.WriteLine("Registering actions..."); actions.Register <ActionCd> (); actions.Register <ActionPwd> (); actions.Register <ActionUpdate> (); actions.Register <ActionUpgrade> (); actions.Register <ActionAutoUpgrade> (); actions.Register <ActionKill> (); actions.Register <ActionStartArgs> (); actions.Register <ActionDetect> (); actions.Register <ActionScreen> (); actions.Register <ActionLs> (); actions.Register <ActionWhoami> (); actions.Register <ActionBroadcast> (); }
public override string ToString() { string timestamp = Utils.ConvertToEarthTime(UniversalTime) + ": "; Action action = ActionPool.Instance().GetActionForCode(Code); if (action != null) { return(timestamp + action.CreateLogBookEntry(this)); } Ribbon ribbon = RibbonPool.Instance().GetRibbonForCode(Code); if (ribbon != null) { Achievement achievement = ribbon.GetAchievement(); return(timestamp + achievement.CreateLogBookEntry(this)); } return("unknown logbook entry (code " + Code + ")"); }
public static System.Delegate ToDelegate(Type type, LuaFunction f) { return(ActionPool.ToDelegate(f, type)); }
public static Action <T1, T2, T3> ToAction <T1, T2, T3>(LuaFunction f) { return(ActionPool.ToAction <T1, T2, T3>(f)); }
public static UnityAction ToUnityAction(LuaFunction f) { return(ActionPool.ToUnityAction(f)); }
public static Action ToAction(LuaFunction f) { return(ActionPool.ToAction(f)); }
public static void CollectActionPool() { ActionPool.Collect(); }
public void CreateFromLogbook(List <LogbookEntry> book) { Log.Detail("creating hall of fame from logbook"); Clear(); lock (this) { if (book.Count == 0) { Log.Detail("no logbook entries"); return; } Log.Detail("resolving logbook"); LogbookEntry lastEntry = null; foreach (LogbookEntry log in book) { if (Log.IsLogable(Log.LEVEL.TRACE)) { Log.Trace("processing logbook entry " + log.UniversalTime + ": " + log.Code + " " + log.Name); } try { // this is a custom ribbon entry if (log.Code.StartsWith(DataChange.DATACHANGE_CUSTOMRIBBON.GetCode())) { changeCustomRibbon(log); // if (Log.IsLogable(Log.LEVEL.DETAIL)) { Log.Detail("adding custom ribbon " + log.Code + ": " + log.Name); } logbook.Add(log); // continue; } HallOfFameEntry entry = GetEntry(log.Name); if (entry == null) { entry = CreateEntry(log.Name); } Action action = ActionPool.Instance().GetActionForCode(log.Code); if (action != null) { action.DoAction(log.UniversalTime, entry, log.Data); addLogbookEntry(log, entry); } else { // those codes have change switch (log.Code) { case "CO": log.Code = "CO:Sun"; break; case "CO1": log.Code = "CO1:Sun"; break; } // Ribbon ribbon = RibbonPool.Instance().GetRibbonForCode(log.Code); if (ribbon != null) { Achievement achievement = ribbon.GetAchievement(); bool sameTransaction = InSameTransaction(log, lastEntry); if (!achievement.HasToBeFirst() || !accomplished.Contains(achievement) || sameTransaction) { // make sure old transactions have same timestamps in each entry if (sameTransaction) { log.UniversalTime = lastEntry.UniversalTime; } // entry.Award(ribbon); addLogbookEntry(log, entry); // to prevent multiple first ribbon awards accomplished.Add(ribbon.GetAchievement()); } } else { Log.Warning("no ribbon for code " + log.Code + " found"); } } } catch (KeyNotFoundException) { Log.Error("kerbal " + log.Name + " not found"); } catch (Exception e) { Log.Error("failed to create data in hall of fame for " + log.Name); Log.Error(e.GetType() + ": " + e.Message); } lastEntry = log; } // end for } Log.Detail("new hall of fame created"); }
public void Initalize() { ActionStorage = new ActionPool(this); ActionStorage.Initalize(); }
public static void Register <TAction> (this ActionPool dummy) where TAction : HostAction, new() { var action = new TAction(); ActionPool.Instance.RegisterAction(action); }