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

Update combat.py #41

Merged
merged 4 commits into from
Nov 10, 2021
Merged

Update combat.py #41

merged 4 commits into from
Nov 10, 2021

Conversation

tjuHaoXiaotian
Copy link
Contributor

@tjuHaoXiaotian tjuHaoXiaotian commented Oct 18, 2021

Fix some bugs:

    1. In get_agent_obs(), the local variable '_type' was mistakenly written as 'type'.
    2. In get_agent_obs(), the x-coordinates and y-coordinates of the entites (whether the entity is 'agent' or 'opponent') within each agent's view range were incorrectly set to the agent's position.
    3. self.agent_prev_pos and self.opp_prev_pos are not updated, but in __update_agent_view() and __update_opp_view(), these previous positions are cleared. Thus the movement records are incorrect.
    4. The self._agent_cool and self._opp_cool are not updated (i.e., the agents and opponents could execute 'attack' action at every step if within range).
        updates:
          (1) update the is_fireable() function to check if the attack agents have been cooled down. 
          (2) add self._agent_cool_step and self._opp_cool_step to track the cooling down of the agents and opponents.
    5. In the opps_action() function, the dead opponent could still call reduce_distance_move() function to sample a 'move' action, which will raise an 'no where to move' exception when the position of the dead opponent is the same with any of the agents.
    6. Update the get_agent_obs(): only return the local view of observation when the agent is alive, otherwise return a zero vector.

Add 2 new functions to support CTDE

    7. Add get_state() to support CTDE (centralized training with decentralized execution).

Fix some bugs:
    1. in get_agent_obs(), the local variable '_type' was mistakenly written as 'type'.

    2. self.agent_prev_pos and self.opp_prev_pos are not updated, but in __update_agent_view() and __update_opp_view(), these previous positions are cleared. Thus the movement records are incorrect.

    3. The self._agent_cool and self._opp_cool are not updated (i.e., the agents and opponents could execute 'attack' action at every step if within range).
        updates:
          (1) update the is_fireable() function to check if the attack agents have been cooled down. 
          (2) add self._agent_cool_step and self._opp_cool_step to track the cooling down of the agents and opponents.

    4. In the opps_action() function, the dead opponent could still call reduce_distance_move() function to sample a 'move' action, which will raise an 'no where to move' exception when the position of the dead opponent is the same with any of the agents.

    5. Update the get_agent_obs(): only return the local view of observation when the agent is alive, otherwise return a zero vector.

Add 2 new functions to support CTDE
    6. Add get_state() to support CTDE (centralized training with decentralized execution).
In get_agent_obs(), the x-coordinates and y-coordinates of the entites (whether the entity is 'agent' or 'opponent') within each agent's view range were incorrectly set to the agent's position.
@koulanurag
Copy link
Owner

Thanks for these changes. I will probably merge it by the end of the month.

Thanks again!

Copy link
Owner

@koulanurag koulanurag left a comment

Choose a reason for hiding this comment

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

Overall looks good! Thanks for the changes.

I can merge it once you resolve the "_render" comment.

remove the unused "_render"
@koulanurag
Copy link
Owner

All looks good. But, Let's write some more exhaustive test cases. You may use this as a reference.

@koulanurag koulanurag merged commit 564fad1 into koulanurag:master Nov 10, 2021
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