summaryrefslogtreecommitdiff
path: root/bots/bot.py
diff options
context:
space:
mode:
authorAineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi>2024-01-17 10:51:08 +0200
committerAineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi>2024-01-17 10:51:08 +0200
commit823877510422f6ce2952de5cc40edd0d62d813e4 (patch)
tree1e68d682a3f59dea0a87aa83c9bb1c73aeb2badb /bots/bot.py
parent899d0997a6badae6535e9f69e0f6d70f3a272578 (diff)
Adding BadBot for hinting.
Diffstat (limited to 'bots/bot.py')
-rw-r--r--bots/bot.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/bots/bot.py b/bots/bot.py
index 1b7fedd..8466c51 100644
--- a/bots/bot.py
+++ b/bots/bot.py
@@ -3,12 +3,29 @@ from tui.static import Action
class Bot():
""" Bot - perusluokka perittäväksi """
- # pylint: disable = too-few-public-methods
def __init__(self):
self.hints = 0
- def hint(self, matrix, x, y):
+ def neighbours(self,dx,dy,x,y):
+ """ palauttaa listana viereiset koordinaatit """
+ offsets = (
+ (-1, -1), ( 0, -1), ( 1, -1),
+ (-1, 0), ( 1, 0),
+ (-1, 1), ( 0, 1), ( 1, 1),
+ )
+ coords=[]
+ for ox, oy in offsets:
+ if ox+x in range(dx):
+ if oy+y in range(dy):
+ coords.append((ox+x, oy+y))
+ return coords
+
+ def coordinates_to_tiles(self, matrix, coords):
+ """ lukee koordinaateissa olevien ruutujen arvot listaksi """
+ return [matrix[x][y] for x,y in coords]
+
+ def hint(self, matrix, cursor_x, cursor_y):
""" antaa vinkin. tässä tapauksessa ei mitään """
# pylint: disable = unused-argument
self.hints += 1
- return Action.NOOP, x, y
+ return Action.NOOP, cursor_x, cursor_y