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

Resolves #115 #116

Open
wants to merge 8 commits into
base: solve-collectables-sb3
Choose a base branch
from
Open

Resolves #115 #116

wants to merge 8 commits into from

Conversation

CinquilCinquil
Copy link

@CinquilCinquil CinquilCinquil commented Nov 7, 2024

@RickFqt RickFqt force-pushed the solve-collectables-sb3 branch from 7f7e1d4 to b67bd85 Compare November 12, 2024 10:32
Copy link
Member

@alvarofpp alvarofpp left a 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:

I recommend splitting the PR into two.

Copy link
Member

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?

Comment on lines +23 to +27
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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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])

Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

Why not:

Suggested change
from urnai.sc2.actions.sc2_actions import raw_functions_classes as sc2_actions
from urnai.sc2.actions import raw_functions_classes

Copy link
Author

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
Copy link
Member

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.

Comment on lines +49 to +52
if len(self.pending_actions) == 0:
action = self.noaction
else:
action = [self.pending_actions.pop()]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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()]

Comment on lines +56 to +75
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()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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?

Copy link
Member

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?

Copy link
Member

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.

Comment on lines +92 to +94
def normalize_map(self, map_):
# map = (map_ - map_.min()) / (map_.max() - map_.min())
return map_
Copy link
Member

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.

@CinquilCinquil
Copy link
Author

CinquilCinquil commented Dec 6, 2024

It seems to me that this PR does two things:

I recommend splitting the PR into two.

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 ?

@alvarofpp
Copy link
Member

The issue #115 will only be resolved when the merge occurs for v2. I believe the best sequence is: take the changes related to #115 and open a PR for v2, merge it and then update the solve-collectables-sb3 branch with this change.

@CinquilCinquil
Copy link
Author

I created the new PR.

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