diff options
Diffstat (limited to 'bots/bot.py')
-rw-r--r-- | bots/bot.py | 23 |
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 |