AgentAction(float[] vectorAction, string textAction) { if (LastTimeAgentStep == -1f) { DeltTimeAgentStep = 0f; } else { DeltTimeAgentStep = Time.time - LastTimeAgentStep; } LastTimeAgentStep = Time.time; if (IsLiving()) { // // call turn based game step // if (globalManager.isTurnBasedGame()) { // TurnState = globalManager.getTurnState(getTeamID(), getAgentID()); // if ((TurnState == TurnStates.NotTurn) || (TurnState == TurnStates.Switching)) { // StepSwitchingOrNotTurn(); // } else if (TurnState == TurnStates.Switching) { // StepSwitching(); // } else if (TurnState == TurnStates.NotTurn) { // StepNotTurn(); // } else if (TurnState == TurnStates.Turn) { // StepTurn(); // } // } bool IsActionTakingEffect = true; if (!HasEnergy()) { IsActionTakingEffect = false; } // // if turn base game and at (NotTurn or Switching), no act // if (globalManager.isTurnBasedGame()) { // if ((TurnState == TurnStates.NotTurn) || (TurnState == TurnStates.Switching)) { // IsActionTakingEffect = false; // } // } if (IsActionTakingEffect) { if (GetActionSpaceType() == SpaceType.discrete) { // for disceret action space int DiscreteAction_ = Mathf.FloorToInt(vectorAction[0]); DiscreteAction_ = CheckHistoryAction(LastDiscreteAction, DiscreteAction_); DiscreteStep(DiscreteAction_); LastDiscreteAction = DiscreteAction_; } else if (GetActionSpaceType() == SpaceType.continuous) { // for continuous action space ContinuousStep(vectorAction); } DiscreteContinuousStep(); } foreach (Dictionary <string, UIPercentageBar> UIPercentageBars in AllAgentCamerasUIPercentageBars) { UIPercentageBars["Episode Reward"].UpdateValue(GetCumulativeReward()); } } else { StepDead(); } foreach (Dictionary <string, UIPercentageBar> UIPercentageBars in AllAgentCamerasUIPercentageBars) { UIPercentageBars["Episode Length"].UpdateValue(GetComponent <ArenaNode>().GetNumLivingSteps()); } if (globalManager.isDebugging()) { if ((getTeamID() == 0) && (getAgentID() == 0)) { print(GetLogTag() + " GetCumulativeReward " + GetCumulativeReward()); } } } // AgentAction
AgentAction(float[] vectorAction, string textAction) { if (isLiving()) { // call turn based game step if (globalManager.isTurnBasedGame()) { TurnState = globalManager.getTurnState(getTeamID(), getAgentID()); if ((TurnState == TurnStates.NotTurn) || (TurnState == TurnStates.Switching)) { StepSwitchingOrNotTurn(); } else if (TurnState == TurnStates.Switching) { StepSwitching(); } else if (TurnState == TurnStates.NotTurn) { StepNotTurn(); } else if (TurnState == TurnStates.Turn) { StepTurn(); } } bool IsActionTakingEffect = true; // if turn base game and at (NotTurn or Switching), no act if (globalManager.isTurnBasedGame()) { if ((TurnState == TurnStates.NotTurn) || (TurnState == TurnStates.Switching)) { IsActionTakingEffect = false; } } if (IsActionTakingEffect) { if (GetActionSpaceType() == SpaceType.discrete) { // for disceret action space int DiscreteAction_ = Mathf.FloorToInt(vectorAction[0]); DiscreteAction_ = CheckHistoryAction(LastDiscreteAction, DiscreteAction_); DiscreteStep(DiscreteAction_); LastDiscreteAction = DiscreteAction_; } else if (GetActionSpaceType() == SpaceType.continuous) { // for continuous action space ContinuousStep(vectorAction); } DiscreteContinuousStep(); } UIPercentageBars["ER"].UpdateValue(GetCumulativeReward()); } else { StepDead(); } if (globalManager.isDebugging()) { if ((getTeamID() == 0) && (getAgentID() == 0)) { print(getLogTag() + " GetCumulativeReward " + GetCumulativeReward()); } } } // AgentAction