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; }
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); }
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); }
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; } }
public EValue(State state, Enum.Action action, float reward) { this.state = state; this.action = action; this.value = reward; }
public EValue getEValue(State state, Enum.Action action, List <EValue> eValues) { return(eValues.Where(i => i.getState().Equals(state) && i.getAction().Equals(action)).FirstOrDefault()); }
public void GoToNode(Node node) { CurrentGoal = node; CurrentAction = Enum.Action.Walking; }