コード例 #1
0
ファイル: Baker.cs プロジェクト: xdrie/DuckMind
        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);
        }
コード例 #2
0
ファイル: ThinkSystem.cs プロジェクト: xdrie/Sor
        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);
        }