Skip to content

Sheraff/boids

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Implementation of Boids

Screen Shot 2022-06-18 at 19 40 31

Boids is an example of emergent behavior; that is, the complexity of Boids arises from the interaction of individual agents (the boids, in this case) adhering to a set of simple rules. The rules applied in the simplest Boids world are as follows:

  • separation: steer to avoid crowding local flockmates
  • alignment: steer towards the average heading of local flockmates
  • cohesion: steer to move towards the average position (center of mass) of local flockmates

JS version

Uses basic web worker for computation, w/ OffscreenCanvas to draw on the canvas off of the main thread.

Requires no transpilation and can be served directly. Entry point (to be set in index.html) is /js/script.js

Rust version

Uses Web Assembly for computation, written in Rust. Also uses a Broadcast Channel for basic interop between JS worker and WASM thread. And imports the web-sys crate to call canvas methods efficiently.

Needs to be compiled

wasm-pack build --target web

Entry point (to be set in index.html) is /js/wasm.js

Releases

No releases published

Packages

No packages published