Skip to content

Commit fbcdd83

Browse files
Replace Agent.GetStepCount with Agent.StepCount` (#3476)
1 parent c1711a4 commit fbcdd83

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayAgent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public override void CollectObservations(VectorSensor sensor)
3030
{
3131
if (useVectorObs)
3232
{
33-
sensor.AddObservation(GetStepCount() / (float)maxStep);
33+
sensor.AddObservation(StepCount / (float)maxStep);
3434
}
3535
}
3636

com.unity.ml-agents/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2020
- The stepping logic for the Agent and the Academy has been simplified (#3448)
2121
- Update Barracuda to 0.6.0-preview
2222
- The checkpoint file suffix was changed from `.cptk` to `.ckpt` (#3470)
23+
- The method `GetStepCount()` on the Agent class has been replaced with the property getter `StepCount`
2324

2425
### Bugfixes
2526
- Fixed an issue which caused self-play training sessions to consume a lot of memory. (#3451)

com.unity.ml-agents/Runtime/Agent.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,15 +314,14 @@ public void GiveModel(
314314
m_Brain = m_PolicyFactory.GeneratePolicy(Heuristic);
315315
}
316316

317-
/// <summary>
318317
/// Returns the current step counter (within the current episode).
319318
/// </summary>
320319
/// <returns>
321-
/// Current episode number.
320+
/// Current step count.
322321
/// </returns>
323-
public int GetStepCount()
322+
public int StepCount
324323
{
325-
return m_StepCount;
324+
get { return m_StepCount; }
326325
}
327326

328327
/// <summary>

com.unity.ml-agents/Tests/Editor/MLAgentsEditModeTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ public void TestAgent()
406406

407407
Assert.AreEqual(i, aca.TotalStepCount);
408408

409-
Assert.AreEqual(agent2StepSinceReset, agent2.GetStepCount());
409+
Assert.AreEqual(agent2StepSinceReset, agent2.StepCount);
410410
Assert.AreEqual(numberAgent1Reset, agent1.agentResetCalls);
411411
Assert.AreEqual(numberAgent2Reset, agent2.agentResetCalls);
412412

@@ -536,20 +536,20 @@ public void TestMaxStepsReset()
536536
expectedAgentStepCount += 1;
537537

538538
// If the next step will put the agent at maxSteps, we expect it to reset
539-
if (agent1.GetStepCount() == maxStep - 1 || (i == 0))
539+
if (agent1.StepCount == maxStep - 1 || (i == 0))
540540
{
541541
expectedResets +=1;
542542
}
543543

544-
if (agent1.GetStepCount() == maxStep - 1)
544+
if (agent1.StepCount == maxStep - 1)
545545
{
546546
expectedAgentActionSinceReset = 0;
547547
expectedCollectObsCallsSinceReset = 0;
548548
expectedAgentStepCount = 0;
549549
}
550550
aca.EnvironmentStep();
551551

552-
Assert.AreEqual(expectedAgentStepCount, agent1.GetStepCount());
552+
Assert.AreEqual(expectedAgentStepCount, agent1.StepCount);
553553
Assert.AreEqual(expectedResets, agent1.agentResetCalls);
554554
Assert.AreEqual(expectedAgentAction, agent1.agentActionCalls);
555555
Assert.AreEqual(expectedAgentActionSinceReset, agent1.agentActionCallsSinceLastReset);

docs/Migrating.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ The versions can be found in
1414
* The `Monitor` class has been moved to the Examples Project. (It was prone to errors during testing)
1515
* The `MLAgents.Sensor` namespace has been removed. All sensors now belong to the `MLAgents` namespace.
1616
* The `SetActionMask` method must now be called on the optional `ActionMasker` argument of the `CollectObservations` method. (We now consider an action mask as a type of observation)
17+
* The method `GetStepCount()` on the Agent class has been replaced with the property getter `StepCount`
1718

1819
### Steps to Migrate
1920
* Replace your Agent's implementation of `CollectObservations()` with `CollectObservations(VectorSensor sensor)`. In addition, replace all calls to `AddVectorObs()` with `sensor.AddObservation()` or `sensor.AddOneHotObservation()` on the `VectorSensor` passed as argument.
2021
* Replace your calls to `SetActionMask` on your Agent to `ActionMasker.SetActionMask` in `CollectObservations`
2122
* Re-import all of your `*.NN` files to work with the updated Barracuda package.
23+
* Replace all calls to `Agent.GetStepCount()` with `Agent.StepCount`
2224

2325
## Migrating from 0.13 to 0.14
2426

0 commit comments

Comments
 (0)