-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Merged
chriselion
merged 3 commits into
develop-modify-stepping-logic
from
develop-modify-stepping-logic-test
Feb 18, 2020
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,46 @@ 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); | ||
} | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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