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

Issue running custom agents. #110

Closed
KasperTK opened this issue Nov 1, 2017 · 22 comments
Closed

Issue running custom agents. #110

KasperTK opened this issue Nov 1, 2017 · 22 comments

Comments

@KasperTK
Copy link

KasperTK commented Nov 1, 2017

After following multiple tutorials i keep getting this error when trying to run my custom agent. I am still new to python and would appriciate the help here is what I am getting.

C:\Users\Danielle>python -m pysc2.bin.agent --map Simple64 --agent pysc2.agents.Adjeera.Adjeera --agent_race T --max_agent_steps 0
Traceback (most recent call last):
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 184, in _run_module_as_main
"main", mod_spec)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\bin\agent.py", line 112, in
app.run(main)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\absl\app.py", line 272, in run
_run_main(main, argv)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\absl\app.py", line 237, in run_main
sys.exit(main(argv))
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\bin\agent.py", line 90, in main
agent_cls = getattr(importlib.import_module(agent_module), agent_name)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 956, in _find_and_load_unlocked
ImportError: No module named 'pysc2.agents.Adjeera'

@greentfrapp
Copy link

The command should be something like

python -m pysc2.bin.agent --map Simple64 --agent <Name of Python script>.<Name of agent class in Python script> --agent_race T --max_agent_steps 0

Assuming that

  • the path of your agent script is C:\Users\Danielle\Adjeera.py
  • the name of the agent class is Adjeera

you can try running

python -m pysc2.bin.agent --map Simple64 --agent Adjeera.Adjeera --agent_race T --max_agent_steps 0

in the C:\Users\Danielle directory. Otherwise it might be simpler to navigate to the folder of your agent script and run it from there.

Hope that helps!

@KasperTK
Copy link
Author

KasperTK commented Nov 2, 2017

I have tried the command

python -m pysc2.bin.agent --map Simple64 --agent Adjeera.Adjeera --agent_race T --max_agent_steps 0

I got the same error as last time. Can you specify running it from the folder where my agent script is?
How I would go about doing that.

On another note it seems to not allow to me choose any specific agent same error each time.

@KasperTK
Copy link
Author

KasperTK commented Nov 2, 2017

Sorry for the double post after executing the script from its folder the game begins to boot up than crashes giving me the following text.

PS C:\Users\Danielle\AppData\Local\Programs\Python\Python35\Lib\site-packages\pysc2\agents> python -m pysc2.bin.agent --map Simple64 --agent Adjeera.Adjeera --ag
ent_race T --max_agent_steps 0
I1102 04:27:39.221402 5840 sc_process.py:148] Connection attempt 0 (running: None)
I1102 04:27:41.282808 5840 sc_process.py:148] Connection attempt 1 (running: None)
I1102 04:27:43.298540 5840 sc_process.py:148] Connection attempt 2 (running: None)
I1102 04:27:45.314206 5840 sc_process.py:148] Connection attempt 3 (running: None)
I1102 04:27:47.356947 5840 sc_process.py:148] Connection attempt 4 (running: None)
I1102 04:27:49.392279 5840 sc_process.py:148] Connection attempt 5 (running: None)
I1102 04:27:51.436405 5840 sc_process.py:148] Connection attempt 6 (running: None)
I1102 04:27:53.474565 5840 sc_process.py:148] Connection attempt 7 (running: None)
I1102 04:28:24.376034 5840 sc2_env.py:200] Environment is ready.
I1102 04:28:24.378532 5840 sc2_env.py:240] Starting episode: 1
Took 0.191 seconds for 0 steps: 0.000 fps
I1102 04:28:24.571171 5840 sc2_env.py:327] Environment Close
I1102 04:28:24.619702 5840 sc2_env.py:342]
Traceback (most recent call last):
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 184, in _run_module_as_main
"main", mod_spec)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\bin\agent.py", line 112, in
app.run(main)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\absl\app.py", line 272, in run
_run_main(main, argv)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\absl\app.py", line 237, in _run_main
sys.exit(main(argv))
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\bin\agent.py", line 98, in main
run_thread(agent_cls, FLAGS.map, FLAGS.render)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\bin\agent.py", line 77, in run_thread
run_loop.run_loop([agent], env, FLAGS.max_agent_steps)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\env\run_loop.py", line 37, in run_loop
a.reset()
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\agents\base_agent.py", line 38, in reset
self.episodes += 1
AttributeError: 'Adjeera' object has no attribute 'episodes'
I1102 04:28:25.042637 5840 sc2_env.py:327] Environment Close
I1102 04:28:25.043120 5840 sc2_env.py:342]
I1102 04:28:25.044623 5840 sc2_env.py:327] Environment Close
I1102 04:28:25.046119 5840 sc2_env.py:342]
W1102 04:28:28.158343 5840 sc_process.py:183] Killing the process.
I1102 04:28:28.625817 5840 sc_process.py:166] Shutdown with return code: 1

@CPUFronz
Copy link

CPUFronz commented Nov 2, 2017

You have to call the constructor of base_agent.BaseAgent in the constructor of your agent: put super(Adjeera, self).__init__() in the __init__ method of your Adjeera class.

It should look something like this:

class Adjeera(base_agent.BaseAgent):
    def __init__(self):
        super(Adjeera, self).__init__()
        # other things to be done by the constructor go here

@KasperTK
Copy link
Author

KasperTK commented Nov 2, 2017

This is what it currently looks like.

class Adjeera(base_agent.BaseAgent):
    def __init__(self):
        self.qlearn = QLearningTable(actions=list(range(len(smart_actions))))
        
        self.previous_killed_unit_score = 0
        self.previous_killed_building_score = 0
        
        self.previous_action = None
        self.previous_state = None

When I try to add the

super(Adjeera, self).__init__()

It gives me several new errors.

@CPUFronz
Copy link

CPUFronz commented Nov 3, 2017

What kind of new errors? Can you please post them here?

@KasperTK
Copy link
Author

KasperTK commented Nov 3, 2017

This is what im getting now

PS C:\Users\Danielle\AppData\Local\Programs\Python\Python35\Lib\site-packages\pysc2\agents> python -m pysc2.bin.agent --map Simple64 --agent Adjeera.Adjeera --agent_race T --max_agent_steps 0
Traceback (most recent call last):
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 184, in _run_module_as_main
"main", mod_spec)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\bin\agent.py", line 112, in
app.run(main)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\absl\app.py", line 272, in run
_run_main(main, argv)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\absl\app.py", line 237, in run_main
sys.exit(main(argv))
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\bin\agent.py", line 90, in main
agent_cls = getattr(importlib.import_module(agent_module), agent_name)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 673, in _load_unlocked
File "", line 661, in exec_module
File "", line 767, in get_code
File "", line 727, in source_to_code
File "", line 222, in _call_with_frames_removed
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\Lib\site-packages\pysc2\agents\Adjeera.py", line 98
super(Adjeera, self).init()

Essentially the same errors with the addition of the last one using the code you gave me.
Should I also post the full code for the class?

@Nostrademous
Copy link

you seem to be calling super(Adjeera, self).init() and not super(Adjeera, self).__init__(). Not the difference.

@KasperTK
Copy link
Author

KasperTK commented Nov 3, 2017

I know it looks like that but it shows up as super(Adjeera, self).__init__() on my command prompt just doesnt when i posted it on here.

@CPUFronz
Copy link

CPUFronz commented Nov 3, 2017

Yes, post the full code for your class.

Btw. the reason why super(Adjeera, self).__init__() is shown as super(Adjeera, self).init() is because it get's interpreted as Markdown and all text between __ gets bold.

@KasperTK
Copy link
Author

KasperTK commented Nov 3, 2017

This is what I have based on the few tutorials I found and read over.

