Skip to content
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

Agent update #8

Merged
merged 9 commits into from
Jun 24, 2024
Merged

Agent update #8

merged 9 commits into from
Jun 24, 2024

Conversation

kozzy97
Copy link
Member

@kozzy97 kozzy97 commented Jun 21, 2024

Proposed change(s)

I have added a random action agent implemented with the low-level API (as per Braitenberg) and fixed the reliability of the braitenberg agent.

Types of change(s)

  • [X ] Bug fix
  • [ X] New feature
  • Code refactor
  • Breaking change
  • Documentation update
  • Other (please describe)

Checklist

  • [X ] Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
  • Updated the migration guide (if applicable)

Other comments

Screenshots (if any)

Copy link
Contributor

@alhasacademy96 alhasacademy96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested these on my end also and they as expected with your new code.

You can merge but i did put some comments in the review for you to check :)


def get_new_action(self, prev_step: AAIAction) -> AAIAction:
"""
Provide a vector of 9 real values, one for each action, which is then softmaxed to provide the probability of selecting that action. Relative differences between the values is what is important.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this need to be maintained in the long run? For example, we may add new actions to the agent so will this script need to be maintained accordingly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, will require updates.

@@ -20,6 +20,7 @@ def main():
rayMaxDegrees=30,
raysPerSide=(n_rays - 1) // 2,
play=False,
inference=True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was inference set true here and was not the case before the PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because presumably the user would want to watch the agent completing the task to confirm expected behaviour.

@@ -28,6 +28,7 @@ class RayCastObjects(enum.Enum):
SIGNPOSTER = 11
DECAYGOAL = 12
DECAYGOALBOUNCE = 13
HOLLOWBOX = 14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this with this PR as otherwise it would have been delayed until the next major PR for python codebase. Standalone mod.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is best practice.

randomAgent = RandomActionAgent(step_length_distribution=lambda: np.random.normal(
5, 1)) # a Rayleigh walker (sampling from normal distribution)

# by default should be AnimalAI?team=0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you mean by this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which part? a Rayleigh Walker is a type of random walker in stochastic process theory, where angles and saccades are drawn from normal distributions. The default to AnimalAI?team=0 is the standard behaviour for the AAI low-level API.

actions = AAIActions()

# Run two episodes
for _episode in range(2):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do the episodes start at index 0? so, arena 0, arena 1, ... , n arenas.

Did i misunderstand this loop?

Copy link
Member Author

@kozzy97 kozzy97 Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It plays the config twice over.

@@ -7,11 +7,11 @@ arenas:
- !Item
name: Agent
positions:
- !Vector3 { x: 5, y: 1, z: 5 }
- !Vector3 { x: 5, y: 0, z: 5 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to let you know the y value constraints are corrected in unity (as heads up note)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good change.

@alhasacademy96
Copy link
Contributor

have you also considered the versioning? Is this a breaking change (becomes version 5.0.0) to the braintenberg agent? Or can we go to 4.1.0 OR 4.0.2 depending on the scale of the changes @kozzy97

@kozzy97
Copy link
Member Author

kozzy97 commented Jun 24, 2024

This is not a breaking change (the behaviour of the braitenberg is slightly different and more reliable but all scripts should work the same), but the addition of the random action agent is significant. I would recommend this, plus the hollowbox change, be included in a 4.1.0 release.

@kozzy97 kozzy97 merged commit 1d78e56 into main Jun 24, 2024
@kozzy97 kozzy97 deleted the agent-update branch June 24, 2024 08:51
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants