Conversation
There was a problem hiding this comment.
Travail impressionant sur les quelques jours de la conférence. Les remarques que je considère les plus importantes ont trait à la réutilisation du code.
Suivant les conventions Python, le nom du dossier Simulateur devrait être en minuscule.
Si ca t'intéresse, exécuter la commande flake8 main.py peut permettre d'augmenter la compatibilité du code avec les attentes des standards Python. Vous aurez bcp d'erreur (les specs sont impossibles à retenir entièrement de toutes façons), et ce n'est pas un impératif pour moi.
| #Load images | ||
| for file in next(os.walk('img'))[2]: | ||
| name = file[:-4] | ||
| img = Image.open("img\{}.png".format(name)).convert('RGBA') |
There was a problem hiding this comment.
- Utilise de préférence les formats de chemins Linux qui seront compatibles pour tous les systèmes
- La notation f-string est désormais préférable à
.format()car plus lisible.
img = Image.open(f'img/{name}.png').convert('RGBA')
| #Load ground images | ||
| for name in GROUND_IMAGES.keys(): | ||
| filename = GROUND_IMAGES[name] | ||
| img = Image.open("img/terrain/{}.png".format(filename)).convert('RGBA') |
| def nop(self): | ||
| pass |
There was a problem hiding this comment.
Je ne crois que la méthode nop() soit appelée dans le code. Ligne 202, l'action est retirée de la liste, la fonction correspondante ne peut donc pas exécutée.
| #sleep 200ms | ||
| master.after(200) | ||
|
|
||
| master.mainloop() No newline at end of file |
There was a problem hiding this comment.
Peux-tu ajouter un retour à la ligne ?
| # Simulateur | ||
|
|
||
| Simulation du déplacement des agents dans un monde défini par deux fichiers de configuration | ||
|
|
There was a problem hiding this comment.
Il serait intéressant de documenter que l'exécution du script requière l'installation de la bibliothèque Pillow (via un environnement virtuel ou non).
| action = self.simulator.check_action(self, 'drop', self.orientation) | ||
| if action == 'drop': | ||
| self.drop() |
There was a problem hiding this comment.
Pour permettre la réutilisation du simulateur, déplacer check_action() dans Robot.drop() et retourner false (ou lever une exception) si l'action est impossible.
| action = self.simulator.check_action(self, 'take', self.orientation) | ||
| if action == 'take': | ||
| self.take() |
There was a problem hiding this comment.
Idem. Cf. commentaire pou Robot.drop().
| def left(self): | ||
| self.turnLeft() | ||
|
|
||
| def right(self): | ||
| self.turnRight() |
There was a problem hiding this comment.
Serait-il envisageable de supprimer ces fonctions dont les instructions sont redondantes avec la fonction elle-même ?
| orientation = self.simulator.compute_newOrientation(orientation,-1) | ||
| elif action == 'right': | ||
| orientation = self.simulator.compute_newOrientation(orientation,1) | ||
| action_name = self.simulator.check_action(self,action,orientation) |
There was a problem hiding this comment.
Idem. Cf. commentaire pou Robot.drop().
| if action == 'left': | ||
| orientation = self.simulator.compute_newOrientation(orientation,-1) | ||
| elif action == 'right': | ||
| orientation = self.simulator.compute_newOrientation(orientation,1) |
There was a problem hiding this comment.
Est-il possible de réduire le nombre d'appels à compute_newOrientation pour simplifier la lecture du code ? (Par ex. un par acquisition de direction, voir un avant un deplacement, e.g.move())
Readme à completer