`class Adjeera(base_agent.BaseAgent):
def init(self):
self.qlearn = QLearningTable(actions=list(range(len(smart_actions))))

    self.previous_killed_unit_score = 0
    self.previous_killed_building_score = 0
    
    self.previous_action = None
    self.previous_state = None
    
def transformLocation(self, x, x_distance, y, y_distance):
    if not self.base_top_left:
        return [x - x_distance, y - y_distance]
    
    return [x + x_distance, y + y_distance]
    
def step(self, obs):
    super(Adjeera, self).step(obs)
    
    player_y, player_x = (obs.observation['minimap'][_PLAYER_RELATIVE] == _PLAYER_SELF).nonzero()
    self.base_top_left = 1 if player_y.any() and player_y.mean() <= 31 else 0
    
    unit_type = obs.observation['screen'][_UNIT_TYPE]

    depot_y, depot_x = (unit_type == _TERRAN_SUPPLY_DEPOT).nonzero()
    supply_depot_count = supply_depot_count = 1 if depot_y.any() else 0

    barracks_y, barracks_x = (unit_type == _TERRAN_BARRACKS).nonzero()
    barracks_count = 1 if barracks_y.any() else 0
        
    supply_limit = obs.observation['player'][4]
    army_supply = obs.observation['player'][5]
    
    killed_unit_score = obs.observation['score_cumulative'][5]
    killed_building_score = obs.observation['score_cumulative'][6]
    
    current_state = [
        supply_depot_count,
        barracks_count,
        supply_limit,
        army_supply,
    ]
    
    if self.previous_action is not None:
        reward = 0
            
        if killed_unit_score > self.previous_killed_unit_score:
            reward += KILL_UNIT_REWARD
                
        if killed_building_score > self.previous_killed_building_score:
            reward += KILL_BUILDING_REWARD
            
        self.qlearn.learn(str(self.previous_state), self.previous_action, reward, str(current_state))
    
    rl_action = self.qlearn.choose_action(str(current_state))
    smart_action = smart_actions[rl_action]
    
    self.previous_killed_unit_score = killed_unit_score
    self.previous_killed_building_score = killed_building_score
    self.previous_state = current_state
    self.previous_action = rl_action
    
    if smart_action == ACTION_DO_NOTHING:
        return actions.FunctionCall(_NO_OP, [])

    elif smart_action == ACTION_SELECT_SCV:
        unit_type = obs.observation['screen'][_UNIT_TYPE]
        unit_y, unit_x = (unit_type == _TERRAN_SCV).nonzero()
            
        if unit_y.any():
            i = random.randint(0, len(unit_y) - 1)
            target = [unit_x[i], unit_y[i]]
            
            return actions.FunctionCall(_SELECT_POINT, [_SCREEN, target])
    
    elif smart_action == ACTION_BUILD_SUPPLY_DEPOT:
        if _BUILD_SUPPLY_DEPOT in obs.observation['available_actions']:
            unit_type = obs.observation['screen'][_UNIT_TYPE]
            unit_y, unit_x = (unit_type == _TERRAN_COMMANDCENTER).nonzero()
            
            if unit_y.any():
                target = self.transformLocation(int(unit_x.mean()), 0, int(unit_y.mean()), 20)
            
                return actions.FunctionCall(_BUILD_SUPPLY_DEPOT, [_SCREEN, target])
    
    elif smart_action == ACTION_BUILD_BARRACKS:
        if _BUILD_BARRACKS in obs.observation['available_actions']:
            unit_type = obs.observation['screen'][_UNIT_TYPE]
            unit_y, unit_x = (unit_type == _TERRAN_COMMANDCENTER).nonzero()
            
            if unit_y.any():
                target = self.transformLocation(int(unit_x.mean()), 20, int(unit_y.mean()), 0)
        
                return actions.FunctionCall(_BUILD_BARRACKS, [_SCREEN, target])

    elif smart_action == ACTION_SELECT_BARRACKS:
        unit_type = obs.observation['screen'][_UNIT_TYPE]
        unit_y, unit_x = (unit_type == _TERRAN_BARRACKS).nonzero()
            
        if unit_y.any():
            target = [int(unit_x.mean()), int(unit_y.mean())]
    
            return actions.FunctionCall(_SELECT_POINT, [_SCREEN, target])
    
    elif smart_action == ACTION_BUILD_MARINE:
        if _TRAIN_MARINE in obs.observation['available_actions']:
            return actions.FunctionCall(_TRAIN_MARINE, [[1]])
    
    elif smart_action == ACTION_SELECT_ARMY:
        if _SELECT_ARMY in obs.observation['available_actions']:
            return actions.FunctionCall(_SELECT_ARMY, [[0]])
    
    elif smart_action == ACTION_ATTACK:
        if _ATTACK_MINIMAP in obs.observation["available_actions"]:
            if self.base_top_left:
                return actions.FunctionCall(_ATTACK_MINIMAP, [[1], [39, 45]])
        
            return actions.FunctionCall(_ATTACK_MINIMAP, [[1], [21, 24]])
    
    return actions.FunctionCall(_NO_OP, [])`

