$30 off During Our Annual Pro Sale. View Details »

Flocking Simulation with Phoenix Channels

Flocking Simulation with Phoenix Channels

Christian Bäuerlein

April 19, 2018
Tweet

More Decks by Christian Bäuerlein

Other Decks in Programming

Transcript

  1. Flocking Simulation
    with Phoenix Channels

    View Slide

  2. Flocking Theory

    View Slide

  3. View Slide

  4. Use case: Cinematic effects

    View Slide

  5. Boid: One member of a flock

    View Slide

  6. * Location

    View Slide

  7. * Location
    * Perception Radius

    View Slide

  8. * Location
    * Perception Radius
    * Velocity
    * Heading

    View Slide

  9. You Need Three Behaviours

    View Slide

  10. 1. Cohesion

    View Slide

  11. 1. Cohesion

    View Slide

  12. 1. Cohesion

    View Slide

  13. 2. Alignment

    View Slide

  14. 2. Alignment

    View Slide

  15. 2. Alignment

    View Slide

  16. 3. Separation

    View Slide

  17. 3. Separation

    View Slide

  18. 3. Separation
    !
    !

    View Slide

  19. 3. Separation
    !
    !

    View Slide

  20. * Cohesion
    * Alignment
    * Separation
    = Next move

    View Slide

  21. Architecture

    View Slide

  22. Phoenix
    BoidsChannel
    Receives Updates
    Changes Settings
    GenServer
    WorldStateUpdater
    Calling itself 

    30 times per second
    Simulation
    Calculates new
    positions
    per boid based
    on world state
    Renderer
    Renders updated
    world state
    Socket Connection
    Receives Updates
    Changes Settings

    View Slide

  23. Demo Time!

    View Slide

  24. Read on!
    http://harry.me/blog/2011/02/17/neat-algorithms-flocking/
    http://www.red3d.com/cwr/boids/

    View Slide