-
Notifications
You must be signed in to change notification settings - Fork 8
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
Resolves #115 #116
base: solve-collectables-sb3
Are you sure you want to change the base?
Resolves #115 #116
Conversation
All of these classes inherit from ActionBase
7f7e1d4
to
b67bd85
Compare
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.
It seems to me that this PR does two things:
- It solves the Automatic class creation for pysc2 actions #115 issue;
- It inserts an experiment or classes and functions for the mineral collecting minigame.
I recommend splitting the PR into two.
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.
Why does this file need to exist or be here?
actions.RAW_FUNCTIONS.no_op() #PySC2 | ||
sc2_actions["no_op"].run() #URNAI | ||
|
||
actions.RAW_FUNCTIONS.Move_pt('now', unit.tag, [new_army_x, new_army_y]) #PySC2 | ||
sc2_actions["Move_pt"].run('now', unit.tag,[new_army_x, new_army_y]) #URNAI |
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.
actions.RAW_FUNCTIONS.no_op() #PySC2 | |
sc2_actions["no_op"].run() #URNAI | |
actions.RAW_FUNCTIONS.Move_pt('now', unit.tag, [new_army_x, new_army_y]) #PySC2 | |
sc2_actions["Move_pt"].run('now', unit.tag,[new_army_x, new_army_y]) #URNAI | |
# PySC2 | |
actions.RAW_FUNCTIONS.no_op() | |
actions.RAW_FUNCTIONS.Move_pt('now', unit.tag, [new_army_x, new_army_y]) | |
# URNAI | |
sc2_actions["no_op"].run() | |
sc2_actions["Move_pt"].run('now', unit.tag,[new_army_x, new_army_y]) |
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.
Why does this file need to exist or be here?
@@ -2,7 +2,7 @@ | |||
|
|||
from pysc2.lib import actions | |||
|
|||
from urnai.sc2.actions.sc2_action import SC2Action | |||
from urnai.sc2.actions.sc2_actions import raw_functions_classes as sc2_actions |
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.
Why not:
from urnai.sc2.actions.sc2_actions import raw_functions_classes as sc2_actions | |
from urnai.sc2.actions import raw_functions_classes |
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.
i think using it with a smaller name is better. Is this a valid enough reason?
@@ -0,0 +1,23 @@ | |||
from abc import abstractmethod | |||
from typing import Any |
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.
We need to avoid using typing
because of that PEP we discussed earlier.
if len(self.pending_actions) == 0: | ||
action = self.noaction | ||
else: | ||
action = [self.pending_actions.pop()] |
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.
if len(self.pending_actions) == 0: | |
action = self.noaction | |
else: | |
action = [self.pending_actions.pop()] | |
action = self.noaction | |
if len(self.pending_actions) > 0: | |
action = [self.pending_actions.pop()] |
def solve_action(self, action_idx, obs): | ||
if action_idx is not None: | ||
if action_idx is not self.noaction: | ||
action = self.actions[action_idx] | ||
if action == self.moveleft: | ||
self.move_left(obs) | ||
elif action == self.moveright: | ||
self.move_right(obs) | ||
elif action == self.moveup: | ||
self.move_up(obs) | ||
elif action == self.movedown: | ||
self.move_down(obs) | ||
else: | ||
# if action_idx was None, this means that the actionwrapper | ||
# was not resetted properly, so I will reset it here | ||
# this is not the best way to fix this | ||
# but until we cannot find why the agent is | ||
# not resetting the action wrapper properly | ||
# i'm gonna leave this here | ||
self.reset() |
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.
def solve_action(self, action_idx, obs): | |
if action_idx is not None: | |
if action_idx is not self.noaction: | |
action = self.actions[action_idx] | |
if action == self.moveleft: | |
self.move_left(obs) | |
elif action == self.moveright: | |
self.move_right(obs) | |
elif action == self.moveup: | |
self.move_up(obs) | |
elif action == self.movedown: | |
self.move_down(obs) | |
else: | |
# if action_idx was None, this means that the actionwrapper | |
# was not resetted properly, so I will reset it here | |
# this is not the best way to fix this | |
# but until we cannot find why the agent is | |
# not resetting the action wrapper properly | |
# i'm gonna leave this here | |
self.reset() | |
def solve_action(self, action_idx, obs): | |
if action_idx is None: | |
self.reset() | |
return | |
... |
I didn't understand the rest of the function. Could you add a description to the function describing what you are trying to do?
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.
Is this file from an experiment?
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.
I recommend putting everything inside a “private” function that receives the list from pysc2 and then declaring the variables raw_functions_classes
and functions_classes
.
def normalize_map(self, map_): | ||
# map = (map_ - map_.min()) / (map_.max() - map_.min()) | ||
return map_ |
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.
Either insert a logic into this function or remove it.
I built this branch on top of the solve-collectables-sb3 because the changes i was making were better reflected using elements in here that were not yet in v2. I intented to have it be merged back into solve-collectables-sb3 instead of directly onto v2. Can i correct only the problems related to Automatic class creation for pysc2 actions #115 and then merge it onto solve-collectables-sb3 ? |
I created the new PR. |
#115