Skip to content

Instantly share code, notes, and snippets.

@rvishwajith
Created January 13, 2021 05:56
Show Gist options
  • Save rvishwajith/f4d77cc2543b5cd593be73314264c423 to your computer and use it in GitHub Desktop.
Save rvishwajith/f4d77cc2543b5cd593be73314264c423 to your computer and use it in GitHub Desktop.
Boids[] // this is a global variable accesible in other methods
Update()
FOR b in Boids
vector1 = rule1(b) // Boids flock to the center of mass
vector2 = rule2(b) // Boids avoid other boids
vector3 = rule3(b) // Boids try to match the speed of other boids
// additional rules can be added directly after
vector4 = rule4(b)
vectorX = ruleX(b)
finalVector = vector1 + vector2 + vector3 ... + vectorX
b.velocity += finalVector // Adjust direction and speed
b.position += b.velocity // Update the position to the new position
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment