Beispiel #1
0
 /* returns: >0 the intention was changed
  *           1 = intention must continue running
  *           2 = fail event was generated and added in C.E
  *           3 = simply removed without event
  */
 public virtual int DropDesire(Intention i, Trigger g, Reasoner rs, Unifier un)
 {
     if (i != null && i.DropDesire(g, un))
     {
         if (rs.HasDesireListener())
         {
             foreach (Desire gl in rs.GetDesiresListeners())
             {
                 gl.DesireFinished(g, Desire.FinishStates.achieved);
             }
         }
         //continue the intention
         if (!i.IsFinished())
         {
             if (rs.GetCircumstance().GetSelectedIntention() != i)
             {
                 i.Peek().RemoveCurrentStep();
             }
             rs.ApplyClrInt(i);
             return(1);
         }
         else
         {
             rs.ApplyClrInt(i);
             return(3);
         }
     }
     return(0);
 }
Beispiel #2
0
    public void Update()
    {
        if (_newAppraisal)
        {
            // Affective Appraisal
            AffectiveAppraisal.ComputeUserEmotion(History, User);
            foreach (Tutor tutor in Tutors)
            {
                AffectiveAppraisal.ComputeTutorEmotion(History, User, tutor);
            }

            // Empathic Strategy
            Intention intention = EmpathicStrategySelector.SelectIntention(History, Strategies, User);

            // Dialog Selector
            IDialogTree dialogTree = DialogSelector.SelectDialog(History, intention);

            DialogManager.SetDialogTree(dialogTree);
            foreach (Tutor tutor in Tutors)
            {
                DialogManager.SetTutorEmotion(tutor);
            }
        }

        _newAppraisal = DialogManager.Update();
    }
Beispiel #3
0
    protected override bool Succeeded(Intention i, Beliefs b)
    {
        // If eating and counter is done, remove food object from level.
        if (i.Name == "eat")
        {
            if (counter < 0.1f)
            {
                b.Foods.Remove(Location);
                Manager.Instance.RemoveObject(Location);

                return(true);
            }
        }

        if (i.Name == "wait")
        {
            if (counter < 0.1f)
            {
                return(true);
            }
        }

        // Searching succeedes if room has been explored.
        if (i.Name == "search" && !b.Rooms.ContainsKey(i.ID))
        {
            return(true);
        }

        return(false);
    }
        protected override void ExecuteTacticCommand()
        {
            var targetContainerViewModel = GetSelectedNodeViewModel();

            if (targetContainerViewModel is null)
            {
                throw new InvalidOperationException("Невозможно выполнить команду. Целевой контейнер не выбран.");
            }

            var staticObject = targetContainerViewModel.StaticObject;

            if (staticObject == null)
            {
                throw new InvalidOperationException(
                          "Невозможно выполнить команду. Целевая модель представления не содержит ссылки на контейнер.");
            }

            var intetion = new Intention <OpenContainerTask>(actor => CreateTask(actor, staticObject));
            var actor    = PlayerState.ActiveActor?.Actor;

            if (actor is null)
            {
                throw new InvalidOperationException();
            }

            var taskSource = PlayerState?.TaskSource;

            if (taskSource is null)
            {
                throw new InvalidOperationException();
            }

            taskSource.Intent(intetion, actor);
        }
Beispiel #5
0
        /// <summary>
        /// Выполнение команды на перемещение и обновление игрового цикла.
        /// </summary>
        protected override void ExecuteTacticCommand()
        {
            var sector = _player.SectorNode.Sector;

            if (sector is null)
            {
                throw new InvalidOperationException();
            }

            var taskContext = new ActorTaskContext(sector);
            var intention   = new Intention <SectorTransitTask>(a => new SectorTransitTask(a, taskContext));
            var actor       = PlayerState.ActiveActor?.Actor;

            if (actor is null)
            {
                throw new InvalidOperationException();
            }

            var taskSource = PlayerState.TaskSource;

            if (taskSource is null)
            {
                throw new InvalidOperationException();
            }

            taskSource.Intent(intention, actor);

            // Drop waiting because the globe must not wait the person which is not in a sector.
            taskSource.DropIntentionWaiting();
        }
