예제 #1
0
파일: Human.cs 프로젝트: yangzk/CityGame
    void GoToNewGoal()
    {
        if (!WithinGroup)
        {
            if (CurrentGoal == null)
            {
                CurrentGoal = Node.GetClosestNode(transform.position, "Untagged");
            }
            else
            {
                CurrentGoal = CurrentGoal.GetNextNode();             //PointsOfInterest[Random.Range(0, PointsOfInterest.Count)];
            }
        }
        else
        {
            this.CurrentGoal = Node.GetRandomNode(this.Group);
        }

        if (CurrentGoal == null)
        {
            return;
        }
        _navAgent.SetDestination(CurrentGoal.transform.position);
        _navAgent.enabled = true;
        CurrentAction     = Enum.Action.Walking;
        _goalDirection    = (CurrentGoal.transform.position - transform.position).normalized;
    }
예제 #2
0
        public static List <QValue> updateTable(State currentState, Enum.Action actionOne, State nextState, Enum.Action actionTwo, float reward, List <QValue> qValues)
        {
            var firstQValue  = getQValueEntry(currentState, actionOne, qValues);
            var secondQValue = getQValueEntry(nextState, actionTwo, qValues);

            firstQValue.setValue(firstQValue.getValue() + learningRate * (reward + gamma * secondQValue.getValue() - firstQValue.getValue()));
            return(qValues);
        }
예제 #3
0
        public static List <EValue> updateETable(State currentState, Enum.Action actionOne, State nextState, Enum.Action actionTwo, List <EValue> eValues)
        {
            var eValue = getEValueEntry(currentState, actionOne, eValues);

            if (currentState.Equals(nextState) && actionOne == actionTwo)
            {
                eValue.setValue((gamma * lambda * eValue.getValue()) + 1);
            }
            else
            {
                eValue.setValue(gamma * lambda * eValue.getValue());
            }
            return(eValues);
        }
예제 #4
0
파일: Human.cs 프로젝트: yangzk/CityGame
    void StartAction(Enum.Action action)
    {
        CurrentAction = action;

        switch (action)
        {
        case Enum.Action.Standing:
            _actionDuration = 2.0f;
            break;

        case Enum.Action.Walking:
        case Enum.Action.Running:
            GoToNewGoal();
            break;

        case Enum.Action.Turning:
            break;

        case Enum.Action.SitDown:
            _animator.SetTrigger("SitDown");
            _actionDuration = 15.0f;
            StartAction(Enum.Action.Sitting);
            break;

        case Enum.Action.Sitting:
            break;

        case Enum.Action.StandUp:
            _animator.SetTrigger("StandUp");
            StartAction(Enum.Action.Standing);
            break;

        default:
            break;
        }
    }
예제 #5
0
 public EValue(State state, Enum.Action action, float reward)
 {
     this.state  = state;
     this.action = action;
     this.value  = reward;
 }
예제 #6
0
 public EValue getEValue(State state, Enum.Action action, List <EValue> eValues)
 {
     return(eValues.Where(i => i.getState().Equals(state) && i.getAction().Equals(action)).FirstOrDefault());
 }
예제 #7
0
파일: Human.cs 프로젝트: yangzk/CityGame
 public void GoToNode(Node node)
 {
     CurrentGoal   = node;
     CurrentAction = Enum.Action.Walking;
 }