Show HN: Genetic Boids Web Simulation
31–40 of 46 posts
Re: Show HN: Genetic Boids Web Simulation
#32The original Boids is from Craig Reynolds, here: https://www.red3d.com/cwr/boids/ It was a java applet (sigh) and unfortunately I have not been able to find a working version. That version based on his three "steering" mechanisms had very realistic movement. Other versions, including this one, which are good do not have that same kind of quality. They look like simulations whereas the Reynolds version, for whatever r…
function update_positions(boids, dt)
local max_speed = 0.5 -- per frame
local max_accel = 20 -- per second
local max_turn_angle = math.pi/6 -- per second
for _,boid in ipairs(boids) do
boid.pos = vadd(boid.pos, boid.velocity)
end
for i,boid in ipairs(boids) do
local accel = {x=0, y=0}
accel = vadd(accel, vscale(avoid_others(boid, boids), 20*dt))
accel = vadd(accel, vscale(seek_others(boid, boids), 10*dt))
accel = vadd(accel, vscale(align_with_others(boid, boids), 10*dt))
accel = vadd(accel, vscale(remain_within_viewport(boid), 40*dt))
local curr_heading = vnorm(boid.velocity) -- could be nil
accel = vclamp2(accel, max_accel*dt, curr_heading, max_turn_angle*dt)
boid.velocity = vadd(boid.velocity, accel)
boid.velocity = vclamp(boid.velocity, max_speed)
end
end
Here, avoid_others, seek_others and align_with_others are the 3 rules you can find on Wikipedia (https://en.wikipedia.org/wiki/Boids): separation, cohesion, alignment. Each of the functions returns a unit vector, which I then weight using vscale.The key is the last 4 lines. My intuition here is that the way muscle mechanics work, there are limits on both how fast you can accelerate and also how much you can turn per unit time. That's what vclamp2 is doing. It separately clamps both magnitude and angle of acceleration.
My rough sense after this experience was:
* Boids is not a simple program the way the Game of Life or Mandelbrot set is. The original paper had tons of nuance that we gloss over in the internet era.
* Every implementation I've found is either extremely sensitive to weights or does weird stuff in the steering. Stuff like subtracting velocity from acceleration when the units are different, and so on. There may be a numeric basis for them, but it's never been explained to my satisfaction. Whereas my vclamp2 idea roughly hangs together for me. And the evidence it's on the right track is that a wide variety of weights (the 10s, 20s and 40s above) result in behavior that looks right to me.
Re: Show HN: Genetic Boids Web Simulation
#33The original Boids is from Craig Reynolds, here: https://www.red3d.com/cwr/boids/ It was a java applet (sigh) and unfortunately I have not been able to find a working version. That version based on his three "steering" mechanisms had very realistic movement. Other versions, including this one, which are good do not have that same kind of quality. They look like simulations whereas the Reynolds version, for whatever r…
I don't know if this will address your question, but I had a long-standing question about boids that might overlap, which I coincidentally only resolved to my satisfaction a month ago. Here's the Lua code I ended up with: function update_positions(boids, dt) local max_speed = 0.5 -- per frame local max_accel = 20 -- per second local max_turn_angle = math.pi/6 -- per second for _,boid in ipairs(boids) do boid.pos = va…
It seems like perhaps the visual inputs are another interesting area. What do I (as a boid) do when I see one boid in front of me go right, one go left, for example. But thanks!!
Re: Show HN: Genetic Boids Web Simulation
#34Earlier quoted context omitted.
I don't know if this will address your question, but I had a long-standing question about boids that might overlap, which I coincidentally only resolved to my satisfaction a month ago. Here's the Lua code I ended up with: function update_positions(boids, dt) local max_speed = 0.5 -- per frame local max_accel = 20 -- per second local max_turn_angle = math.pi/6 -- per second for _,boid in ipairs(boids) do boid.pos = va…
Wow! Thanks. The thought about "Boids is not a simple ..." is new to me and very good. The other vector in this is the evolution/genetic algorithm idea. It raises the question of what are the benefits of flocking? And could you plug those into a genetic algorithm to test survival. It seems like perhaps the visual inputs are another interesting area. What do I (as a boid) do when I see one boid in front of me go right…
Re: Show HN: Genetic Boids Web Simulation
#35how are genetic (algorithms) used?
Re: Show HN: Genetic Boids Web Simulation
#36The original Boids is from Craig Reynolds, here: https://www.red3d.com/cwr/boids/ It was a java applet (sigh) and unfortunately I have not been able to find a working version. That version based on his three "steering" mechanisms had very realistic movement. Other versions, including this one, which are good do not have that same kind of quality. They look like simulations whereas the Reynolds version, for whatever r…
Just a clarifying note, Craig Reynolds is the original researcher for Boids, and he did have a Java applet implementation in the above page. But the original Boids simulation was from 1986, almost a decade prior to Java applets. The original paper, published in 1987, is "Flocks, herds and schools: A distributed behavioral model"[1]. The implementation was done in Lisp on a Symbolics 3600 Lisp Machine. Edit: One quite…
Re: Show HN: Genetic Boids Web Simulation
#37Re: Show HN: Genetic Boids Web Simulation
#38The original Boids is from Craig Reynolds, here: https://www.red3d.com/cwr/boids/ It was a java applet (sigh) and unfortunately I have not been able to find a working version. That version based on his three "steering" mechanisms had very realistic movement. Other versions, including this one, which are good do not have that same kind of quality. They look like simulations whereas the Reynolds version, for whatever r…
https://www.youtube.com/watch?v=86iQiV3-3IA
Boids Demo Reel 1987 — Part B:
https://www.youtube.com/watch?v=xBniZYiyrb4
>Early motion tests of the boids model of flocking and related collective motion (herds, schools, crowds). Recorded on a Symbolics Lisp Machine between 1986 and 1987.
Stanley and Stella in “BREAKING THE ICE” - Original Symbolics Tapes Restored & Remastered, 1080p:
https://www.youtube.com/watch?v=aYEp26g14Wk
Craig Reynolds #SCCS2015:
https://www.youtube.com/watch?v=rqP_c5zm89Q
>Pioneer Craig Reynolds shares his groundbreaking work in artificial life and computer animation. Reynolds describes his lifelong fascination with simulating natural complexity computationally. By modeling flocking birds from the bottom up, based on simple rules for how individual birds move, Reynolds made the astonishing flock emerge. This agent-based approach allowed new insights into collective behavior impossible to gather from nature alone. Reynolds reflects on the significance of his iconic 1987 "Boids" model for animating birds in films like Batman Returns. But its influence extends further - to complexity science and understanding real-world systems like traffic flow and crowd dynamics. According to Reynolds, the beauty of simple models is their emergent properties. By distilling phenomena to basic rules, computer simulation uncovers new truths about the world. Join this fascinating conversation with a legend of artificial life and computer graphics.
Blender Tutorial - Full Guide to Boid Particles:
https://www.youtube.com/watch?v=J3TUPYVsxow
"Concierge" clip from 1968 Mel Brooks' "The Producers":
https://www.youtube.com/watch?v=aL6mTMShVyk
>Doity, disgusting, filthy, lice ridden boids.
Re: Show HN: Genetic Boids Web Simulation
#39I really like it, though I'm finding it dies consistently after about 30s (Vivaldi on an intel iMac with a decent GPU).
dies in the sense machine gets hung or all boids vanish? EDIT: also pushed some fixes in params (allow offsprings at larger distance, etc), but basically if the boids don't end up closer, they won't reproduce and the population dies so play with that and lmk
Re: Show HN: Genetic Boids Web Simulation
#40Earlier quoted context omitted.
dies in the sense machine gets hung or all boids vanish? EDIT: also pushed some fixes in params (allow offsprings at larger distance, etc), but basically if the boids don't end up closer, they won't reproduce and the population dies so play with that and lmk
Noticed that all the boids lifetime seems to be the same, so you go from "a flock" to "nothing" very quickly if the lifetime been hit. What I've done before with "crowd simulations" like these, is add another params, something like "random lifetime interval" where if set to say 100, it'll set the actual lifetime to be randomly chosen between $LIFETIME - 100 and $LIFETIME + 100, so things die a bit less predictable. H…
for me its not vanishing suddenly, so not sure how to reproduce now