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/bad.py | |
parent | 0c034e6fbae0833f8524caf223deab450e9bb1b4 (diff) |
Updating too much. Renewed bots and tui.
Diffstat (limited to 'bots/bad.py')
-rw-r--r-- | bots/bad.py | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/bots/bad.py b/bots/bad.py deleted file mode 100644 index 5197dc9..0000000 --- a/bots/bad.py +++ /dev/null @@ -1,73 +0,0 @@ -""" bots/bad.py - botti joka ehkä osaa merkata jonkun asian """ -from random import sample -from tui import Action -from .bot import Bot - -class BadBot(Bot): - """ IdiotBot - merkistsee kaikki turvallisiksi avata """ - # pylint: disable = too-few-public-methods - def missing_bombs(self, matrix, x, y): - """ test how many boms are not found at the coordinate """ - dx = len(matrix) - dy = len(matrix[0]) - bcount = 0 - for nx, ny in self.neighbours(dx, dy, x, y): - if matrix[nx][ny] in (9,11): - bcount+=1 - return matrix[x][y]-bcount - - def get_tiles_at_border(self, matrix): - """ get interesting tiles on the border of cleared and masked area """ - tiles = [] - w = len(matrix) - h = len(matrix[0]) - for y in range(h): - for x in range(w): - if matrix[x][y] < 12: - open_tiles=1 - masked_tiles=0 - else: - open_tiles=0 - masked_tiles=1 - for nx, ny in self.neighbours(w, h, x, y): - if matrix[nx][ny] < 12: - open_tiles+=1 - else: - masked_tiles+=1 - if open_tiles and masked_tiles: - tiles.append( (x,y) ) - return tiles - - def get_unopened_tiles(self, matrix): - """ get interesting tiles on the border of cleared and masked area """ - tiles = [] - w = len(matrix) - h = len(matrix[0]) - for y in range(h): - for x in range(w): - if matrix[x][y] == 12: - tiles.append( (x,y) ) - return tiles - - def hint(self, matrix, cursor_x, cursor_y): - """ merkitsee jonkin ruudun """ - super().hint(matrix, cursor_x, cursor_y) - w = len(matrix) - h = len(matrix[0]) - # pylint: disable = consider-using-enumerate - for x, y in self.get_tiles_at_border(matrix): - ncoords=self.neighbours(w,h,x,y) - ntiles=self.coordinates_to_tiles(matrix,ncoords) - unopened=ntiles.count(12) - bombs=ntiles.count(10) - if unopened: - if matrix[x][y]<9 and matrix[x][y]==bombs: - safe = ncoords[ntiles.index(12)] - return(Action.SAFE, safe[0], safe[1]) - if matrix[x][y]-bombs==unopened: - bomb = ncoords[ntiles.index(12)] - return(Action.BOMB, bomb[0], bomb[1]) - if self.uncertain: - x, y = sample(self.get_unopened_tiles(matrix),1)[0] - return (Action.OPEN, x, y) - return (Action.NOOP, cursor_x, cursor_y) |