summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/miinaharava/bots/bot.py4
-rw-r--r--src/miinaharava/tests/test_bot.py2
-rw-r--r--src/miinaharava/tui/tui.py11
3 files changed, 10 insertions, 7 deletions
diff --git a/src/miinaharava/bots/bot.py b/src/miinaharava/bots/bot.py
index b00f9a6..15dbb8e 100644
--- a/src/miinaharava/bots/bot.py
+++ b/src/miinaharava/bots/bot.py
@@ -40,7 +40,7 @@ class Bot():
tiles.remove(tile)
return self.safe_tiles or self.mine_tiles
- def hint(self, matrix, cursor_x, cursor_y):
+ def hint(self, matrix):
""" Kysyy tekoälyltä vihjettä. Joko palauttaa vihjeen, arvauksen tai
vain nykyisen paikan ilman toimintoa. """
self.matrix = matrix
@@ -50,7 +50,7 @@ class Bot():
for step in (self.saved_hints, self.search, ok_to_guess ):
if step():
return self.get_hint_from_list()
- return Action.NOOP, cursor_x, cursor_y
+ return Action.NOOP, 0, 0
def get_dimensions(self):
""" Apufunktio joka palauttaa pelilaudan mitat. """
diff --git a/src/miinaharava/tests/test_bot.py b/src/miinaharava/tests/test_bot.py
index 4dab148..435151f 100644
--- a/src/miinaharava/tests/test_bot.py
+++ b/src/miinaharava/tests/test_bot.py
@@ -26,7 +26,7 @@ class TestBotClass(unittest.TestCase):
tested = set()
while True:
- action, x, y = bot.hint(brd.get_view(), 0, 0)
+ action, x, y = bot.hint(brd.get_view())
if (x,y) in tested:
break
tested.add((x,y))
diff --git a/src/miinaharava/tui/tui.py b/src/miinaharava/tui/tui.py
index d7f7fb3..378b222 100644
--- a/src/miinaharava/tui/tui.py
+++ b/src/miinaharava/tui/tui.py
@@ -55,12 +55,12 @@ class Tui():
# automaattipeli avaa botin vinkit heti
if self.autoplay:
- action, x, y = self.bot.hint(matrix, x, y)
+ action, bx, by = self.bot.hint(matrix)
if action != Action.NOOP:
if self.delay:
- self.draw.matrix(matrix, x, y)
+ self.draw.matrix(matrix, bx, by)
time.sleep(self.delay/100)
- return Action.OPEN if action==Action.SAFE else action, x, y
+ return Action.OPEN if action==Action.SAFE else action, bx, by
# ilman näppiskäsittelijää voidaan lopettaa
@@ -79,7 +79,10 @@ class Tui():
return (action, x, y)
case Action.HINT:
if self.bot is not None:
- return self.bot.hint(matrix, x, y)
+ action, bx, by = self.bot.hint(matrix)
+ if action != Action.NOOP:
+ return (action, bx, by)
+ return (Action.NOOP, x, y)
def game_over(self, matrix, x, y):
""" tehtävät kun kuolee """