Ejemplo n.º 1
0
 public STRIPSNode(STRIPSNode previousAction, float actionCost, List <KeyValuePair <string, bool> > state, STRIPSAction action)
 {
     PreviousAction = previousAction;
     ActionCost     = actionCost;
     State          = state;
     Action         = action;
 }
Ejemplo n.º 2
0
 private void HandleHideInBushAction(Spy spy, STRIPSAction action)
 {
     if (action.Name == "HideInBush")
     {
         HideInBush hideAction = action as HideInBush;
         action.ActionTarget = WhichBushToHide(hideAction.Hideouts, spy);
     }
 }
Ejemplo n.º 3
0
        private void HandleSubplanning(List <STRIPSNode> plans, List <STRIPSAction> usableActions, List <KeyValuePair <string, bool> > goal, int level, Vector3 currentPosition, Spy spy,
                                       STRIPSAction action, STRIPSNode planNode)
        {
            var actionsForSubplanning = usableActions.Except(new List <STRIPSAction>()
            {
                action
            }).ToList();

            GenerateAllPossiblePlans(planNode, plans, actionsForSubplanning, goal, level + 1, currentPosition, spy);
        }
Ejemplo n.º 4
0
        private void TryToExecuteAction(STRIPSAction action, Spy spy, FiniteStateMachine finiteStateMachine)
        {
            bool success = action.Execute(spy);

            if (success)
            {
                return;
            }

            HandleActionExecutionFailure(finiteStateMachine);
        }
Ejemplo n.º 5
0
        private void HandleCurrentActionExecution(Spy spy, FiniteStateMachine finiteStateMachine)
        {
            STRIPSAction action = currentActions.Peek();

            bool inRange = action.RequiresInRange ? action.IsInRange : true;

            if (inRange)
            {
                TryToExecuteAction(action, spy, finiteStateMachine);
            }
            else
            {
                finiteStateMachine.AddStateToStack(movementState);
            }
        }
Ejemplo n.º 6
0
        private void InitiateMovementState()
        {
            movementState = (finiteStateMachine, spy) =>
            {
                STRIPSAction action = currentActions.Peek();

                if (SchedulePlanningIfNecessary(spy, finiteStateMachine))
                {
                    return;
                }

                isSpyAwareOfBeingChasedLastValue = spy.AmIAwareOfBeingChased;

                if (STRIPSInstance.MoveSpy(action))
                {
                    finiteStateMachine.RemoveStateFromStack();
                }
            };
        }
Ejemplo n.º 7
0
        private static float CalculateActionCost(STRIPSNode parent, Vector3 currentPosition, STRIPSAction action)
        {
            var actionStartPosition = currentPosition;

            if (parent != null && parent.Action != null && parent.Action.ActionTarget != null)
            {
                actionStartPosition = parent.Action.ActionTarget.transform.position;
            }

            float cost = action.CalculateCost(actionStartPosition);

            return(cost);
        }