image_recognition #5
@ -17,25 +17,21 @@ class Search:
|
|||||||
angles = {0: 'UP', 90: 'RIGHT', 270: 'LEFT', 180: 'DOWN'}
|
angles = {0: 'UP', 90: 'RIGHT', 270: 'LEFT', 180: 'DOWN'}
|
||||||
match(angles[angle]):
|
match(angles[angle]):
|
||||||
case 'UP':
|
case 'UP':
|
||||||
if y != 0:
|
possible = [['left', x, y, 270], ['right', x, y, 90]]
|
||||||
return [['move', x, y - self.cell_size, 0], ['left', x, y, 270], ['right', x, y, 90]]
|
if y != 0: possible.append(['move', x, y - self.cell_size, 0])
|
||||||
else:
|
return possible
|
||||||
return [['left', x, y, 270], ['right', x, y, 90]]
|
|
||||||
case 'RIGHT':
|
case 'RIGHT':
|
||||||
if x != self.cell_size*(self.cell_number-1):
|
possible = [['left', x, y, 0], ['right', x, y, 180]]
|
||||||
return [['move', x + self.cell_size, y, 90], ['left', x, y, 0], ['right', x, y, 180]]
|
if x != self.cell_size*(self.cell_number-1): possible.append(['move', x + self.cell_size, y, 90])
|
||||||
else:
|
return possible
|
||||||
return [['left', x, y, 0], ['right', x, y, 180]]
|
|
||||||
case 'DOWN':
|
case 'DOWN':
|
||||||
if y != self.cell_size*(self.cell_number-1):
|
possible = [['left', x, y, 90], ['right', x, y, 270]]
|
||||||
return [['move', x, y + self.cell_size, 180], ['left', x, y, 90], ['right', x, y, 270]]
|
if y != self.cell_size*(self.cell_number-1): possible.append(['move', x, y + self.cell_size, 180])
|
||||||
else:
|
return possible
|
||||||
return [['left', x, y, 90], ['right', x, y, 270]]
|
|
||||||
case 'LEFT':
|
case 'LEFT':
|
||||||
if x != 0:
|
possible = [['left', x, y, 180], ['right', x, y, 0]]
|
||||||
return [['move', x - self.cell_size, y, 270], ['left', x, y, 180], ['right', x, y, 0]]
|
if x != 0: possible.append(['move', x - self.cell_size, y, 270])
|
||||||
else:
|
return possible
|
||||||
return [['left', x, y, 180], ['right', x, y, 0]]
|
|
||||||
|
|
||||||
def graphsearch(self, istate, goaltest):
|
def graphsearch(self, istate, goaltest):
|
||||||
x = istate[0]
|
x = istate[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user