public void PrepareStrictLAP(AgentBase agent) { done = false; if (agent is Agent) { lapSDC = (agent as Agent).dc; DismantleSDC(); } }
public void PrepareScheduledLap(AgentBase agent) { done = false; if (agent is Agent) { lapDC = (agent as POSH.sys.scheduled.Agent).dc; //DismantleDC(); } //TODO: needs to be done once scheduled mode works in POSH# }
public override void Execute(AgentBase agent) { base.Execute(agent); if (agent.Behavior.GetType() == typeof(PathFollowingBehaviour)) { var tempBehaviour = (PathFollowingBehaviour)agent.Behavior; if (tempBehaviour.Finished()) { UICore.GetInstance().Log(agent.Name + ": I need to repair my ride.."); agent.StateMachine.ChangeState(new RepairingVehicle()); } } }
public SubMove(AgentBase agentBase, NavNode startingNode, object agentStartingData, NavNode destinationNode, Vector3Int dir, bool moveCritical = true, SubMove criticalFor = null, SubMove reliesOn = null, int subMovePriority = 0) { this.agentStartingData = agentStartingData; this.subMovePriority = subMovePriority; this.criticalFor = criticalFor; SetReliesOn(reliesOn); finishedExecuting = false; //todo change this language to finishedAnimation or something more clear, inconsistent use of the word executing. this.moveCritical = moveCritical; this.dir = dir; //uh, we can just calculate this from destination-starting? I wont jic teleportation becomes like, a move? so we would pass in the previous ... direction entering the teleporter? this.agent = agentBase; this.startingNode = startingNode; this.destinationNode = destinationNode; }
public override void Execute(AgentBase agent) { base.Execute(agent); if (agent.Behavior.GetType() == typeof(PathFollowingBehaviour)) { var tempBehaviour = (PathFollowingBehaviour)agent.Behavior; if (tempBehaviour.Finished()) { agent.StateMachine.ChangeState(new ReachedFinish()); UICore.GetInstance().Log(agent.Name + ": I finished a lap!"); } } }
// Constructor overload for attack possibillity public PossibilityModel(PossibilityType type, Vector3 targetPos, AgentBase targetAgent) { this.Type = type; if (targetPos != null) { this.TargetPos = targetPos; } if (targetAgent != null) { this.TargetAgent = targetAgent; } }
public override void Setup(AgentBase agent) { waitingFor = 0; waitTime = (1 / agent.speed) * waitMultiplier; degrees = 90; agent.PlaySound(sounds[Random.Range(0, sounds.Length)]); agent.anim.Play("IrisBotTurn"); if (agent.popup != null) { Debug.Log("dicks"); agent.popup.SetPopupTexture(texture); } }
public static AgentBase GetRandomAgentTemplateFromGroup(List <AgentTemplate> atmass, int group_id, Scenario scenario) { int j = 0; Random rand = new Random(); double value = rand.Next(1, 101); while (value > 0 && j < atmass.Count) { value -= atmass[j].Persent; j++; } j--; int AgentSpeedms = Convert.ToInt32(MapOld.CellSize * 3600 * 1000 / (rand.Next(Convert.ToInt32(atmass[j].MinSpeed * 1000), Convert.ToInt32(atmass[j].MaxSpeed * 1000)))); AgentBase agent = null; if (atmass[j].Type == typeof(HumanAgent).Name) { agent = new HumanAgent(AgentIDEnumerator.GetNextID(), scenario, group_id, AgentSpeedms); } else if (atmass[j].Type == typeof(BusAgent).Name) { agent = new BusAgent(AgentIDEnumerator.GetNextID(), scenario, group_id, AgentSpeedms) { RoadGraph = scenario.RoadGraph, Size = new System.Windows.Media.Media3D.Size3D(atmass[j].Length / MapOld.CellSize, atmass[j].Width / MapOld.CellSize, atmass[j].Height / MapOld.CellSize), MaxCapasity = atmass[j].Capasity, InputFactor = atmass[j].InputFactor, OutputFactor = atmass[j].OutputFactor }; } else if (atmass[j].Type == typeof(TrainAgent).Name) { agent = new TrainAgent(AgentIDEnumerator.GetNextID(), scenario, group_id, AgentSpeedms, atmass[j].NumberOfCarriges) { RoadGraph = scenario.RoadGraph, Size = new System.Windows.Media.Media3D.Size3D(atmass[j].Length / MapOld.CellSize, atmass[j].Width / MapOld.CellSize, atmass[j].Height / MapOld.CellSize), MaxCapasity = atmass[j].Capasity, InputFactor = atmass[j].InputFactor, OutputFactor = atmass[j].OutputFactor }; } if (agent != null) { agent.WayPointsList = new List <WayPoint>(); foreach (var wp in atmass[j].WayPointsList) { agent.WayPointsList.Add((WayPoint)wp.Clone()); } } return(agent); }
private void TradeResources(AgentType wantedAgentType, PropertyType giveProperty, PropertyType takeProperty, int amountToTrade, bool isGiving = false) { int?[] agentsOnTile = ReverseLookup.Instance.AgentsOnTile(attachedBase); if (agentsOnTile == null) { Debug.Log("There's no Task Object on this Tile with AgentID " + attachedBase.ID); return; } foreach (var agent in agentsOnTile) { if (agent == null) { continue; } AgentBase tradingAgent = Simulation.Instance.GetAgent((int)agent); if (tradingAgent.type != wantedAgentType) { continue; } AgentProperty givingProperty; AgentProperty takingProperty; if (isGiving) { givingProperty = attachedBase.GetPropertyofType(giveProperty); takingProperty = tradingAgent.GetPropertyofType(takeProperty); } else { givingProperty = tradingAgent.GetPropertyofType(giveProperty); takingProperty = attachedBase.GetPropertyofType(takeProperty); } takingProperty.TakeWeight(givingProperty.GiveWeight(amountToTrade)); if (giveProperty == PropertyType.Pollen && isGiving) { GlobalResources.Instance.TotalPollen += amountToTrade; Debug.Log("Global Resources Updated"); } return; } Debug.Log("Something went wrong completing the task for AgentID" + attachedBase.ID); }
public async Task <bool> Predict(AgentBase agent, NlpDoc doc, PipeModel meta) { Init(); doc.Tokenizer = this; // same as train doc.Sentences.ForEach(snt => { snt.Tokens = _tokenizer.Tokenize(snt.Text); }); return(true); }
public bool GetValidSubMove(AgentBase agentBase, out SubMove subMove) { if (_allSubMoves.ContainsKey(agentBase)) { if (_allSubMoves[agentBase].Valid) { subMove = _allSubMoves[agentBase]; return(true); } } subMove = null; return(false); }
public void ClearAgentHere(AgentBase agentBase) { //todo Assert(tileAgent == agentHere); //bothering with these 'interface' functions specifically for possible future handling of multiple occupied tileAgents if (AgentBaseHere == agentBase) { AgentBaseHere = null; IsAgentHere = false; } else { Debug.LogWarning("Sanity Check. Tried to clear an agent from where it wasn't."); } }
public override void Setup(AgentBase agent) { //Debug.Log("setup rotat"); bulletShot = false; waitingFor = 0; waitTime = (1 / agent.speed) * waitMultiplier; postShotWaitTime = waitTime; agent.PlaySound(sounds[Random.Range(0, sounds.Length)]); agent.anim.Play("IrisBotTurn"); if (agent.popup != null) { agent.popup.SetPopupTexture(texture); } }
public void Execute(AgentBase agent) { agent.FinishedLaps++; Debug.Log("IS FINISHED!, wear of the agent is now: " + agent.Wear + ", finished laps: " + agent.FinishedLaps); if (agent.Wear < 50) { // Here has to come logic if wear is lower than x agent.StateMachine.ChangeState(new DrivingToFinish()); } else { agent.StateMachine.ChangeState(new DrivingToPitstop()); } }
public RemoveAgent(AgentBase agentBase, string animation = "") { IsValid = true; executed = false; HistoryPoint = false; if (agentBase.isActiveAndEnabled == false) { IsValid = false; } _agent = agentBase; _agentAnim = agentBase as IRemoveWithAnimation; removeWithAnimation = _agentAnim != null; //This boolean only exists so we only do this null check once. It's a minor optimization that I am writing early on in my code, just to make myself feel better. _anim = animation; }
public AgentVisualBase(AgentBase agentBase) { this.agentBase = agentBase; if (agentBase is HumanAgent) { this.Location = new Point(agentBase.GetCell().X, agentBase.GetCell().Y); } else if (agentBase is BusAgent) { this.Location = agentBase.GetPosition(); } System.Windows.Controls.ToolTip tip = new System.Windows.Controls.ToolTip(); tip.Content = string.Format("id:{0} group:{1} location:{2},{3} speed:{4}", agentBase.ID, agentBase.Group, agentBase.GetCell().X, agentBase.GetCell().Y, Math.Round(MapOld.CellSize * 3600 / agentBase.MaxSpeed, 2)); this.ToolTip = tip; }
public void PopulateBumblr(GameObject bee) { //populate with agent stuff AgentBase beeAgent = bee.GetComponent <AgentBase>(); AgentBrain beeBrain = bee.GetComponent <AgentBrain>(); beeNameTxt.text = beeAgent.info.name; beeAgeTxt.text = beeAgent.info.capacity.ToString(); beePhysicalTxt.text = beeAgent.info.trait; beeTaskTxt.text = beeBrain.currentTask.type.ToString(); beeBumblrTxt.text = "BumblrText"; //for(int i = 0; i < beeAgent.bumblrText.Count; i++) //{ // PrintToBumblr(beeAgent.bumblrText[i]); //} }
public override void Setup(AgentBase agent) { //Debug.Log("setup loop action"); //Debug.Log(loopAmount); timesRun = 1; iterator = 0; if (loopStates != null) { if (loopStates.Count > 0) { currentState = loopStates[iterator]; currentState.Setup(agent); } } iterator++; }
/// <summary> /// Convert an object that implements IPossbilityTarget /// to a possibility model that is usable by the /// Utiltiy calculation static method /// </summary> public static PossibilityModel GetPossibilityModel(GameObject obj) { if (obj == null) { return(null); } // The interface held by every possible // target for an action IPossibilityTarget target = obj.GetComponent <IPossibilityTarget>(); PossibilityModel model; if (target == null) { return(null); } // Create an item possibility if (target.Type == PossibilityType.APPLY_ITEM) { Item targetItem = obj.GetComponent <Item>(); Vector3 targetPos = obj.transform.position; // Use the default constructor to create // a new possibility model for this item model = new PossibilityModel(target.Type, targetItem, targetPos); } // Create an attack possibility else if (target.Type == PossibilityType.ATTACK) { Vector3 targetPos = obj.transform.position; AgentBase targetAgent = obj.GetComponent <AgentBase>(); // Use the overload constructor to create // a new possbility model for this enemy agent model = new PossibilityModel(target.Type, targetPos, targetAgent); model.EnergyCost = ENERGY_COST_ATTACK; //Debug.Log("Created a new attack possibility for agent: " + obj.name); } else { return(null); } return(model); }
public ActionResult SaveGeneral(string ImprovementId, string Alias, string Introduction, string SourceComponentId) { try { AgentBase ABase = new AgentBase(); DatabaseContext dbx = ABase.GetContext(); int nImprovementId = -1; if (ImprovementId.Length > 0) { nImprovementId = Convert.ToInt32(ImprovementId); } if (nImprovementId == -1) { int nSourceComponentId = Convert.ToInt32(SourceComponentId); Reco3Component reco3Component = dbx.CloneComponent(nSourceComponentId); if (reco3Component != null) { Reco3Improvement improvement = new Reco3Improvement(); improvement.Name = Alias; improvement.ValidFrom = DateTime.Parse(Introduction); improvement.Reco3Component = reco3Component; improvement.ComponentId = reco3Component.ComponentId; dbx.Reco3Improvements.Add(improvement); dbx.SaveChanges(); return(Json(new { success = true, message = "Improvement successfully saved." }, JsonRequestBehavior.AllowGet)); } } else { Reco3Improvement improvement = dbx.Reco3Improvements.Include("Reco3Component").Where(x => x.ImprovementId == nImprovementId).FirstOrDefault(); if (improvement != null) { improvement.Name = Alias; improvement.ValidFrom = DateTime.Parse(Introduction); dbx.Entry(improvement).State = System.Data.Entity.EntityState.Modified; dbx.SaveChanges(); return(Json(new { success = true, message = "Improvement successfully saved." }, JsonRequestBehavior.AllowGet)); } } } catch (Exception e) { Console.WriteLine(e); return(Json(new { success = false, message = e.Message }, JsonRequestBehavior.AllowGet)); } return(RedirectToAction("Index")); }
public async Task <bool> Train(AgentBase agent, NlpDoc doc, PipeModel meta) { var corpus = agent.Corpus; meta.Model = "ner-crf.model"; List <TrainingIntentExpression <TrainingIntentExpressionPart> > userSays = corpus.UserSays; List <List <TrainingData> > list = new List <List <TrainingData> >(); string rawTrainingDataFileName = System.IO.Path.Combine(Settings.ModelDir, "ner-crf.corpus.txt"); string modelFileName = System.IO.Path.Combine(Settings.ModelDir, meta.Model); using (FileStream fs = new FileStream(rawTrainingDataFileName, FileMode.Create)) { using (StreamWriter sw = new StreamWriter(fs)) { for (int i = 0; i < doc.Sentences.Count; i++) { List <TrainingData> curLine = Merge(doc, doc.Sentences[i].Tokens, userSays[i].Entities); curLine.ForEach(trainingData => { string[] wordParams = { trainingData.Token, trainingData.Pos, trainingData.Entity }; string wordStr = string.Join("\t", wordParams); sw.WriteLine(wordStr); }); list.Add(curLine); sw.WriteLine(); } sw.Flush(); } } string contentDir = AppDomain.CurrentDomain.GetData("DataPath").ToString(); string template = Configuration.GetValue <String>($"template"); template = template.Replace("|App_Data|", contentDir + System.IO.Path.DirectorySeparatorChar); var encoder = new CRFEncoder(); bool result = encoder.Learn(new EncoderOptions { TrainingCorpusFileName = rawTrainingDataFileName, TemplateFileName = template, ModelFileName = modelFileName, }); return(result); }
public void InteractWith(AgentBase target) { var interaction = InteractionWith(target); if (interaction != UnitAction.ActionType.None) { UnitAction action = new UnitAction() { target = target, type = interaction, cancellable = false, priority = 1000 }; actionRunner.UpdateAction(ref action, true); actionRunner.Run(action); } }
public POSHBot(AgentBase agent, Dictionary <string, object> attributes) : base(agent, new string[] {}, new string[] {}) { middleIntMatcher = new Regex(",(.*?),"); firstIntMatcher = new Regex("(.*?),"); spaceMatcher = new Regex(@"^(.+?)\s+(.+?)$"); itemMatcher = new Regex(@"\{(.*?)\}"); attributeMatcher = new Regex(@"\{(.*?)\s+(.*?)\}"); // default connection values, use attributes to override ip = IPAddress.Parse("127.0.0.1"); port = 3000; botName = "POSHbot"; // Valid values for team are 0 and 1. If an invalid value is used gamebots // will alternate the team on which each new bot is placed. team = -1; // all the rest is standard events = new List <Tuple <long, string> >(); conninfo = null; gameinfo = new Dictionary <string, string>(); viewPlayers = new Dictionary <string, UTPlayer>(); viewItems = new List <InvItem>(); navPoints = new Dictionary <string, NavPoint>(); info = new Dictionary <string, string>(); sGameinfo = new Dictionary <string, string>(); sViewPlayers = new Dictionary <string, UTPlayer>(); sViewItems = new List <InvItem>(); sNavPoints = new Dictionary <string, NavPoint>(); sBotinfo = new Dictionary <string, string>(); msgLog = new List <Tuple <string, Dictionary <string, string> > >(); msgLogMax = 4096; sentMsgLog = new List <Tuple <string, Dictionary <string, string> > >(); sentMsgLogMax = 6; hitTimestamp = -1; threadActive = false; killConnection = false; rotationHist = new List <int>(); velocityHist = new List <float>(); connReady = false; connThread = null; }
public ActionResult DeleteImprovement(string ImprovementId) { try { AgentBase ABase = new AgentBase(); DatabaseContext dbx = ABase.GetContext(); int nImprovementId = Convert.ToInt32(ImprovementId); Reco3Improvement improvement = dbx.Reco3Improvements .Include("Conditions") .Where(x => x.ImprovementId == nImprovementId) .First(); if (improvement != null) { // Ensure that all conditions are removed first! if ((improvement.Conditions != null) && (improvement.Conditions.Count > 0)) { return(Json(new { success = false, error = true, message = "Please delete all conditions before proceeding." }, JsonRequestBehavior.AllowGet)); } // Remove the component if (improvement.Reco3Component != null) { dbx.Reco3Components.Remove(improvement.Reco3Component); } // Remove link to the component improvement.Reco3Component = null; // Remove the improvement dbx.Reco3Improvements.Remove(improvement); dbx.SaveChanges(); return(Json(new { success = true, message = "Successfully deleted improvement" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, error = true, message = "Failed to find the improvement." }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Console.WriteLine(e); return(Json(new { success = false, error = true, message = e.Message }, JsonRequestBehavior.AllowGet)); } //return RedirectToAction("Index"); }
public async Task <bool> Train(AgentBase agent, NlpDoc doc, PipeModel meta) { Init(meta); var sentences = doc.Sentences.Select(x => new Sentence { Label = x.Intent.Label, Text = x.Text, Words = x.Tokens }).ToList(); _classifier.Train(sentences); Console.WriteLine($"Saved model to {Settings.ModelDir}"); return(true); }
/// <summary> /// verify if you allowed to equip this item /// </summary> /// <param name="me"></param> /// <returns></returns> public virtual bool Equip(AgentBase me) { if (this.Slot == AllocationSlot.None) { equiped = false; return(equiped); } else if (this.Slot == AllocationSlot.Inventory) { return(true); // counts as equiped by simply picking it up :p } else { return(TestAllocation(me, this.Slot)); } }
public override bool Run(AgentBase agent) { if (loopStates == null) { return(true); } if (loopStates.Count == 0) { return(true); } if (currentState != null) { if (currentState.Run(agent)) { currentState.Complete(agent); if (iterator < loopStates.Count) { currentState = loopStates[iterator]; currentState.Setup(agent); iterator++; } else { if (timesRun < loopAmount) { //Debug.Log("lets do it another time"); timesRun++; iterator = 0; currentState = loopStates[iterator]; currentState.Setup(agent); iterator++; } else { //Debug.Log(timesRun); return(true); } } } } else { return(true); } return(false); }
private static void DrawCard(AgentBase agent, int id) { var textColor = ImGui.GetColorU32(ImGuiCol.Text); ImGui.BeginChild($"##{agent.Name ?? ""}{id}", new Vector2(65, 80)); { var drawList = ImGui.GetWindowDrawList(); var windowPos = ImGui.GetWindowPos(); if (ImGui.Button("", new Vector2(65, 80))) { CurrentAgent = agent; State = WindowState.AgentSetup; } drawList.AddText(windowPos + new Vector2(4, 60), textColor, agent.Name ?? ""); } ImGui.EndChild(); }
public static string GetInstanceUrl(IAgentHelper helper, AgentBase aB) { string instanceUrl = ""; try { aB.RaiseMessage("Attempting to get URL...", 1); instanceUrl = helper.GetInstanceSettingBundle().GetString("Relativity.Core", "KeplerServicesUri"); aB.RaiseMessage("Acquired URL: " + instanceUrl, 1); } catch (Exception e) { aB.RaiseMessage(e.ToString(), 1); } return(instanceUrl); }
public void Addplayer(AgentBase player) { if (player.GetType() == Omnicatz.Engine.Entities.PlayerInstanceManager.PlayerType) { if (Agents.Count(n => n.GetType() == player.GetType()) == 0) { Agents.Add(player); } else { throw new ApplicationException("Agent List allready has a player!"); // might handle this diffently later... } } else { throw new ApplicationException($"{player.GetType()} is not set as playerType for this game"); } }
// GET: Simulations public ViewResult Index(string sortOrder, string currentFilter, string searchString, int?page) { ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date"; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; AgentBase ABase = new AgentBase(); List <SimulationJob> simJobs = ABase.GetSimulationJobList(); return(View(simJobs)); /* * switch (sortOrder) * { * case "name_desc": * simJobs = simJobs.OrderByDescending(s => s.OwnerSss).ToList(); * break; * case "Date": * simJobs = simJobs.OrderBy(s => s.CreatedDateTime).ToList(); * break; * case "date_desc": * simJobs = simJobs.OrderByDescending(s => s.CreatedDateTime).ToList(); * break; * default: // Name ascending * simJobs = simJobs.OrderBy(s => s.Name).ToList(); * break; * } */ //int pageSize = 3; //int pageNumber = (page ?? 1); //return View(simJobs.ToPagedList(pageNumber, pageSize)); }
public ActionResult AddCoin(string introductionId, string introductionName, string introductionDate) { try { AgentBase ABase = new AgentBase(); DatabaseContext dbx = ABase.GetContext(); int nIntroductionPointId = Convert.ToInt32(introductionId); Reco3IntroductionPoint introduction = null; if (nIntroductionPointId != -1) { introduction = dbx.IntroductionPoints.Where(x => x.Reco3IntroductionPointId == nIntroductionPointId).First(); } else { introduction = new Reco3IntroductionPoint(); } if (introduction != null) { introduction.Name = introductionName; introduction.IntroductionDate = DateTime.Parse(introductionDate); if (nIntroductionPointId == -1) { dbx.IntroductionPoints.Add(introduction); } else { dbx.Entry(introduction).State = System.Data.Entity.EntityState.Modified; } dbx.SaveChanges(); return(Json(new { success = true, message = "Successfully saved introduction." }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Failed to find the introduction." }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Console.WriteLine(e); return(Json(new { success = false, message = e.Message }, JsonRequestBehavior.AllowGet)); } //return Json(new { success = false, message = "Fatal" }, JsonRequestBehavior.AllowGet); }
public void RegisterAgent( string _Name , AgentBase _Add ) { m_Agents.Add( _Name , _Add ) ; }