@CPUFronz
Copy link

CPUFronz commented Nov 3, 2017

I tried your code (with added super(Adjeera, self).__init__() and it worked fine on my machine. I guess you are having some issues with your setup.

Were there some lines lost while copying and pasting the error message here? If so check out this: tensorflow/tensorflow#7529 it seems to be an similar issue.

@KasperTK
Copy link
Author

KasperTK commented Nov 4, 2017

No that's the whole code for my class and the error messages I received to be safe i double checked the referenced issue and made sure i wasn't missing certain files just to be sure.

Edit: Nvm double checking again

@KasperTK
Copy link
Author

KasperTK commented Nov 4, 2017

After fixing some of the files i was missing I'm still getting error codes namely these.

PS C:\Users\Danielle\AppData\Local\Programs\Python\Python35\Lib\site-packages\pysc2\agents> python -m pysc2.bin.agent --map Simple64 --agent Adjeera.Adjeera --agent_race T
--max_agent_steps 0
I1103 23:04:37.056485 12276 sc_process.py:148] Connection attempt 0 (running: None)
I1103 23:04:39.083933 12276 sc_process.py:148] Connection attempt 1 (running: None)
I1103 23:04:41.115282 12276 sc_process.py:148] Connection attempt 2 (running: None)
I1103 23:04:43.130982 12276 sc_process.py:148] Connection attempt 3 (running: None)
I1103 23:04:45.147072 12276 sc_process.py:148] Connection attempt 4 (running: None)
I1103 23:04:47.173626 12276 sc_process.py:148] Connection attempt 5 (running: None)
I1103 23:04:49.187810 12276 sc_process.py:148] Connection attempt 6 (running: None)
I1103 23:04:51.213186 12276 sc_process.py:148] Connection attempt 7 (running: None)
I1103 23:04:53.223015 12276 sc_process.py:148] Connection attempt 8 (running: None)
I1103 23:04:55.234865 12276 sc_process.py:148] Connection attempt 9 (running: None)
I1103 23:04:57.261970 12276 sc_process.py:148] Connection attempt 10 (running: None)
I1103 23:04:59.283957 12276 sc_process.py:148] Connection attempt 11 (running: None)
I1103 23:05:01.309333 12276 sc_process.py:148] Connection attempt 12 (running: None)
I1103 23:05:03.321424 12276 sc_process.py:148] Connection attempt 13 (running: None)
I1103 23:05:05.345624 12276 sc_process.py:148] Connection attempt 14 (running: None)
I1103 23:05:07.372373 12276 sc_process.py:148] Connection attempt 15 (running: None)
I1103 23:05:09.399859 12276 sc_process.py:148] Connection attempt 16 (running: None)
I1103 23:05:11.428563 12276 sc_process.py:148] Connection attempt 17 (running: None)
I1103 23:06:57.111847 12276 sc2_env.py:200] Environment is ready.
I1103 23:06:57.378677 12276 sc2_env.py:240] Starting episode: 1
Took 0.202 seconds for 0 steps: 0.000 fps
I1103 23:06:57.580648 12276 sc2_env.py:327] Environment Close
I1103 23:06:57.820013 12276 sc2_env.py:342]
Traceback (most recent call last):
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 184, in _run_module_as_main
"main", mod_spec)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\bin\agent.py", line 112, in
app.run(main)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\absl\app.py", line 272, in run
_run_main(main, argv)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\absl\app.py", line 237, in _run_main
sys.exit(main(argv))
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\bin\agent.py", line 98, in main
run_thread(agent_cls, FLAGS.map, FLAGS.render)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\bin\agent.py", line 77, in run_thread
run_loop.run_loop([agent], env, FLAGS.max_agent_steps)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\env\run_loop.py", line 37, in run_loop
a.reset()
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\agents\base_agent.py", line 38, in reset
self.episodes += 1
AttributeError: 'Adjeera' object has no attribute 'episodes'
I1103 23:06:58.383533 12276 sc2_env.py:327] Environment Close
I1103 23:06:58.384036 12276 sc2_env.py:342]
I1103 23:06:58.385036 12276 sc2_env.py:327] Environment Close
I1103 23:06:58.386631 12276 sc2_env.py:342]
W1103 23:07:01.494381 12276 sc_process.py:183] Killing the process.
I1103 23:07:01.983977 12276 sc_process.py:166] Shutdown with return code: 1

