public void canScoreConsideration() { var carpet = new MagicCarpet(2, 2); var floatConsid = new ThresholdSumConsideration <MagicCarpet>(() => { }, 0.5f); floatConsid.addAppraisal(new BalloonAppraisal(carpet)); floatConsid.addAppraisal(new WeightsAppraisal(carpet).negate()); var score = floatConsid.score(); Assert.Equal(0f, score, 4); }
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); }
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); }