public override void receiveMessage(AASMAMessage msg) { //this AI also handles messages, writing them in the debug log file //the logData method is very usefull for debbuging purposes //it will write the turn number and name of the agent who wrote in the log getAASMAFramework().logData(this._nanoAI, "received message from " + msg.Sender + " : " + msg.Content); }
public override void receiveMessage(AASMAMessage msg) { if (msg.Content.Contains("NP_") || msg.Content.Contains(InternalName)) { inbox.Add(msg); } }
protected override void UpdateBeliefs() { if (HitPoint < 5) { AASMAMessage msg = new AASMAMessage(this.InternalName, "AI$ RPROTECTOR BEING KILLED"); getAASMAFramework().sendMessage(msg, "AI"); } }
public override void receiveMessage(AASMAMessage msg) { // getAASMAFramework().logData(this, " received message from " + msg.Sender + " : " + msg.Content); if (msg.Content.Contains("E_") || msg.Content.Contains(InternalName)) { inbox.Add(msg); } }
private void UpdateBeliefs() { // outbox if (Stock == ContainerCapacity) { AASMAMessage msg = new AASMAMessage(this.InternalName, "C_,E_$ FULL NEEDLE"); msg.Tag = this.Location; getAASMAFramework().broadCastMessage(msg); } }
private void Execute(List <Instruction> plan) { Instruction i; if (plan.Count == 0 && currentIntention.getDesire() == Desire.GO_TO_NAV_POINTS) { i = new Instruction(Instructions.MOVE_TO_NAV_POINT, currentIntention.getDest()); } else { i = plan[0]; plan.RemoveAt(0); } switch (i.getInstruction()) { case Instructions.MOVE_TO_NAV_POINT: Point p = i.getDest(); if (this.State != NanoBotState.Moving) { navPointToReach.Remove(p); reachedNavPoints.Add(p); AASMAMessage msg = new AASMAMessage(this.InternalName, "E_$ NAVIGATION POINT REACHED"); msg.Tag = p; getAASMAFramework().broadCastMessage(msg); this.MoveTo(i.getDest()); } break; case Instructions.MOVE: if (frontClear()) { MoveForward(); } else { RandomTurn(); } break; default: break; } }
protected override void UpdateBeliefs() { if (HitPoint < 5) { AASMAMessage msg = new AASMAMessage(this.InternalName, "AI$ AIPROTECTOR BEING KILLED"); getAASMAFramework().sendMessage(msg, "AI"); } foreach (AASMAMessage msg in inbox) { if (msg.Content.Contains("AIP_$ MOVE TO HOSHIMI")) { protege = (Point)msg.Tag; } } inbox.Clear(); }
public override void DoActions() { updateNavigationPoints(); if (intentions.Count == 0 || deliberationWaitPeriods > deliberationDelta) { updateBeliefs(); deliberate(); deliberationWaitPeriods = 0; this.StopMoving(); } else { deliberationWaitPeriods++; } // Execute intentions if (intentions.Count > 0) { Knowledge.Desires intent = intentions.Pop(); // EXECUTE if (intent == Knowledge.Desires.GoNavigationPoint) { this.MoveTo(goals[0]); } } else { wander(); } // message handling if (getAASMAFramework().visibleHoshimies(this).Count > 0) { foreach (Point hoshimi in getAASMAFramework().visibleHoshimies(this)) { AASMAMessage msg = new AASMAMessage(this.InternalName, "hoshimi"); msg.Tag = hoshimi; getAASMAFramework().sendMessage(msg, "AI"); } } }
public override void receiveMessage(AASMAMessage msg) { // SEND MESSAGES ABOUT DANGER AND SHOOTING TARGETS }
public override void receiveMessage(AASMAMessage msg) { }
private void UpdateBeliefs() { // Debug.WriteLine(this.InternalName + " UpdateBeliefs"); // if seeing navigation points foreach (Point p in this.getAASMAFramework().visibleNavigationPoints(this)) { if (p.X == this.Location.X && p.Y == this.Location.Y && !reachedNavPoints.Contains(p)) { reachedNavPoints.Add(p); } if (!navPointToReach.Contains(p) && !reachedNavPoints.Contains(p)) { navPointToReach.Add(p); } } // inbox foreach (AASMAMessage msg in inbox) { if (msg.Content.Equals("E_$ NAVIGATION POINT REACHED")) { Point p = (Point)msg.Tag; if (!reachedNavPoints.Contains(p)) { reachedNavPoints.Add(p); } if (navPointToReach.Contains(p)) { navPointToReach.Remove(p); } } else if (msg.Content.Equals("C_,E_$ FULL NEEDLE")) { Point p = (Point)msg.Tag; if (empty_needles.Contains(p)) { empty_needles.Remove(p); } if (hoshimi_points.Contains(p)) { hoshimi_points.Remove(p); } } else if (msg.Content.Contains("E_$ CONTAINER CREATED")) { String receiver = msg.Content.Split(new char[] { ':' })[1]; AASMAMessage new_msg = new AASMAMessage(this.InternalName, receiver + "$ AZN POINTS"); new_msg.Tag = azn_points; getAASMAFramework().sendMessage(new_msg, receiver); new_msg = new AASMAMessage(this.InternalName, receiver + "$ EMPTY NEEDLES"); new_msg.Tag = empty_needles; getAASMAFramework().sendMessage(new_msg, receiver); } } // outbox // if seeing hoshimi points foreach (Point hoshimi in this.getAASMAFramework().visibleHoshimies(this)) { if (!hoshimi_points.Contains(hoshimi) && !getAASMAFramework().visibleFullNeedles(this).Contains(hoshimi) && !getAASMAFramework().visibleEmptyNeedles(this).Contains(hoshimi)) { hoshimi_points.Add(hoshimi); AASMAMessage msg = new AASMAMessage(this.InternalName, "AI$ HOSHIMI POINT"); msg.Tag = hoshimi; getAASMAFramework().sendMessage(msg, "AI"); } } foreach (Point azn in getAASMAFramework().visibleAznPoints(this)) { if (!azn_points.Contains(azn)) { azn_points.Add(azn); AASMAMessage msg = new AASMAMessage(this.InternalName, "C_$ AZN POINT"); msg.Tag = azn; getAASMAFramework().broadCastMessage(msg); } } foreach (Point needle in getAASMAFramework().visibleEmptyNeedles(this)) { if (!empty_needles.Contains(needle)) { empty_needles.Add(needle); if (hoshimi_points.Contains(needle)) { hoshimi_points.Remove(needle); } AASMAMessage msg = new AASMAMessage(this.InternalName, "C_$ EMPTY NEEDLE"); msg.Tag = needle; getAASMAFramework().broadCastMessage(msg); } } foreach (Point needle in getAASMAFramework().visibleFullNeedles(this)) { if (hoshimi_points.Contains(needle)) { hoshimi_points.Remove(needle); } } }
private void Execute(List <Instruction> plan) { Instruction i = new Instruction(); if (plan.Count > 0) { i = plan[0]; plan.RemoveAt(0); } else if (currentIntention.getDesire() == Desire.GOTO_AZN && this.getAASMAFramework().overAZN(this)) { i = new Instruction(Instructions.COLLECT); } else if (currentIntention.getDesire() == Desire.GOTO_NEEDLE && this.getAASMAFramework().overEmptyNeedle(this)) { i = new Instruction(Instructions.DROP); } switch (i.getInstruction()) { case Instructions.MOVE_TO: Point p = i.getDest(); this.MoveTo(p); AASMAMessage msg1 = new AASMAMessage(this.InternalName, myprotector + "$ Container's location"); msg1.Tag = p; getAASMAFramework().sendMessage(msg1, myprotector); break; case Instructions.MOVE: if (frontClear()) { MoveForward(); } else { RandomTurn(); } break; case Instructions.COLLECT: if (this.getAASMAFramework().overAZN(this)) { this.collectAZN(); } // else // Debug.WriteLine(this.InternalName + " tried to collect AZN when far from AZN Point"); break; case Instructions.DROP: if (this.getAASMAFramework().overEmptyNeedle(this)) { this.transferAZN(); } // else // Debug.WriteLine(this.InternalName + " tried to collect AZN when far from Needle"); break; default: break; } }
private void Execute(List <Instruction> plan) { Instruction i = plan[0]; Debug.WriteLine("Executing " + i.getInstruction().ToString()); switch (i.getInstruction()) { case Instructions.DO_NOTHING: if (_nanoAI.State == NanoBotState.Moving) { this._nanoAI.StopMoving(); } break; case Instructions.MOVE: if (frontClear()) { MoveForward(); } else { RandomTurn(); } break; case Instructions.MOVE_TO_HOSHIMI: if (_nanoAI.State != NanoBotState.Moving) { Point p = i.getPoint(); AASMAMessage msg = new AASMAMessage(this._nanoAI.InternalName, "AIP_$ MOVE TO HOSHIMI"); msg.Tag = p; getAASMAFramework().broadCastMessage(msg); this._nanoAI.MoveTo(p); } if (!_nanoAI.Location.Equals(i.getPoint())) { return; } break; case Instructions.CREATE_AI_PROTECTOR: this._nanoAI.Build(typeof(AIProtector), "AIP" + this._protectorNumber); _AIProtectors.Add("AIP" + this._protectorNumber++); break; case Instructions.CREATE_CONTAINER_PROTECTOR: this._nanoAI.Build(typeof(ContainerProtector), "CP" + this._protectorNumber++); break; case Instructions.CREATE_NEEDLE_PROTECTOR: string protectorName = "NP" + this._protectorNumber++; this._nanoAI.Build(typeof(NeedleProtector), protectorName); // mandar mensagem com o ponto do needle AASMAMessage msg_to_needle = new AASMAMessage(this._nanoAI.InternalName, "NP_$ MOVE TO NEEDLE LOCATION"); msg_to_needle.Tag = this._nanoAI.Location; getAASMAFramework().sendMessage(msg_to_needle, protectorName); empty_hoshimi.Remove(this._nanoAI.Location); break; case Instructions.CREATE_RANDOM_PROTECTOR: this._nanoAI.Build(typeof(RandomProtector), "RP" + this._protectorNumber); RProtectors.Add("RP" + this._protectorNumber++); break; case Instructions.CREATE_EXPLORER: this._nanoAI.Build(typeof(ForwardExplorer), "E" + this._explorerNumber++); break; case Instructions.CREATE_CONTAINER: this._nanoAI.Build(typeof(PassiveContainer), "C" + this._containerNumber); if (getAASMAFramework().explorersAlive() > 2) { AASMAMessage msg_1 = new AASMAMessage(this._nanoAI.InternalName, "E_$ CONTAINER CREATED:C" + this._containerNumber); msg_1.Tag = i.getPoint(); getAASMAFramework().broadCastMessage(msg_1); } AASMAMessage msg_2 = new AASMAMessage(this._nanoAI.InternalName, "C" + _containerNumber + "$ Protector number:CP" + this._protectorNumber); msg_2.Tag = i.getPoint(); getAASMAFramework().sendMessage(msg_2, "C" + _containerNumber); this._containerNumber++; break; case Instructions.CREATE_NEEDLE: if (getAASMAFramework().overHoshimiPoint(this._nanoAI) && !getAASMAFramework().overNeedle(this._nanoAI)) { this._nanoAI.Build(typeof(PassiveNeedle), "N" + this._needleNumber++); } break; default: break; } plan.RemoveAt(0); }
public override void receiveMessage(AASMAMessage msg) { inbox.Add(msg); }