FIX boucle de traitement du mouvt|TP_3.9
This commit is contained in:
parent
71d6e7cb90
commit
f04d34c4d2
11
roboc/map.py
11
roboc/map.py
|
@ -146,15 +146,13 @@ class Map:
|
||||||
direction = move[0]
|
direction = move[0]
|
||||||
goal = int(move[1:])
|
goal = int(move[1:])
|
||||||
steps = 0
|
steps = 0
|
||||||
move_status = 4
|
|
||||||
|
|
||||||
# direction non conforme
|
# direction non conforme
|
||||||
if direction not in DIRECTIONS:
|
if direction not in DIRECTIONS:
|
||||||
move_status = 0
|
move_status = 0
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# pour chaque pas on recupere la position suivante
|
# pour chaque pas on recupere la position suivante
|
||||||
while steps < goal or move_status not in range(MOVE_STATUS.index('ok')):
|
while steps < goal:
|
||||||
steps += 1
|
steps += 1
|
||||||
if direction == DIRECTIONS[0]: # nord
|
if direction == DIRECTIONS[0]: # nord
|
||||||
next_position = self._robo_position - self._column_nb
|
next_position = self._robo_position - self._column_nb
|
||||||
|
@ -172,21 +170,26 @@ class Map:
|
||||||
raise NotImplementedError(ERR_)
|
raise NotImplementedError(ERR_)
|
||||||
|
|
||||||
# verifie quelle est la case du prochain pas
|
# verifie quelle est la case du prochain pas
|
||||||
# import pdb; pdb.set_trace()
|
# import pdb; pdb.set_trace()
|
||||||
next_char = self._data_text[next_position]
|
next_char = self._data_text[next_position]
|
||||||
if next_char == MAZE_ELEMENTS['wall']:
|
if next_char == MAZE_ELEMENTS['wall']:
|
||||||
move_status = 1
|
move_status = 1
|
||||||
|
steps = goal
|
||||||
|
|
||||||
elif next_char == MAZE_ELEMENTS['exit']:
|
elif next_char == MAZE_ELEMENTS['exit']:
|
||||||
self._robo_position = next_position
|
self._robo_position = next_position
|
||||||
move_status = 2
|
move_status = 2
|
||||||
|
steps = goal
|
||||||
|
|
||||||
|
|
||||||
elif next_char == MAZE_ELEMENTS['door']:
|
elif next_char == MAZE_ELEMENTS['door']:
|
||||||
self._robo_position = next_position
|
self._robo_position = next_position
|
||||||
move_status = 3
|
move_status = 3
|
||||||
|
steps = goal
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self._robo_position = next_position
|
self._robo_position = next_position
|
||||||
|
move_status = 4
|
||||||
|
|
||||||
# supprime le robo de son emplacement precedent
|
# supprime le robo de son emplacement precedent
|
||||||
self._data_text = self._data_text.replace(
|
self._data_text = self._data_text.replace(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user