Beispiel #6
0
        /// <summary>
        /// Выполнение команды на перемещение и обновление игрового цикла.
        /// </summary>
        protected override void ExecuteTacticCommand()
        {
            var taskContext = new ActorTaskContext(_player.SectorNode.Sector);
            var intention   = new Intention <SectorTransitTask>(a => new SectorTransitTask(a, taskContext));

            PlayerState.TaskSource.Intent(intention, PlayerState.ActiveActor.Actor);
        }
Beispiel #7
0
    protected override bool Sound(Queue <Location> plan, Intention i, Beliefs b)
    {
        // If exploring and the entire path is within FOV, this area of the room
        // is already searched so re-plan.
        if (i.Name == "explore")
        {
            List <Location> intersect = plan.Intersect(b.Sees.Locations).ToList();
            if (intersect.Count == plan.Count)
            {
                return(false);
            }
        }

        // Re-plan if an obstacle is discovered which is located on the current
        // planned path.
        foreach (Location loc in plan)
        {
            if (b.Obstacles.ContainsKey(loc))
            {
                return(false);
            }
        }

        return(true);
    }
Beispiel #8
0
        public void IntentOpenContainer_SetContainerAndMethod_ReturnsTask()
        {
            //ARRANGE
            var map = new TestGridGenMap();

            var startNode = map.Nodes.Cast <HexNode>().SelectBy(0, 0);

            var actor = CreateActor(map, startNode);

            var taskSource = InitTaskSource(actor);

            var actorManager = CreateActorManager(actor);

            var containerMock = new Mock <IPropContainer>();
            var container     = containerMock.Object;

            var methodMock = new Mock <IOpenContainerMethod>();
            var method     = methodMock.Object;

            var intention = new Intention <OpenContainerTask>(a => new OpenContainerTask(a, container, method));



            // ACT
            var tasks = SetHumanIntention(actor, taskSource, intention);



            // ASSERT
            tasks.Should().NotBeNullOrEmpty();
            tasks[0].Should().BeOfType <OpenContainerTask>();
        }
Beispiel #9
0
        public IActionResult ViewApplicantSend(IFormCollection collection)
        {
            using (var db = new parttimejobContext())
            {
                var appinfo = db.Applicantinfo.FirstOrDefault(a => a.AId == common.key);
                if (appinfo == null)
                {
                    var script = String.Format("<script>alert('Your information is not found!');location.href = '{0}'</script>", Url.Action("ViewApplicant"));
                    return(Content(script, "text/html"));

                    //return RedirectToAction("ViewApplicant");
                }
                else
                {
                    string id            = collection["RId"];
                    var    Res           = db.Recruit.FirstOrDefault(b => b.RId == id);
                    var    ApplicantId   = db.Applicant.FirstOrDefault(b => b.AId == common.key);
                    var    TempIntention = new Intention();
                    TempIntention.AId     = ApplicantId.AId;
                    TempIntention.RId     = Res.RId;
                    TempIntention.IStatus = "确认中";
                    string   date  = DateTime.Now.ToLocalTime().ToString();
                    DateTime date1 = Convert.ToDateTime(date);
                    TempIntention.ICreateTime = date1;
                    db.Intention.Add(TempIntention);
                    db.SaveChanges();
                    var script = String.Format("<script>alert('Your application has been sent!');location.href = '{0}'</script>", Url.Action("ViewApplicant"));
                    return(Content(script, "text/html"));
                }
            }
        }
        private List <Instruction> Plan(Intention intention)
        {
            List <Instruction> myplan = new List <Instruction>();

            switch (intention.getDesire())
            {
            case Desire.SEARCH_AZNPOINT:
            case Desire.SEARCH_NEEDLE:
                myplan.Add(new Instruction(Instructions.MOVE));
                //    Debug.WriteLine(this.InternalName + " plan -> move random");
                break;

            case Desire.GOTO_AZN:
                myplan.Add(new Instruction(Instructions.MOVE_TO, intention.getDest()));
                myplan.Add(new Instruction(Instructions.COLLECT));
                break;

            case Desire.GOTO_NEEDLE:
                myplan.Add(new Instruction(Instructions.MOVE_TO, intention.getDest()));
                myplan.Add(new Instruction(Instructions.DROP));
                break;

            default:
                break;
            }

            return(myplan);
        }
