Skip to content

Commit

Permalink
Cluster Selection so it doesn't jump from cluster to cluster (#2153)
Browse files Browse the repository at this point in the history
* added secondary criteria so it doesn't jump from cluster to cluster when they're equally large

* added secondary criteria so it doesn't jump from cluster to cluster when they're equally large

* updated cluster example
  • Loading branch information
MFizz authored and elicwhite committed Jul 31, 2016
1 parent d42e324 commit 2169675
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 11 deletions.
54 changes: 51 additions & 3 deletions configs/config.json.cluster.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
"tasks": [
{
"auth_service": "google",
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD",
"location": "SOME_LOCATION",
"gmapkey": "GOOGLE_MAPS_API_KEY",
"tasks": [
{
"type": "HandleSoftBan"
},
Expand All @@ -18,7 +24,7 @@
"type": "EvolveAll",
"config": {
"evolve_speed": 20,
"use_lucky_egg": true
"use_lucky_egg": false
}
},
{
Expand Down Expand Up @@ -68,4 +74,46 @@
"evolve_cp_min": 300,
"evolve_captured": "NONE",
"catch_randomize_reticle_factor": 1.0,
"catch_randomize_spin_factor": 1.0,
"catch_randomize_spin_factor": 1.0,
"catch": {
"any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"},
"// Example of always catching Rattata:": {},
"// Rattata": { "always_catch" : true }
},
"release": {
"any": {"release_below_cp": 0, "release_below_iv": 0, "logic": "or"},
"// Example of always releasing Rattata:": {},
"// Rattata": {"always_release": true},
"// Example of keeping 3 stronger (based on CP) Pidgey:": {},
"// Pidgey": {"keep_best_cp": 3},
"// Example of keeping 2 stronger (based on IV) Zubat:": {},
"// Zubat": {"keep_best_iv": 2},
"// Also, it is working with any": {},
"// any": {"keep_best_iv": 3},
"// Example of keeping the 2 strongest (based on CP) and 3 best (based on IV) Zubat:": {},
"// Zubat": {"keep_best_cp": 2, "keep_best_iv": 3}
},
"vips" : {
"Any pokemon put here directly force to use Berry & Best Ball to capture, to secure the capture rate!": {},
"any": {"catch_above_cp": 1200, "catch_above_iv": 0.9, "logic": "or" },
"Lapras": {},
"Moltres": {},
"Zapdos": {},
"Articuno": {},

"// S-Tier pokemons (if pokemon can be evolved into tier, list the representative)": {},
"Mewtwo": {},
"Dragonite": {},
"Snorlax": {},
"// Mew evolves to Mewtwo": {},
"Mew": {},
"Arcanine": {},
"Vaporeon": {},
"Gyarados": {},
"Exeggutor": {},
"Muk": {},
"Weezing": {},
"Flareon": {}

}
}
10 changes: 5 additions & 5 deletions pokemongo_bot/cell_workers/follow_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ def work(self):
log_lured_str = ''
if self.lured:
log_lured_str = 'lured '
lured_forts = filter(lambda x: True if x.get('lure_info', None) != None else False, forts)
lured_forts = [x for x in forts if 'lure_info' in x]
if len(lured_forts) > 0:
forts = lured_forts
self.dest = find_biggest_cluster(self.radius, lured_forts, 'lure_info')
else:
log_lure_avail_str = 'No lured pokestops in vicinity. Search for normal ones instead. '


self.dest = find_biggest_cluster(self.radius, forts)
self.dest = find_biggest_cluster(self.radius, forts)
else:
self.dest = find_biggest_cluster(self.radius, forts)

if self.dest is not None:

Expand Down
9 changes: 6 additions & 3 deletions pokemongo_bot/cell_workers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,20 @@ def rad2deg(rad):
return rad * 180.0 / pi


def find_biggest_cluster(radius, points):
def find_biggest_cluster(radius, points, order=None):
graph = nx.Graph()
for point in points:
f = point['latitude'], point['longitude']
if order is 'lure_info':
f = point['latitude'], point['longitude'], point['lure_info']['lure_expires_timestamp_ms']
else:
f = point['latitude'], point['longitude'], 0
graph.add_node(f)
for node in graph.nodes():
if node != f and distance(f[0], f[1], node[0], node[1]) <= radius*2:
graph.add_edge(f, node)
cliques = list(find_cliques(graph))
if len(cliques) > 0:
max_clique = max(list(find_cliques(graph)), key=len)
max_clique = max(list(find_cliques(graph)), key=lambda l: (len(l), sum(x[2] for x in l)))
merc_clique = [coord2merc(x[0], x[1]) for x in max_clique]
clique_x, clique_y = zip(*merc_clique)
best_point = np.mean(clique_x), np.mean(clique_y)
Expand Down

0 comments on commit 2169675

Please sign in to comment.