Boids: Add a class, rename variables, merge for loop, replace numbers with variables#7
Boids: Add a class, rename variables, merge for loop, replace numbers with variables#7myx2021 wants to merge 2 commits intoUCL-MPHY0021-21-22:mainfrom
Conversation
ageorgou
left a comment
There was a problem hiding this comment.
Good start, and creating a class can open more possibilities! You could have also created a class for each individual boid, rather than for the whole flock (as in, for example, #8).
You could shorten your attribute names a bit by removing the boid_ prefix, since they all belong to the object anyway.
The constructor of the class takes quite a few arguments. This is not a problem necessarily, but functions with lots of arguments can be confusing when you call them, which tends to lead to errors (not to mention long lines). Can you think of any other way to write this that would require fewer arguments all at once?
| boid_x_velocities=[random.uniform(0,10.0) for x in range(50)] | ||
| boid_y_velocities=[random.uniform(-20.0,20.0) for x in range(50)] | ||
| boids=(boids_x,boids_y,boid_x_velocities,boid_y_velocities) | ||
| class boid: |
There was a problem hiding this comment.
Conventionally, class names start with a capital letter, e.g. Boid. Also, since this contains many of them, I would call it Boids to make that clear.
No description provided.