@CPUFronz
Copy link

CPUFronz commented Nov 4, 2017

Ok, good. Now that those errors are fixed you just have to add super(Adjeera, self).__init__() to the __init__ method of your Adjeera class as described above.

The reason why you get this error is because in your step() method you call the step method of the super class (super(Adjeera, self).step(obs)), which then tries to access members from the super class that do not exist, because they haven't been initialised before.

@KasperTK
Copy link
Author

KasperTK commented Nov 4, 2017

I put it right where it was shown above like so ofc it all isn't posting as markup.
`class Adjeera(base_agent.BaseAgent):
def init(self):
super(Adjeera, self).init()
self.qlearn = QLearningTable(actions=list(range(len(smart_actions))))

    self.previous_killed_unit_score = 0
    self.previous_killed_building_score = 0
    
    self.previous_action = None
    self.previous_state = None`

This is the error I get when i add super(Adjeera, self).__init__()

PS C:\Users\Danielle\AppData\Local\Programs\Python\Python35\Lib\site-packages\pysc2\agents> python -m pysc2.bin.agent --
map Simple64 --agent Adjeera.Adjeera --agent_race T --max_agent_steps 0
Traceback (most recent call last):
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 184, in _run_module_as_main
"main", mod_spec)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\bin\agent.py", line 112, in
app.run(main)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\absl\app.py", line 272, in run
_run_main(main, argv)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\absl\app.py", line 237, in run_main
sys.exit(main(argv))
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\bin\agent.py", line 90, in main
agent_cls = getattr(importlib.import_module(agent_module), agent_name)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 673, in _load_unlocked
File "", line 661, in exec_module
File "", line 767, in get_code
File "", line 727, in source_to_code
File "", line 222, in _call_with_frames_removed
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\Lib\site-packages\pysc2\agents\Adjeera.py", line 98
super(Adjeera, self).init()
^
TabError: inconsistent use of tabs and spaces in indentation

@greentfrapp
Copy link

Maybe you can try checking the indentations and make sure they are consistent? Since the error you pasted seems to be a TabError at the super(Adjeera, self).__init__() line (line 98).

@KasperTK
Copy link
Author

KasperTK commented Nov 5, 2017

Sorry if I've been a pain to help still very new to this and you have all been very helpful, I fixed the indentations it runs for 5 to 10 seconds before crashing with new errors this time.

