summaryrefslogtreecommitdiff
path: root/bots
diff options
context:
space:
mode:
Diffstat (limited to 'bots')
-rw-r--r--bots/bot.py11
-rw-r--r--bots/dssp.py16
2 files changed, 18 insertions, 9 deletions
diff --git a/bots/bot.py b/bots/bot.py
index 49bd962..f32b466 100644
--- a/bots/bot.py
+++ b/bots/bot.py
@@ -123,6 +123,17 @@ class Bot():
tiles.add((x,y))
return tiles
+ def get_border_tiles(self):
+ """ palauttaa palauttaa numerolaatat joiden vieressä avaamaton """
+ tiles = set()
+ for x in range(self.w):
+ for y in range(self.h):
+ if self.number_tile((x,y)):
+ n = self.get_neighbours((x,y))
+ if self.count_unknowns(n):
+ tiles.add((x,y))
+ return tiles
+
def get_unknown_tiles(self):
""" palauttaa kaikki tuntemattomat laatat """
tiles = set()
diff --git a/bots/dssp.py b/bots/dssp.py
index 33578a0..78dec8e 100644
--- a/bots/dssp.py
+++ b/bots/dssp.py
@@ -54,22 +54,20 @@ class DSSPBot(SimpleBot):
return self.saved_hints()
def lucky_guess(self):
- heatmap = dict.fromkeys(self.get_unknown_tiles(), 0)
- tiles = self.get_interesting_tiles()
+ heatmap = dict.fromkeys(self.get_unknown_tiles(), float(0))
+ tiles = self.get_border_tiles()
for tile in tiles:
n = self.get_neighbours(tile)
c = self.get_value(tile) - self.remove_bomb_tiles(n)
self.remove_number_tiles(n)
- for tile in n:
- heatmap[tile] = max( heatmap[tile], c/len(n) )
+ for ntile in n:
+ heatmap[ntile] += c/len(n)
- for tile, value in heatmap.items():
- if value>0:
- continue
+ for tile in heatmap:
if tile[0] in range(1,self.w-1):
- heatmap[tile]+=0.05
+ heatmap[tile]+=0.005
if tile[1] in range(1,self.h-1):
- heatmap[tile]+=0.05
+ heatmap[tile]+=0.005
best = min((x for _, x in heatmap.items()))
best_tiles = [x for x,y in heatmap.items() if y == best]