diff options
author | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-01-29 02:34:32 +0200 |
---|---|---|
committer | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-01-29 02:34:32 +0200 |
commit | e591d15abc4943a74c39f0fcab065213828a1514 (patch) | |
tree | bc22931abb08d8c213ba4eb81a85298d69e88890 /bots/simple.py | |
parent | 0c034e6fbae0833f8524caf223deab450e9bb1b4 (diff) |
Updating too much. Renewed bots and tui.
Diffstat (limited to 'bots/simple.py')
-rw-r--r-- | bots/simple.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/bots/simple.py b/bots/simple.py new file mode 100644 index 0000000..cb3d25c --- /dev/null +++ b/bots/simple.py @@ -0,0 +1,29 @@ +""" bots/simple.py - yksinkertainen botti joka etsii vain yhdeltä laatalta """ +from random import sample +from .bot import Bot + +class SimpleBot(Bot): + """ SimpleBot - perustyhmä botti """ + + def search(self): + """ simple_search - jos viereisten avaamattomien määrä tästmää """ + tiles = self.get_interesting_tiles() + for tile in tiles: + c = self.get_value(tile) + n = self.get_neighbours(tile) + self.remove_number_tiles(n) + c -= self.remove_bomb_tiles(n) + if c == 0: + for safe in n: + self.safe_tiles.add(safe) + if c == len(n): + for bomb in n: + self.bomb_tiles.add(bomb) + return self.saved_hints() + + def lucky_guess(self): + tiles = self.get_unknown_tiles() + if tiles: + self.safe_tiles.add(sample(sorted(tiles),1)[0]) + return True + return False |