Skip to content

Comments

adding simulator#3

Open
nassimmokhtari wants to merge 3 commits intocecilia-afia:masterfrom
nassimmokhtari:master
Open

adding simulator#3
nassimmokhtari wants to merge 3 commits intocecilia-afia:masterfrom
nassimmokhtari:master

Conversation

@nassimmokhtari
Copy link

Readme à completer

Copy link
Collaborator

@kodizh kodizh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem pour .format()

Comment on lines +173 to +174
def nop(self):
pass
Copy link
Collaborator

@kodizh kodizh Jul 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peux-tu ajouter un retour à la ligne ?

# Simulateur

Simulation du déplacement des agents dans un monde défini par deux fichiers de configuration

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment on lines +181 to +183
action = self.simulator.check_action(self, 'drop', self.orientation)
if action == 'drop':
self.drop()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +188 to +190
action = self.simulator.check_action(self, 'take', self.orientation)
if action == 'take':
self.take()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem. Cf. commentaire pou Robot.drop().

Comment on lines +167 to +171
def left(self):
self.turnLeft()

def right(self):
self.turnRight()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem. Cf. commentaire pou Robot.drop().

Comment on lines +198 to +201
if action == 'left':
orientation = self.simulator.compute_newOrientation(orientation,-1)
elif action == 'right':
orientation = self.simulator.compute_newOrientation(orientation,1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants