Example #1
0
        public void canScoreConsiderationsWithTransformedAppraisals()
        {
            var carpet      = new MagicCarpet(4, 8);
            var floatConsid = new SumConsideration <MagicCarpet>(() => { });

            floatConsid.addAppraisal(new BalloonAppraisal(carpet));
            floatConsid.addAppraisal(new WeightsAppraisal(carpet).clamp(0.6f).negate());

            var score = floatConsid.score();

            Assert.Equal(-0.2f, score, 4);
        }
Example #2
0
        private void buildReasoner()
        {
            reasoner           = new Reasoner <CakeGame>();
            reasoner.scoreType = Reasoner <CakeGame> .ScoreType.Raw;

            var sleepConsid = new ThresholdSumConsideration <CakeGame>(game.sleepBed, 0.6f, "sleep");

            sleepConsid.addAppraisal(new Sleepy(game));
            sleepConsid.addAppraisal(new Backlogged(game).scale(0.3f).negate());
            reasoner.addConsideration(sleepConsid);

            var bakeConsid = new SumConsideration <CakeGame>(game.bakeCake, "bake");

            bakeConsid.addAppraisal(new Backlogged(game));
            reasoner.addConsideration(bakeConsid);

            var shopConsid = new SumConsideration <CakeGame>(game.buyFlour, "shop");

            shopConsid.addAppraisal(new LowFlour(game));
            reasoner.addConsideration(shopConsid);
        }
Example #3
0
        private void createReasoner()
        {
            // create utility planner
            reasoner = new Reasoner <DuckMind>();
            Reasoner <DuckMind> .trace = true; // enable tracing
            reasoner.scoreType         = Reasoner <DuckMind> .ScoreType.Normalized;

            var eatConsideration = new ThresholdConsideration <DuckMind>(eatAction, 0.3f, "eat");

            eatConsideration.addAppraisal(new EatAppraisals.Hunger(mind));           // 0-1
            eatConsideration.addAppraisal(new EatAppraisals.FoodAvailability(mind)); //0-1
            reasoner.addConsideration(eatConsideration);

            var exploreConsideration = new SumConsideration <DuckMind>(exploreAction, "explore");

            exploreConsideration.addAppraisal(new ExploreAppraisals.ExplorationTendency(mind));
            exploreConsideration.addAppraisal(new ExploreAppraisals.Unexplored(mind));
            reasoner.addConsideration(exploreConsideration);

            // FIGHT of fight-or-flight
            var fightConsideration = new ThresholdSumConsideration <DuckMind>(fightAction, 0.8f, "fight");

            fightConsideration.addAppraisal(new DefenseAppraisals.NearbyThreat(mind));
            fightConsideration.addAppraisal(new DefenseAppraisals.ThreatFightable(mind));
            reasoner.addConsideration(fightConsideration);

            // FLIGHT of fight-or-flight
            var fleeConsideration = new ThresholdConsideration <DuckMind>(fleeAction, 0.4f, "flee");

            fleeConsideration.addAppraisal(new DefenseAppraisals.NearbyThreat(mind));
            fleeConsideration.addAppraisal(new DefenseAppraisals.ThreatFightable(mind).inverse());
            reasoner.addConsideration(fleeConsideration);

            var socialConsideration = new ThresholdConsideration <DuckMind>(socialAction, 0.2f, "social");

            socialConsideration.addAppraisal(new SocialAppraisals.NearbyPotentialAllies(mind));
            socialConsideration.addAppraisal(new SocialAppraisals.Sociability(mind));
            socialConsideration.addAppraisal(new SocialAppraisals.FriendBudget(mind));
            reasoner.addConsideration(socialConsideration);
        }