Beispiel #1
0
        private void Start()
        {
            this.EnsureRequiredFieldsAreSetInEditor();

            // Init AI
            var knowledgeProvider = new KnowledgeProvider(this);
            var goalSelector      = new GoalSelector.Builder()
                                    .WithReevaluationPeriod(3.0f)
                                    .WithGoal(
                new Goal("BuildHouse",
                         new List <IPrecondition>
            {
                new IsTrue(new SymbolId("HouseBuilt"))
            }
                         ),
                () => town.House.IsBuilt ? -1 : 1
                )
                                    .WithGoal(
                new Goal("DestroyHouse",
                         new List <IPrecondition>
            {
                new IsTrue(new SymbolId("HouseBuilt"))
            }
                         ),
                () => town.House.IsBuilt ? 1 : -1
                )
                                    .WithGoal(
                new Goal("BuildHouse",
                         new List <IPrecondition>
            {
                new IsTrue(new SymbolId("HouseBuilt"))
            }
                         ),
                () => town.House.IsBuilt ? -1 : 1
                )
                                    .Build();
            var actionFactory = GetActionFactory();

            var planner      = new ForwardPlanner(100, 200, learn, experienceWeight);
            var planExecutor = new PlanExecutor(actionFactory);

            agent = new Agent(
                new AgentConfiguration.Builder()
                .WithKnowledgeProvider(knowledgeProvider)
                .WithGoalSelector(goalSelector)
                .WithPlanner(planner)
                .WithPlanExecutor(planExecutor)
                .Build()
                );

            navMeshAgent = GetComponent <NavMeshAgent>();
            DebugUtils.Assert(navMeshAgent != null, "{0} requires {1} to be present", GetType(), typeof(NavMeshAgent));

            // Init view
            toolAnimationTimer = new ResettableStopwatchExecutionTimer(true);

            // Init UI
            planExecutionStatePanel.PlanExecution = planExecutor.CurrentExecution;
        }
Beispiel #2
0
        public override void initialize()
        {
            base.initialize();

            // set up plan executor
            planExecutor = new PlanExecutor(this);

            // set up systems
            sensorySystems.Add(new VisionSystem(this, 0.4f, cancelToken.Token));
            cognitiveSystems.Add(new ThinkSystem(this, 0.4f, cancelToken.Token));
        }
Beispiel #3
0
        public override bool Execute(NewCommandInput input)
        {
            var plan            = new TemplatePlan();
            var findContentStep = input.GitFlag.IsNotEmpty()
                                      ? (ITemplateStep) new CloneGitRepository(ProcessFactory, FileSystem)
                                      : new UnzipTemplate(ZipService);

            plan.AddStep(findContentStep);
            plan.AddStep(new ReplaceKeywords(KeywordReplacer, FileSystem));

            if (input.SolutionFlag.IsNotEmpty())
            {
                plan.AddStep(new ModifySolution(SolutionFileService, CsProjGatherer));
            }

            plan.AddStep(new MoveContent(FileSystem));

            if (input.RakeFlag.IsNotEmpty())
            {
                plan.AddStep(new RunRakeFile(FileSystem, RakeRunner));
            }

            plan.AddStep(new AutoRunFubuRake(FileSystem, RakeRunner));
            plan.AddStep(new RemoveTemporaryContent());

            var hasErrors = false;

            PlanExecutor.Execute(input, plan, ctx =>
            {
                Console.ForegroundColor = ConsoleColor.Red;
                ctx.Errors.Each(error => Console.WriteLine(error));
                Console.ForegroundColor = ConsoleColor.White;
                hasErrors = ctx.Errors.Any();
            });

            if (hasErrors)
            {
                return(false);
            }

            Console.WriteLine("Solution {0} created", input.ProjectName);
            return(true);
        }
Beispiel #4
0
        void Start()
        {
            this.EnsureRequiredFieldsAreSetInEditor();

            // Init AI
            var knowledgeProvider = new KnowledgeProvider(this);
            var goalSelector      = new GoalSelector.Builder()
                                    .WithReevaluationPeriod(3.0f)
                                    .WithGoal(
                new Goal(
                    "BuildHouse",
                    new List <IPrecondition>()
            {
                new IsTrue(new SymbolId("HouseBuilt"))
            }
                    ),
                () => town.House.IsBuilt ? -1 : 1
                )
                                    .Build();
            var actionFactory = this.GetActionFactory();
            var planner       = new RegressivePlanner(20, 5);
            var planExecutor  = new PlanExecutor(actionFactory);

            this.agent = new Agent(
                new AgentEnvironment.Builder()
                .WithKnowledgeProvider(knowledgeProvider)
                .WithGoalSelector(goalSelector)
                .WithPlanner(planner)
                .WithPlanExecutor(planExecutor)
                .Build()
                );

            this.navMeshAgent = this.GetComponent <NavMeshAgent>();
            DebugUtils.Assert(this.navMeshAgent != null, "{0} requires {1} to be present", this.GetType(), typeof(NavMeshAgent));

            // Init view
            this.toolAnimationTimer = new ResettableExecutionTimer(true);

            // Init UI
            this.planExecutionStatePanel.PlanExecution = planExecutor.CurrentExecution;
        }
Beispiel #5
0
 public MercenaryNpc()
 {
     this.blackboard.SetWorldStateVariable(WorldStateVariable.HAS_MONEY.ToString(), 100);
     this.planExecutor = new PlanExecutor(this);
 }
Beispiel #6
0
 public FarmerNpc()
 {
     this.planExecutor = new PlanExecutor(this);
 }