From 6ecbbafbb0b8db5922a1ab9a2c7d9eb7ecf72cb4 Mon Sep 17 00:00:00 2001 From: micwuj Date: Sat, 22 Apr 2023 21:47:00 +0200 Subject: [PATCH] change successor & added map validation --- src/bfs.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/bfs.py b/src/bfs.py index 629f19c..fd02b29 100644 --- a/src/bfs.py +++ b/src/bfs.py @@ -29,7 +29,17 @@ class BFS: states = [(pos_x - block_size, pos_y, directions[270]), (pos_x, pos_y, directions[0]), (pos_x, pos_y, directions[180])] actions = ['F', 'L', 'R'] - return states, actions + for s, a in zip(states, actions): + if self.valid_state(s): + options.append((a, s)) + + return options + + def valid_state(self, state): + pos_x, pos_y, rotation = state + if pos_x < 0 or pos_x >= screen_width or pos_y < 0 or pos_y >= screen_width: + return False + return True def search(self): pass