mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Misc.
This commit is contained in:
parent
02dd22eaf4
commit
8dee48d966
1 changed files with 13 additions and 11 deletions
|
@ -715,7 +715,8 @@ class InitialNode(Node, namedtuple('InitialNode', 'search')):
|
||||||
search = self.search
|
search = self.search
|
||||||
for pokemon, version_groups in search.pokemon_moves.items():
|
for pokemon, version_groups in search.pokemon_moves.items():
|
||||||
egg_groups = search.egg_groups[search.evolution_chains[pokemon]]
|
egg_groups = search.egg_groups[search.evolution_chains[pokemon]]
|
||||||
if any(search.breeds_required[group] for group in egg_groups):
|
if any(search.breeds_required[group] for group in egg_groups) or (
|
||||||
|
search.evolution_chains[pokemon] == search.goal_evolution_chain):
|
||||||
for version_group in version_groups:
|
for version_group in version_groups:
|
||||||
action = StartAction(search, pokemon, version_group)
|
action = StartAction(search, pokemon, version_group)
|
||||||
node = PokemonNode(
|
node = PokemonNode(
|
||||||
|
@ -729,7 +730,7 @@ class InitialNode(Node, namedtuple('InitialNode', 'search')):
|
||||||
yield 0, action, node
|
yield 0, action, node
|
||||||
|
|
||||||
class PokemonNode(Node, Facade, namedtuple('PokemonNode',
|
class PokemonNode(Node, Facade, namedtuple('PokemonNode',
|
||||||
'pokemon_ level version_group_ new_level moves_ search')):
|
'search pokemon_ level version_group_ new_level moves_')):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "lv.{level:3}{s} {self.pokemon.identifier:<10.10} in {version_group_:3} with {moves}".format(
|
return "lv.{level:3}{s} {self.pokemon.identifier:<10.10} in {version_group_:3} with {moves}".format(
|
||||||
|
@ -866,16 +867,17 @@ class PokemonNode(Node, Facade, namedtuple('PokemonNode',
|
||||||
egg_groups = search.egg_groups[evo_chain]
|
egg_groups = search.egg_groups[evo_chain]
|
||||||
breeds_required = search.breeds_required
|
breeds_required = search.breeds_required
|
||||||
moves = self.moves_
|
moves = self.moves_
|
||||||
for group in egg_groups:
|
|
||||||
if moves in breeds_required[group] or evo_chain == search.goal_evolution_chain:
|
|
||||||
cost = search.costs['breed']
|
cost = search.costs['breed']
|
||||||
cost += search.costs['egg'] * len(moves)
|
cost += search.costs['egg'] * len(moves)
|
||||||
cost += search.costs['breed-penalty'] * len(search.egg_moves - moves)
|
cost += search.costs['breed-penalty'] * len(search.egg_moves - moves)
|
||||||
yield cost, None, BreedNode(search=self.search, dummy='b', group_=group,
|
for group in egg_groups:
|
||||||
version_group_=self.version_group_, moves_=self.moves_)
|
if moves in breeds_required[group]:
|
||||||
|
yield cost, None, BreedNode(search=self.search, dummy='breed',
|
||||||
|
group_=group, version_group_=self.version_group_,
|
||||||
|
moves_=self.moves_)
|
||||||
|
|
||||||
class BreedNode(Node, namedtuple('BreedNode',
|
class BreedNode(Node, namedtuple('BreedNode',
|
||||||
'group_ version_group_ dummy search moves_')):
|
'search dummy group_ version_group_ moves_')):
|
||||||
"""Breed node
|
"""Breed node
|
||||||
This serves to prevent duplicate breeds, by storing only the needed info
|
This serves to prevent duplicate breeds, by storing only the needed info
|
||||||
in the namedtuple.
|
in the namedtuple.
|
||||||
|
@ -898,7 +900,7 @@ class BreedNode(Node, namedtuple('BreedNode',
|
||||||
if 'light-ball-pichu' in methods:
|
if 'light-ball-pichu' in methods:
|
||||||
bred_moves.add(move)
|
bred_moves.add(move)
|
||||||
cost = search.costs['per-hatch-counter'] * search.hatch_counters[baby]
|
cost = search.costs['per-hatch-counter'] * search.hatch_counters[baby]
|
||||||
yield 0, BreedAction(self.search, baby, moves), PokemonNode(
|
yield 0, BreedAction(self.search, baby, bred_moves), PokemonNode(
|
||||||
search=self.search, pokemon_=baby, level=hatch_level,
|
search=self.search, pokemon_=baby, level=hatch_level,
|
||||||
version_group_=vg, moves_=bred_moves, new_level=True)
|
version_group_=vg, moves_=bred_moves, new_level=True)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue