Skip to content

Update knights_archers_zombies to v11#1297

Open
dm-ackerman wants to merge 58 commits intoFarama-Foundation:masterfrom
dm-ackerman:kaz_update
Open

Update knights_archers_zombies to v11#1297
dm-ackerman wants to merge 58 commits intoFarama-Foundation:masterfrom
dm-ackerman:kaz_update

Conversation

@dm-ackerman
Copy link
Copy Markdown
Contributor

@dm-ackerman dm-ackerman commented Apr 30, 2025

Description

Behavior changes:

  • replaced vector_state, use_typemasks, and sequence_space
    parameters with obs_method
    The old options had multiple invalid combinations. The obs_method
    options are listed in the documentation
  • fixed bugs related to initial spawning
  • fixed state, obs, typemasks to match docs
  • arrows persist even if the archer that fires them is removed
  • 'pad_observation' parameter was removed (it did nothing)
  • 'spawn_rate' argument is now 'spawn_delay'. Same Behavior.
    'Rate' implied higher numbers were faster which was the
    opposite of the behavior.
  • fixed incorrect bounds on agent movement

Other changes:

  • Documentation was updated and corrected
  • doc strings added
  • Type hints were added
  • Fixed issue with FPS scaling movement
  • Agent actions were explicitly defined
  • Removed redundant/dead code
  • Made various classes into subclasses as needed
  • Moved agent logic into agent classes
  • Removed extraneous data structures
  • Adjusted rendering/draw/screen code
  • Rotated player icons to correct orientation
  • Added env specific tests
  • Combined all zombie actions into single function
  • Combined weapon actions into single function
  • Add check that render_mode is valid
  • Move space creations to own functions
  • Fixed some int/float confusion
  • Renamed items to avoid name shadowing/collision
  • Did misc code cleanup

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • I have run the pre-commit checks with pre-commit run --all-files (see CONTRIBUTING.md instructions to set it up)
  • I have run pytest -v and no errors are present.
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I solved any possible warnings that pytest -v has generated that are related to my code to the best of my knowledge.
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

The archer and knight were not aligned properly.
Arrow's initial position was set incorrectly.
This impacted the display and the observations
Several changes made to Zombie class:
* class is now responsible for initial position.
  This was broken before - zombie could spawn outside allowed area.
  This led to occasional image jumping behavior in rendering
  Unsure if it caused issues with the observations
* simplified x-motion code
* added type hints and docstrings

Additionally,
* removed SCREEN_UNITS from constants (no longer used)
* added WALL_WIDTH to constants (used to define boundaries for zombies)
* removed random position assignment in kaz env (now in class)
Also removed from documentation. It did nothing and the docs were wrong.
previous location caused circular import.
Added _fill_agent_name_mapping to fill the mapping which is done
in two locations that had identical code.
This wasn't in the documentation and was confusing in the code.
There is now an Actions Enum with named actions.
The env documentation was updated to list the actions.
The mixed 0-indexed and 1-indexed actions have been converted to
0-indexed everywhere.
remove name collision with pygame
Just to make a little clearer
There are two different methods, moving them to different functions
keeps the code cleaner.
The direction and angle contained the same information. Angle has been
removed and all used of it converted use the direction.
alive() is a function for pygame sprites, so the alive data members
conflict with this.
moved duplicate code into base class
fixed floats being assigned to ints
added type hints
added docstrings
Replaced `vector_state`, `use_typemasks`, and `sequence_space` parameters
with `obs_method`.

The 3 bools gave 8 options - half of which were invalid.

`obs_method` takes one of four values
* 'vector' (default) [vector_state=T,use_typemasks=F,sequence_space=F]
* 'image' [vector_state=F,use_typemasks=F,sequence_space=F]
* 'vector-sequence' [vector_state=T,use_typemasks=T,sequence_space=T]
* 'vector-masked' [vector_state=T,use_typemasks=T,sequence_space=F]

The actual behavior of the spaces is unchanged.
The components are now joined into a single backgroun image instead of
being re-added individually each time.
Changing agent_list to agent_map makes the agent_name_mapping not
needed. This reduces a layer of abstraction when accessing an
agent.
The method changes, but result should be the same. The intent is to
support future plans.
removes some warnings
This adds a mix-in class that adds properties for vector state with and
without typemasking.
This also adds an interval timer to simplify the code of deciding when
to spawn a new zombie.
The docs said the state listed archers before knights. This wasn't
explicitly done in the code (although may have worked out that way).
It's now explicitly ordered.
The behavior is the same but the name was changed because rate implied a
higher number was faster which was the opposite of the behavior.
Always create a screen
Remove unneeded draws
Store screen dimensions as var for later use
This will be added back after the manual policy is updated
added docstrings and updated/expanded the env doc
In the process, also avoid geting an image unless needed
There were artifical limits on when forward or back movement could be
done. These were removed. In addition, the tests for out of bounds and
the clamping to be within bounds were not aligned with the screen area.
This has been fixed.
This now correctly identifies when agents reach the bottom as well as
being more general in supporting left/right limits
@dm-ackerman
Copy link
Copy Markdown
Contributor Author

hmm.... The are two groups of failures: a) waterworld tests and b) pygame display mode issues

This PR doesn't touch waterworld and I see an earlier PR is failing there too, so I don't think that's me.

I see the display mode issues locally too, but i thought that was an SDL bug on my system. I'm confused by this one because the errors are in envs i didn't touch. I'm going to poke at this later.

@dm-ackerman
Copy link
Copy Markdown
Contributor Author

The display issue is fixed. The waterworld issue is the same as in #1295 . This should be ready after that is fixed.

@MathieuFonsProjects
Copy link
Copy Markdown

Hi, I'm interested in this branch, any news of merging this yet ?

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.

3 participants