-
Notifications
You must be signed in to change notification settings - Fork 4.4k
step logic changes: unit test #3467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -487,10 +487,8 @@ public void TestCumulativeReward() | |
agent1.LazyInitialize(); | ||
agent2.SetPolicy(new TestPolicy()); | ||
|
||
int expectedAgent1Resets= 0; | ||
int expectedAgent1ActionSinceReset = 0; | ||
var expectedAgent1ActionSinceReset = 0; | ||
|
||
var j = 0; | ||
for (var i = 0; i < 50; i++) | ||
{ | ||
expectedAgent1ActionSinceReset += 1; | ||
|
@@ -518,30 +516,44 @@ public void TestMaxStepsReset() | |
decisionRequester.DecisionPeriod = 1; | ||
decisionRequester.Awake(); | ||
|
||
var maxStep = 6; | ||
const int maxStep = 6; | ||
agent1.maxStep = maxStep; | ||
agent1.LazyInitialize(); | ||
|
||
int expectedResets= 0; | ||
int expectedAgentAction = 0; | ||
int expectedAgentActionSinceReset = 0; | ||
var expectedAgentStepCount = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added some extra checks on the step count and collectobservations calls. |
||
var expectedResets= 0; | ||
var expectedAgentAction = 0; | ||
var expectedAgentActionSinceReset = 0; | ||
var expectedCollectObsCalls = 0; | ||
var expectedCollectObsCallsSinceReset = 0; | ||
|
||
for (var i = 0; i < 15; i++) | ||
{ | ||
// Agent should observe and act on each Academy step | ||
expectedAgentAction += 1; | ||
expectedAgentActionSinceReset += 1; | ||
if (expectedAgentActionSinceReset == maxStep || (i == 0)){ | ||
expectedCollectObsCalls += 1; | ||
expectedCollectObsCallsSinceReset += 1; | ||
expectedAgentStepCount += 1; | ||
|
||
// If the next step will put the agent at maxSteps, we expect it to reset | ||
if (agent1.GetStepCount() == maxStep - 1 || (i == 0)){ | ||
|
||
expectedResets +=1; | ||
} | ||
|
||
if (expectedAgentActionSinceReset == maxStep){ | ||
if (agent1.GetStepCount() == maxStep - 1){ | ||
expectedAgentActionSinceReset = 0; | ||
expectedCollectObsCallsSinceReset = 0; | ||
expectedAgentStepCount = 0; | ||
} | ||
aca.EnvironmentStep(); | ||
|
||
Assert.AreEqual(expectedAgentAction, agent1.agentActionCalls); | ||
Assert.AreEqual(expectedAgentStepCount, agent1.GetStepCount()); | ||
Assert.AreEqual(expectedResets, agent1.agentResetCalls); | ||
Assert.AreEqual(expectedAgentAction, agent1.agentActionCalls); | ||
Assert.AreEqual(expectedAgentActionSinceReset, agent1.agentActionCallsSinceLastReset); | ||
Assert.AreEqual(expectedCollectObsCalls, agent1.collectObservationsCalls); | ||
Assert.AreEqual(expectedCollectObsCallsSinceReset, agent1.collectObservationsCallsSinceLastReset); | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were unused, and switch to
var
instead ofint