Пример #1
0
        public GoapMiner()
        {
            // we need an ActionPlanner before we can do anything
            _planner = new ActionPlanner();

            // setup our Actions and add them to the planner
            var sleep = new Action("sleep");

            sleep.SetPrecondition(IsFatigued, true);
            sleep.SetPostcondition(IsFatigued, false);
            _planner.AddAction(sleep);

            var drink = new Action("drink");

            drink.SetPrecondition(IsThirsty, true);
            drink.SetPostcondition(IsThirsty, false);
            _planner.AddAction(drink);

            var mine = new Action("mine");

            mine.SetPrecondition(HasEnoughGold, false);
            mine.SetPostcondition(HasEnoughGold, true);
            _planner.AddAction(mine);

            var depositGold = new Action("depositGold");

            depositGold.SetPrecondition(HasEnoughGold, true);
            depositGold.SetPostcondition(HasEnoughGold, false);
            _planner.AddAction(depositGold);

            // set our state machine to idle. When it is in idle it will ask the ActionPlanner for a new plan
            InitialState = MinerBobState.Idle;
        }
Пример #2
0
        public GOAPMiner()
        {
            // we need an ActionPlanner before we can do anything
            _planner = new ActionPlanner();

            // setup our Actions and add them to the planner
            var sleep = new Action("sleep");

            sleep.setPrecondition(IS_FATIGUED, true);
            sleep.setPostcondition(IS_FATIGUED, false);
            _planner.addAction(sleep);

            var drink = new Action("drink");

            drink.setPrecondition(IS_THIRSTY, true);
            drink.setPostcondition(IS_THIRSTY, false);
            _planner.addAction(drink);

            var mine = new Action("mine");

            mine.setPrecondition(HAS_ENOUGH_GOLD, false);
            mine.setPostcondition(HAS_ENOUGH_GOLD, true);
            _planner.addAction(mine);

            var depositGold = new Action("depositGold");

            depositGold.setPrecondition(HAS_ENOUGH_GOLD, true);
            depositGold.setPostcondition(HAS_ENOUGH_GOLD, false);
            _planner.addAction(depositGold);

            // set our state machine to idle. When it is in idle it will ask the ActionPlanner for a new plan
            initialState = MinerBobState.Idle;
        }
Пример #3
0
        /// <summary>
        /// 行動方針の決定
        /// </summary>
        protected virtual void PlanAction()
        {
            ActionStrategyArgs args = new ActionStrategyArgs {
                Agi = Agi, GuessResult = LatestGuess
            };

            LatestPlan = ActionPlanner.Execute(args);
        }
Пример #4
0
        /// <summary>
        /// 行動方針の決定
        /// </summary>
        protected override void PlanAction()
        {
            ActionStrategyArgs args = new ActionStrategyArgs {
                Agi = Agi, GuessResult = LatestGuess
            };

            args.Items.Add("AgentStatistics", statistics);
            LatestPlan = ActionPlanner.Execute(args);
        }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        stateMachine     = new FSM();
        availableActions = new HashSet <AbstractGOAPAction>();
        currentActions   = new Queue <AbstractGOAPAction>();
        planner          = new ActionPlanner();
        findDataProvider();
        createIdleState();
        createMoveToState();
        createPerformActionState();
        stateMachine.pushState(idleState);
        loadActions();

        actions = GetComponents <AbstractGOAPAction>();
    }
Пример #6
0
        public ActionPlannerPageModel()
        {
            ActionPlanner.SubscribeUpDateEvent(this);

            if (ViewModelBase.IsInDesignModeStatic)
            {
                ActionPlanner.Add(DayOfWeek.Monday, TimeSpan.FromHours(5));
                ActionPlanner.Add(DayOfWeek.Thursday, TimeSpan.FromHours(15));
            }


            Set(nameof(Tasks), ref tasks, ActionPlanner.GetPlanner());


            ActionPlanner.Start();
        }
Пример #7
0
 protected void Awake()
 {
     // Set animator
     _animator = GetComponentInChildren <Animator>();
     // Set action planner
     _actionPlanner = new ActionPlanner <Dog, IDogAction>();
     // Set state
     _state          = _actionPlanner.GetState();
     _state.Position = new Vector2(_animator.transform.position.x, _animator.transform.position.z);
     _state.Speed    = new Vector2(0, 0);
     // Set active plan
     _planActive = _actionPlanner.GetPlan();
     // Set test plan
     _planTest = _actionPlanner.GetPlan();
     // Set action state machine
     _actionStateMachine = new ActionStateMachine <Dog, IDogAction, float>();
 }
Пример #8
0
        public General(Vector2 position) : base(position)
        {
            //goap
            //Console.WriteLine("STARTING PATHFINDING GOAL: "+ goal);
            entityName = Utilities.NameGenerator.GenreateFirstLastName();
            Console.WriteLine("General with name " + name);
            position.X += 100;
            //pathFinding = new World.Pathfinding();
            CreateBody();


            // setup action planner
            planner = new ActionPlanner();
            var sleep = new AI.GOAP.Action("sleep");

            sleep.setPrecondition("fatigued", true);
            sleep.setPostcondition("fatigued", false);
            planner.addAction(sleep);
        }