PS C:\Users\Danielle\AppData\Local\Programs\Python\Python35\Lib\site-packages\pysc2\agents> python -m pysc2.bin.agent --map Simple64 --agent Adjeera.Adjeera --agent_race
T --max_agent_steps 0
I1104 20:59:07.574983 10708 sc_process.py:148] Connection attempt 0 (running: None)
I1104 20:59:09.961695 10708 sc_process.py:148] Connection attempt 1 (running: None)
I1104 20:59:11.966601 10708 sc_process.py:148] Connection attempt 2 (running: None)
I1104 20:59:13.968271 10708 sc_process.py:148] Connection attempt 3 (running: None)
I1104 20:59:15.970692 10708 sc_process.py:148] Connection attempt 4 (running: None)
I1104 20:59:17.984621 10708 sc_process.py:148] Connection attempt 5 (running: None)
I1104 20:59:19.988043 10708 sc_process.py:148] Connection attempt 6 (running: None)
I1104 20:59:21.992448 10708 sc_process.py:148] Connection attempt 7 (running: None)
I1104 20:59:23.999373 10708 sc_process.py:148] Connection attempt 8 (running: None)
I1104 20:59:26.002808 10708 sc_process.py:148] Connection attempt 9 (running: None)
I1104 21:00:11.329096 10708 sc2_env.py:200] Environment is ready.
I1104 21:00:11.372124 10708 sc2_env.py:240] Starting episode: 1
C:\Users\Danielle\AppData\Local\Programs\Python\Python35\Lib\site-packages\pysc2\agents\Adjeera.py:74: FutureWarning: 'argmax' is deprecated. Use 'idxmax' instead. The b
ehavior of 'argmax' will be corrected to return the positional maximum in the future. Use 'series.values.argmax' to get the position of the maximum now.
action = state_action.argmax()
Took 0.274 seconds for 1 steps: 3.647 fps
I1104 21:00:11.647820 10708 sc2_env.py:327] Environment Close
I1104 21:00:11.672841 10708 sc2_env.py:342]
Traceback (most recent call last):
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 184, in _run_module_as_main
"main", mod_spec)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\bin\agent.py", line 112, in
app.run(main)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\absl\app.py", line 272, in run
_run_main(main, argv)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\absl\app.py", line 237, in _run_main
sys.exit(main(argv))
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\bin\agent.py", line 98, in main
run_thread(agent_cls, FLAGS.map, FLAGS.render)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\bin\agent.py", line 77, in run_thread
run_loop.run_loop([agent], env, FLAGS.max_agent_steps)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\env\run_loop.py", line 41, in run_loop
for agent, timestep in zip(agents, timesteps)]
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pysc2\env\run_loop.py", line 41, in
for agent, timestep in zip(agents, timesteps)]
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\Lib\site-packages\pysc2\agents\Adjeera.py", line 151, in step
rl_action = self.qlearn.choose_action(str(current_state))
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\Lib\site-packages\pysc2\agents\Adjeera.py", line 74, in choose_action
action = state_action.argmax()
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pandas\util_decorators.py", line 36, in wrapper
return alternative(*args, **kwargs)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pandas\core\series.py", line 1357, in idxmax
i = nanops.nanargmax(_values_from_object(self), skipna=skipna)
File "C:\Users\Danielle\AppData\Local\Programs\Python\Python35\lib\site-packages\pandas\core\nanops.py", line 74, in _f
raise TypeError(msg.format(name=f.name.replace('nan', '')))
TypeError: reduction operation 'argmax' not allowed for this dtype
I1104 21:00:12.361322 10708 sc2_env.py:327] Environment Close
I1104 21:00:12.361821 10708 sc2_env.py:342]
I1104 21:00:12.362823 10708 sc2_env.py:327] Environment Close
I1104 21:00:12.364825 10708 sc2_env.py:342]
W1104 21:00:15.470270 10708 sc_process.py:183] Killing the process.
I1104 21:00:15.927076 10708 sc_process.py:166] Shutdown with return code: 1

@greentfrapp
Copy link

It seems to be something related to the argmax call. Can you try uploading your code to a repo or posting it as a gist so we can take a look at it?

@KasperTK
Copy link
Author

KasperTK commented Nov 5, 2017

Uploaded it to https://github.com/Arkknightmare/Adjeera

@greentfrapp
Copy link

Hey I've tried running your code and it actually works fine on my laptop. Looking at your error message, it looks like it's related to the newest version of pandas (I'm still on pandas==0.15.2), see discussion here.

TL;DR what you can do is downgrade your pandas or just change line 74 in your code to action = state_action.values.argmax() note the extra values, in order to call argmax on the underlying np array according to the workaround in the last comment in the link above. See if that helps!

@KasperTK
Copy link
Author

KasperTK commented Nov 6, 2017

Yes adding values to the line finally fixed it and I can finally move forward thanks for all your help everyone.

@KasperTK KasperTK closed this as completed Nov 6, 2017
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

No branches or pull requests

4 participants