Beispiel #11
0
        public void IntentAttack_SetTarget_ReturnsAttackTask()
        {
            //ARRANGE
            var usageService = _container.GetInstance <ITacticalActUsageService>();

            var map = new TestGridGenMap();

            var attackerStartNode = map.Nodes.Cast <HexNode>().SelectBy(3, 3);
            var targetStartNode   = map.Nodes.Cast <HexNode>().SelectBy(2, 3);


            var attackerActor = CreateActor(map, attackerStartNode);
            var targetActor   = CreateActor(map, targetStartNode);

            var taskSource = InitTaskSource(attackerActor);

            var actorManager = CreateActorManager(attackerActor, targetActor);

            var attackIntention = new Intention <AttackTask>(a => new AttackTask(a, targetActor, usageService));



            // ACT
            var tasks = SetHumanIntention(attackerActor, taskSource, attackIntention);



            // ASSERT
            tasks.Should().NotBeNullOrEmpty();
            tasks[0].Should().BeOfType <AttackTask>();
        }
Beispiel #12
0
        public bool HasReasonFor(Subject s, Beliefs b, Intention i)
        {
            if (!new Capture().HasReasonFor(s, b, i))
            {
                if (b.Sees.Agents.ContainsKey('0'))
                {
                    if (b.ToM['0'].Sees.Agents.ContainsKey(s.ID))
                    {
                        if (Util.GetAgentSpeed('0') != (int)Speed.VeryFast)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        if (Util.L1Distance(s.Location, b.Agents['0'].Location) <= 2)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
        public override void DoActions()
        {
            //   if (! (currentPlan.Count == 0 || Succeeded(currentIntention)))
            if (currentPlan.Count != 0)
            {
                Debug.WriteLine("doing actions; plan.count =" + currentPlan.Count);
                Execute(currentPlan);
                UpdateBeliefs();

                if (Reconsider(currentIntention))
                {
                    Desire d = Options();
                    currentIntention = Filter(d);
                    currentPlan      = Plan(currentIntention);
                }
            }
            else
            {
                Debug.WriteLine("new plan");
                UpdateBeliefs();

                Desire d = Options();
                currentIntention = Filter(d);
                currentPlan      = Plan(currentIntention);
            }
        }
Beispiel #14
0
        public bool HasReasonFor(Subject s, Beliefs b, Intention i)
        {
            if (!new Recover().HasReasonFor(s, b, i))
            {
                if (b.Sees.Agents.ContainsKey('0'))
                {
                    if (b.ToM['0'].Hears.Agents.ContainsKey(s.ID) ||
                        Util.GetAgentSpeed('0') == (int)Speed.VeryFast)
                    {
                        return(true);
                    }

                    // If lower rank, Misdirect the cat if another agent is seen
                    // and sees this agent and they both see the cat.
                    if (b.Sees.Agents.Count > 1)
                    {
                        foreach (Subject subj in b.Sees.Agents.Values)
                        {
                            if (Util.IsChild(subj.ID) &&
                                b.ToM[subj.ID].Sees.Agents.ContainsKey(s.ID) &&
                                ((b.ToM[subj.ID].Sees.Agents.ContainsKey('0') &&
                                  Util.IsHigherRank(subj.ID, s.ID)) ||
                                 !b.ToM[subj.ID].Sees.Agents.ContainsKey('0')))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Beispiel #15
0
        public bool HasReasonFor(Subject s, Beliefs b, Intention i)
        {
            if (!new Halt().HasReasonFor(s, b, i))
            {
                if (b.Sees.Agents.ContainsKey('0'))
                {
                    if (b.Sees.Agents.Count > 1 &&
                        (b.Sees.Agents.ContainsKey('0') &&
                         !b.ToM['0'].Sees.Agents.ContainsKey(s.ID) &&
                         Util.GetAgentSpeed('0') != (int)Speed.VeryFast))
                    {
                        foreach (Subject subj in b.Sees.Agents.Values)
                        {
                            if (Util.IsChild(subj.ID) &&
                                b.ToM[subj.ID].Sees.Agents.ContainsKey('0') &&
                                !b.ToM[subj.ID].Sees.Agents.ContainsKey(s.ID))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
        private bool Reconsider(Intention i)
        {
            if (getAASMAFramework().visiblePierres(this).Count > 0)
            {
                return(true);
            }


            if (State == NanoBotState.Moving && i.getDesire() == Desire.GOTO_AZN && getAASMAFramework().visibleAznPoints(this).Count > 0 && !getAASMAFramework().overAZN(this))
            {
                int   dist          = Utils.SquareDistance(this.Location, i.getDest());
                Point nearest       = Utils.getNearestPoint(this.Location, azn_points);
                int   distToNearest = Utils.SquareDistance(this.Location, nearest);
                if (distToNearest / dist <= 0.5)
                {
                    return(true);
                }
            }


            if (State == NanoBotState.Moving && i.getDesire() == Desire.GOTO_NEEDLE && getAASMAFramework().visibleEmptyNeedles(this).Count > 0 && !getAASMAFramework().overEmptyNeedle(this))
            {
                int   dist          = Utils.SquareDistance(this.Location, i.getDest());
                Point nearest       = Utils.getNearestPoint(this.Location, empty_needles);
                int   distToNearest = Utils.SquareDistance(this.Location, nearest);
                if (distToNearest / dist <= 0.5)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #17
0
 public Task <Intention> SetIntentionAsync(Intention intention, CancellationToken cancellationToken = default(CancellationToken))
 => ProcessCommandAsync <Intention>(
     CreateSetCommandRequest(
         intention,
         UriTemplates.INTENTIONS,
         ArtificialIntelligenceAddress),
     cancellationToken);
Beispiel #18
0
        public Intention SelectIntention(List <Intention> intentions)
        {
            Intention i = intentions[0];

            intentions.RemoveAt(0);
            return(i);
        }
    void SmashRocksAI()
    {
        if (targetRock == null)
        {
            targetRock = Pathing.FindNearbyRock(tileX, tileY, 20, path);
            if (targetRock == null)
            {
                intention = Intention.None;
            }
        }
        else
        {
            if (path.xPositions.Count == 1)
            {
                attackingARock = true;

                targetRock.TakeDamage(1);
            }
            if (targetRock.health <= 0)
            {
                targetRock = null;
                intention  = Intention.None;
            }
        }
    }
Beispiel #20
0
        public static int[] CreateGroundLevels(IntentionGrid grid)
        {
            var floorHeight  = 2.0;
            var groundLevels = new int[(int)Math.Floor((grid.Height - 2) / floorHeight)];

            for (var i = 0; i < groundLevels.Count(); i++)
            {
                groundLevels[i]  = (int)Math.Floor((i) * (grid.Height - 2) / (float)groundLevels.Count());
                groundLevels[i] += (int)floorHeight;
            }

            for (var x = 1; x < grid.Width - 1; x++)
            {
                for (var y = 0; y < grid.Height; y++)
                {
                    if (groundLevels.Any(gl => gl == y))
                    {
                        grid.Positions[x, y].Intentions.Add(Intention.GroundLevelIntention());
                    }
                }
            }

            DebugPrintMeaning(grid, Meaning.GroundLevel);

            return(groundLevels);
        }
 public EnglishWordSentiment(string word, string valence,
                             string stateIntensity, string emotion, string judgment,
                             string agreement, string intention)
 {
     Word = word;
     if (!Enum.TryParse(valence, out this.valence))
     {
         this.valence = Valence.NULL;
     }
     if (!Enum.TryParse(stateIntensity, out this.stateIntensity))
     {
         this.stateIntensity = StateIntensity.NULL;
     }
     if (!Enum.TryParse(emotion, out this.emotion))
     {
         this.emotion = Emotion.NULL;
     }
     if (!Enum.TryParse(judgment, out this.judgment))
     {
         this.judgment = Judgment.NULL;
     }
     if (!Enum.TryParse(agreement, out this.agreement))
     {
         this.agreement = Agreement.NULL;
     }
     if (!Enum.TryParse(intention, out this.intention))
     {
         this.intention = Intention.NULL;
     }
 }
    public void PickNewIntention()
    {
        path.Clear();


        int rand = Random.Range(0, 4);

        if (rand == 0)
        {
            intention = Intention.SmashRocks;
        }
        else if (rand == 1)
        {
            intention        = Intention.TillGround;
            foundTillingZone = false;
        }
        else if (rand == 2)
        {
            intention = Intention.PlantSeeds;
        }
        else if (rand == 3)
        {
            intention = Intention.SellPlants;
        }
    }
Beispiel #23
0
        public override object Execute(Reasoner ts, Unifier un, ITerm[] args)
        {
            CheckArguments(args);

            ForkData fd = new ForkData(((Atom)args[0]).Equals(aAnd));

            Intention currentInt = (Intention)ts.GetCircumstance().GetSelectedIntention();

            for (int iPlans = 1; iPlans < args.Length; iPlans++)
            {
                Intention i = new ForkIntention(currentInt, fd);
                fd.AddIntention(i);
                i.Pop(); // remove the top IM, it will be introduced back later (modified)
                IntendedPlan im = (IntendedPlan)currentInt.Peek().Clone();

                // adds the .join in the plan
                InternalActionLiteral joinL = new InternalActionLiteral(joinS, ts.GetAgent());
                joinL.AddTerm(new ObjectTermImpl(fd));
                IPlanBody joinPB = new PlanBodyImpl(BodyType.Body_Type.internalAction, joinL);
                joinPB.SetBodyNext(im.GetCurrentStep().GetBodyNext());

                // adds the argument in the plan (before join)
                IPlanBody whattoadd = (IPlanBody)args[iPlans].Clone();
                whattoadd.Add(joinPB);
                whattoadd.SetAsBodyTerm(false);
                im.InsertAsNextStep(whattoadd);
                im.RemoveCurrentStep(); // remove the .fork
                i.Push(im);
                ts.GetCircumstance().AddRunningIntention(i);
            }
            return(true);
        }
        protected override void ExecuteTacticCommand()
        {
            var targetStaticObject = (PlayerState.SelectedViewModel as IContainerViewModel).StaticObject;
            var targetDeposit      = targetStaticObject.GetModule <IPropDepositModule>();

            var equipmentCarrier = PlayerState.ActiveActor.Actor.Person.GetModule <IEquipmentModule>();
            var requiredTags     = targetDeposit.GetToolTags();

            if (requiredTags.Any())
            {
                var equipedTool = GetEquipedTool(equipmentCarrier, requiredTags);
                if (equipedTool is null)
                {
                    throw new InvalidOperationException("Попытка добычи без инструмента.");
                }

                var intetion = new Intention <MineTask>(actor =>
                                                        CreateTaskByInstrument(actor, targetStaticObject, equipedTool));
                PlayerState.TaskSource.Intent(intetion, PlayerState.ActiveActor.Actor);
            }
            else
            {
                // Добыча руками, если никаких тегов инструмента не задано.
                var intetion = new Intention <MineTask>(actor => CreateTaskByHands(actor, targetStaticObject));
                PlayerState.TaskSource.Intent(intetion, PlayerState.ActiveActor.Actor);
            }
        }
        /// <summary>
        /// Sets the next intention for the agent to perform.
        /// </summary>
        protected void StartNextIntention()
        {
            if (!HasCurrentIntention)
            {
                Intention intention = null;

                if (intentions.Count > 0)
                {
                    intention = intentions.Dequeue();
                }

                // if we have another intent, perform it, otherwise clear our walking towards destination because have no other intents
                if (intention != null)
                {
                    if (intention.Type == IntentionType.BuyDrink)
                    {
                        ChangeActivity(AgentActivity.WalkingToDrink);
                    }
                    else if (intention.Type == IntentionType.BuySnack)
                    {
                        ChangeActivity(AgentActivity.WalkingToFood);
                    }
                    else if (intention.Type == IntentionType.GoToDesk)
                    {
                        ChangeActivity(AgentActivity.WalkingToDesk);
                    }

                    WalkOnPathTowardsIntendedAgent(intention.PathNodesToAgent, intention);
                }
                else
                {
                    CurrentIntention = null;
                }
            }
        }
Beispiel #26
0
        public override object Execute(Reasoner reasoner, Unifier un, ITerm[] args)
        {
            CheckArguments(args);
            Intention currentInt = (Intention)reasoner.GetCircumstance().GetSelectedIntention();
            ForkData  fd         = (ForkData)((IObjectTerm)args[0]).GetObject();

            fd.toFinish--;

            // in the case of fork and, all intentions should be finished to continue
            if (fd.isAnd)
            {
                if (fd.toFinish == 0)
                {
                    currentInt.Peek().RemoveCurrentStep();
                    reasoner.GetCircumstance().AddRunningIntention(currentInt);
                }
            }
            else
            {
                // the first intention has finished, drop others
                fd.intentions.Remove(currentInt);
                foreach (Intention i in fd.intentions)
                {
                    //System.out.println("drop "+i.getId());
                    reasoner.GetCircumstance().DropIntention(i);
                }
                currentInt.Peek().RemoveCurrentStep();
                reasoner.GetCircumstance().AddRunningIntention(currentInt);
            }
            return(true);
        }
        public override bool DropInt(Circumstance C, Literal goal, Unifier un)
        {
            Unifier bak                  = un.Clone();
            bool    isCurrentInt         = false;
            IEnumerator <Intention> iint = C.GetAllIntentions();

            while (iint.Current != null)
            {
                Intention i  = iint.Current;
                IPlanBody pb = i.Peek().GetPlan().GetBody();
                while (pb != null)
                {
                    if (pb.GetBodyType() == BodyType.Body_Type.achieve || pb.GetBodyType() == BodyType.Body_Type.achieveNF)
                    {
                        if (un.Unifies(pb.GetBodyTerm(), goal))
                        {
                            C.DropIntention(i);
                            isCurrentInt = isCurrentInt || i.Equals(C.GetSelectedIntention());
                            un           = bak.Clone();
                            break;
                        }
                    }
                    pb = pb.GetBodyNext();
                }
            }
            return(isCurrentInt);
        }
Beispiel #28
0
        protected override void ExecuteTacticCommand()
        {
            if (SlotIndex is null)
            {
                throw new InvalidOperationException("Для команды не указан слот.");
            }

            var equipment = GetSelectedEquipmentInInventory();

            var sector = _player.SectorNode.Sector;

            if (sector is null)
            {
                throw new InvalidOperationException();
            }

            var taskContext = new ActorTaskContext(sector);

            var intention  = new Intention <EquipTask>(a => new EquipTask(a, taskContext, equipment, SlotIndex.Value));
            var taskSource = PlayerState.TaskSource;

            if (taskSource is null)
            {
                throw new InvalidOperationException();
            }

            var activeActor = PlayerState.ActiveActor?.Actor;

            if (activeActor is null)
            {
                throw new InvalidOperationException();
            }

            taskSource.Intent(intention, activeActor);
        }
Beispiel #29
0
        public static void CreateShooterSection(IntentionGrid grid, Random random)
        {
            //counts on having a border of width of 1

            //get a humble groundlevel tile at edge
            var tile = grid.GetByMeaning(Meaning.GroundLevel).Where(t =>
                                                                    (t.X == grid.Width - 2 || t.X == 1) &&
                                                                    grid.Positions[t.X, t.Y].Intentions.Count == 1
                                                                    )
                       //not next to exit or entrance path
                       .Where(t =>
                              !grid.Positions[t.X + 1, t.Y].Intentions.Any(n => n.Meaning == Meaning.EntrancePath || n.Meaning == Meaning.ExitPath)
                              &&
                              !grid.Positions[t.X - 1, t.Y].Intentions.Any(n => n.Meaning == Meaning.EntrancePath || n.Meaning == Meaning.ExitPath)
                              )
                       .ToList().GetRandomOrDefault(random);

            if (tile != null)
            {
                grid.Positions[tile.X, tile.Y].Intentions.Clear();
                grid.Positions[tile.X, tile.Y].Intentions.Add(Intention.ShooterIntention());
            }

            DebugPrintMeaning(grid, Meaning.Shooter);
        }
Beispiel #30
0
        public static void CreateVerticalEntrancePath(IntentionGrid grid, int exitX, int exitY)
        {
            var circuits   = grid.GetByMeaning(Meaning.Circuit);
            var topMost    = circuits.Select(x => x.Y).Min();
            var bottomMost = circuits.Select(x => x.Y).Max();

            var yDir   = 0;
            var yStart = 0;
            var yStop  = topMost + 1;

            if (exitY <= 0)
            {
                yDir = 1;
            }
            else
            {
                yDir   = -1;
                yStart = grid.Width - 1;
                yStop  = bottomMost - 1;
            }

            for (var y = yStart; y != yStop; y += yDir)
            {
                grid.Positions[exitX, y].Intentions.Add(Intention.EntrancePathIntention());
                if (y != yStop - yDir)
                {
                    grid.Positions[exitX, y].Intentions.Add(Intention.VerticalExitIntention());
                }
            }

            DebugPrintMeaning(grid, Meaning.ExitPath);
        }
Beispiel #31
0
        public BDIAgent(GameManager gameManager, Game game, Camera camera, int team)
            : base(gameManager, game, camera, team)
        {
            agentBeliefs.hasFoundDisk = false;
            if (team == 1)
                agentBeliefs.teamGoalPosition = _court.getTeam1GoalPosition();
            else if (team == 2)
                agentBeliefs.teamGoalPosition = _court.getTeam2GoalPosition();

            agentsManager = (AgentsManager)gameManager.getGameEntity("agentsManager");

            agentBeliefs.sameTeamPositions = new Dictionary<Agent, Vector3>();
            agentBeliefs.otherTeamPositions = new Dictionary<Agent, Vector3>();
            agentBeliefs.sawAgents = new List<Agent>();

            agentBeliefs.positionToPass = new Vector3(1000, 1000, 1000);

            intention = Intention.SEARCH_DISK;
        }
Beispiel #32
0
        public void Activities_Operations_and_Intentions_work_properly()
        {
            var world = Factory.CreateWorld();
            var alice = world.IReality.AddAgent(
                Factory.CreateAgent< IVirtual, IDesirous, IThinking, IActive >( "Alice" )
                );
            var a = new Location( "A" );
            var b = new Location( "B" );

            alice.As< IVirtual >().AddAttribute( new Position( a ) );
            alice.As< IThinking >().InnerReality.AddAgent( alice );

            IIntention intention = new Intention< ILocation >( Lib.Activities.Movement, alice, b );

            intention.Realize( world.IReality );

            Log( world.Dump() );

            Assert.That( alice.Get( Its.Virtual.Location ), Is.EqualTo( b ) );
        }
Beispiel #33
0
 private void updateIntentions()
 {
     if (desire == Desire.SCORE || _hasDisk) {
         if ((intention == Intention.SEARCH_DISK || intention == Intention.MOVE_TO_DISK) && agentBeliefs.canSeeDisk && agentBeliefs.playerWithDisk == null)
             intention = Intention.GRAB_DISK;
         else if (intention == Intention.SEARCH_DISK && agentBeliefs.canSeeDisk && sameTeam(agentBeliefs.playerWithDisk))
             intention = Intention.HEAD_TO_GOAL_NO_DISK;
         else if (intention == Intention.SEARCH_DISK && agentBeliefs.canSeeDisk && !sameTeam(agentBeliefs.playerWithDisk))
             intention = Intention.JINK;
         else if (intention == Intention.HEAD_TO_GOAL_NO_DISK && agentBeliefs.canSeeDisk && !sameTeam(agentBeliefs.playerWithDisk))
             intention = Intention.JINK;
         else if (intention == Intention.HEAD_TO_GOAL_NO_DISK && agentBeliefs.canSeeDisk && agentBeliefs.playerWithDisk == null)
             intention = Intention.GRAB_DISK;
         else if ((intention == Intention.GRAB_DISK || intention == Intention.HEAD_TO_GOAL) &&
                  _hasDisk && agentBeliefs.agentNearGoal != null)
             intention = Intention.PASS;
         else if (intention == Intention.GRAB_DISK && _hasDisk && !agentBeliefs.canSeeTeamGoal)
             intention = Intention.HEAD_TO_GOAL;
         else if (intention == Intention.GRAB_DISK && _hasDisk && agentBeliefs.canSeeTeamGoal)
             intention = Intention.SHOOT_TO_GOAL;
         else if (intention == Intention.PASS && _hasDisk && canSeePlayer(agentBeliefs.agentNearGoal))
             intention = Intention.SHOOT_TO_PLAYER;
         else if (intention == Intention.HEAD_TO_GOAL && _hasDisk && agentBeliefs.canSeeTeamGoal)
             intention = Intention.SHOOT_TO_GOAL;
         else if (!_hasDisk && intention != Intention.GRAB_DISK && agentBeliefs.hasFoundDisk)
             intention = Intention.MOVE_TO_DISK;
         else if(intention == Intention.SEARCH_PLAYER_WITH_DISK && agentBeliefs.agentNearGoal == null)
             intention = Intention.SEARCH_DISK;
         else if (!_hasDisk && intention != Intention.GRAB_DISK)
             intention = Intention.SEARCH_DISK;
     } else {
         if ((intention == Intention.SEARCH_PLAYER_WITH_DISK || intention == Intention.JINK) && sameTeam(agentBeliefs.playerWithDisk))
             intention = Intention.HEAD_TO_GOAL_NO_DISK;
         else if ((intention == Intention.SEARCH_PLAYER_WITH_DISK || intention == Intention.JINK) && agentBeliefs.canSeeDisk && agentBeliefs.playerWithDisk == null)
             intention = Intention.GRAB_DISK;
         else if (intention == Intention.JINK && agentBeliefs.sawAgents.Contains(agentBeliefs.playerWithDisk))
             intention = Intention.JINK;
         else if (!_hasDisk)
             intention = Intention.SEARCH_DISK;
     }
 }
 public IntentionDetails(Intention intention, float weight, Vector3 position)
 {
     this.weight = weight;
     this.position = position;
     this.intention = intention;
 }