Using linux for poke env yields ConstantTeambuilder object has no attribute '_mons'
As the title says I get this error only on linux. I use the same code on Windows and it works fine, but I wish to use it on linux.
The issue seems to stem from poke_env/teambuilder/constant_teambuilder.py specifically in return self._mons
Hi @AlanOsys, Thanks for opening this issue. Can you post a minimum example to reproduce this issue?
team_1 = """ Goodra (M) @ Assault Vest Ability: Sap Sipper EVs: 248 HP / 252 SpA / 8 Spe Modest Nature IVs: 0 Atk
- Dragon Pulse
- Flamethrower
- Sludge Wave
- Thunderbolt
Sylveon (M) @ Leftovers Ability: Pixilate EVs: 248 HP / 244 Def / 16 SpD Calm Nature IVs: 0 Atk
- Hyper Voice
- Mystical Fire
- Protect
- Wish
Cinderace (M) @ Life Orb Ability: Blaze EVs: 252 Atk / 4 SpD / 252 Spe Jolly Nature
- Pyro Ball
- Sucker Punch
- U-turn
- High Jump Kick
Toxtricity (M) @ Throat Spray Ability: Punk Rock EVs: 4 Atk / 252 SpA / 252 Spe Rash Nature
- Overdrive
- Boomburst
- Shift Gear
- Fire Punch
Seismitoad (M) @ Leftovers Ability: Water Absorb EVs: 252 HP / 252 Def / 4 SpD Relaxed Nature
- Stealth Rock
- Scald
- Earthquake
- Toxic
Corviknight (M) @ Leftovers Ability: Pressure EVs: 248 HP / 80 SpD / 180 Spe Impish Nature
- Defog
- Brave Bird
- Roost
- U-turn """
team_2 = """ Togekiss @ Leftovers Ability: Serene Grace EVs: 248 HP / 8 SpA / 252 Spe Timid Nature IVs: 0 Atk
- Air Slash
- Nasty Plot
- Substitute
- Thunder Wave
Galvantula @ Focus Sash Ability: Compound Eyes EVs: 252 SpA / 4 SpD / 252 Spe Timid Nature IVs: 0 Atk
- Sticky Web
- Thunder Wave
- Thunder
- Energy Ball
Cloyster @ Leftovers Ability: Skill Link EVs: 252 Atk / 4 SpD / 252 Spe Adamant Nature
- Icicle Spear
- Rock Blast
- Ice Shard
- Shell Smash
Sandaconda @ Focus Sash Ability: Sand Spit EVs: 252 Atk / 4 SpD / 252 Spe Jolly Nature
- Stealth Rock
- Glare
- Earthquake
- Rock Tomb
Excadrill @ Focus Sash Ability: Sand Rush EVs: 252 Atk / 4 SpD / 252 Spe Adamant Nature
- Iron Head
- Rock Slide
- Earthquake
- Rapid Spin
Cinccino @ Leftovers Ability: Skill Link EVs: 252 Atk / 4 Def / 252 Spe Jolly Nature
-
Bullet Seed
-
Knock Off
-
Rock Blast
-
Tail Slap """ from poke_env import RandomPlayer from poke_env.data import GenData class RandomTeamFromPool(Teambuilder): def init(self, pokemons): self.pokemons = []
for pokemon in pokemons: parsed_mons = self.parse_showdown_team(pokemon) self.pokemons.append(parsed_mons[0]) self.n_pokemons = len(self.pokemons) assert self.n_pokemons >= 6def yield_team(self): idxs = np.random.choice(self.n_pokemons, 6, replace=False) team = [self.pokemons[idx] for idx in idxs] return self.join_team(team) def yield_team_for_a_mons(self,pokemonIdx=None): #print(len(str(self.pokemons).replace("[","").replace("]","").split("|")[:-1])) if pokemonIdx == None: picked_idx = np.random.choice(self.n_pokemons, 1, replace=False) else: picked_idx = [pokemonIdx] picked_mon = [self.pokemons[idx] for idx in picked_idx] #print(picked_mon,picked_idx) idxs = [picked_idx] while(picked_idx in idxs): idxs = np.random.choice(self.n_pokemons, 5, replace=False) #print(idxs) team = [self.pokemons[idx] for idx in idxs] team.append(picked_mon[0]) return self.join_team(team) custom_builder = RandomTeamFromPool(pokemons) print(custom_builder.yield_team_for_a_mons()) #use this ^ to generate like 10 teams for one mon at first #then do this for 20 mons teams_per_mon = [] for i in range (0,len(pokemons)): teams = [] for j in range(0,10): #print(custom_builder.yield_team_for_a_mons(i)) teams.append(custom_builder.yield_team_for_a_mons(i)) teams_per_mon.append(teams) player_1 = RandomPlayer( battle_format="gen9customgame", team=teams_per_mon[0][0], max_concurrent_battles=10, ) player_2 = RandomPlayer( battle_format="gen9customgame", team=teams_per_mon[0][0], max_concurrent_battles=10, ) await player_1.battle_against(player_2, n_battles=10) tem = int(player_1.n_won_battles/10*100)
It works if i dont use a custom team builder, but its something i would really want to use
I wonder if this has to do with carriage return (\r\n) v. line feed (\n). Most editors give you the option to choose. If yours does, can you try changing it and see if it fixes this issue?