Пример #9
0
 public Move(GameObject gameObject, IReadOnlyList <IDogActionMovement> actionsMovement, IDogActionDestination actionDestination)
 {
     // Set action planner
     _actionPlanner = new ActionPlanner <Dog, IDogActionMovement>();
     // Set action state machine
     _actionStateMachine = new ActionStateMachine <Dog, IDogActionMovement, float>();
     // Run through movement actions
     for (int i = 0; i < actionsMovement.Count; i++)
     {
         // Create movement action
         var actionMovement = actionsMovement[i].Create(gameObject, actionDestination);
         // Add movement action
         _actionPlanner.AddAction(actionMovement);
     }
     // Set destination action
     _actionDestination = actionDestination;
     // Get plan
     _plan = _actionPlanner.GetPlan();
     // Set plan
     _actionPlanner.PopulatePlan(_plan, _actionPlanner.Actions[0]);
 }
Пример #10
0
    // Use this for initialization
    void Start()
    {
        currWorldState       = new WorldState();
        goalWorldState       = new WorldState();
        actionPlanner        = GetComponent <ActionPlanner>();
        currentActionIndex   = 0;
        currentlyDoingAction = false;

        needManagers = GetComponents <IGoalManager>();
        prepareInitialWorldState();

        GetComponent <MeshRenderer>().material = agent.color;
        transform.name = agent.NameGenerator();
        deltaTime      = 0;

        agent.PrepareAllActions();
        for (int i = 0; i < agent.actions.Count; i++)
        {
            Debug.Log(agent.actions[i].name + " .. " + agent.actions[i].cost + " .. " + agent.actions[i].result.getAllProperties().Count);
        }
    }
Пример #11
0
    void Execute()
    {
        var planner = new ActionPlanner();
        planner.Clear();

        planner.SetPrecondition(Actions.Scout, Atoms.Alive, true);
        planner.SetPostcondition(Actions.Scout, Atoms.EnemyVisible, true);

        planner.SetPrecondition(Actions.Approach, Atoms.EnemyVisible, true);
        planner.SetPostcondition(Actions.Approach, Atoms.NearEnemy, true);

        planner.SetPrecondition(Actions.Aim, Atoms.EnemyVisible, true);
        planner.SetPrecondition(Actions.Aim, Atoms.WeaponLoaded, true);
        planner.SetPostcondition(Actions.Aim, Atoms.EnemyLinedUp, true);

        planner.SetPrecondition(Actions.Shoot, Atoms.EnemyLinedUp, true);
        planner.SetPostcondition(Actions.Shoot, Atoms.EnemyAlive, false);

        planner.SetPrecondition(Actions.Load, Atoms.ArmedWithGun, true);
        planner.SetPostcondition(Actions.Load, Atoms.WeaponLoaded, true);

        planner.SetPrecondition(Actions.DetonateBomb, Atoms.ArmedWithBomb, true);
        planner.SetPrecondition(Actions.DetonateBomb, Atoms.NearEnemy, true);
        planner.SetPostcondition(Actions.DetonateBomb, Atoms.Alive, false);
        planner.SetPostcondition(Actions.DetonateBomb, Atoms.EnemyAlive, false);
        planner.SetCost(Actions.DetonateBomb, 5);

        planner.SetPrecondition(Actions.Flee, Atoms.EnemyVisible, true);
        planner.SetPostcondition(Actions.Flee, Atoms.EnemyVisible, false);

        Debug.Log(planner.ToString<Actions, Atoms>());

        var state = new WorldState();
        state.Set(Atoms.EnemyVisible,   false);
        state.Set(Atoms.ArmedWithGun,   true);
        state.Set(Atoms.WeaponLoaded,   false);
        state.Set(Atoms.EnemyLinedUp,   false);
        state.Set(Atoms.EnemyAlive,     true);
        state.Set(Atoms.ArmedWithBomb,  true);
        state.Set(Atoms.NearEnemy,      false);
        state.Set(Atoms.Alive,          true);

        Debug.LogFormat("State: {0}", state.ToString<Atoms>());

        var goal = new WorldState();
        goal.Set(Atoms.EnemyAlive, false);

        Debug.LogFormat("Goal: {0}", goal.ToString<Atoms>());

        var search = new Fringe(Graph.PlannerHeuristic);

        var stateNode = new WorldStateNode(planner, state);
        var goalNode = new WorldStateNode(planner, goal);

        var path = search.FindPath(stateNode, goalNode);

        foreach (WorldStateNode node in path)
        {
            Debug.Log(node.State);
        }
    }
Пример #12
0
 public WorldStateNode(ActionPlanner planner, WorldState state)
 {
     Planner = planner;
     State = state;
 }