A hungry swarm indeed.
Change Log:
v0.1 – The initial swarm.
v0.2 – Replaced custom random method with (min..max).rand
- Mouse clicks add food. Careful not to add too much.
Magnus Adamsson v0.3 – Seems Shoes 0.r646 can no longer draw a zero radius circle
Wally Glutton v0.4 – No longer using a $app global to access Shoes methods within the Food and Boid classes.
- Moved class definitions above Shoes.app block as this was causing a problem for OSX builds.
- Decreased the Stay Visible Damper by 50.
- Fixed some spelling errors.
- Assigned explicit app title, height & width.
Wally Glutton v0.5 – In Shoes Raisins an oval :radius now acutally defines its radius, and not the diameter like in early versions of Shoes.
- Changed all references to RADIUS to DIAMETER and draw oval using :width.
Speak now or forever hold your peace:
rmulliga@rtmlap:~/rb/shoes$ diff hungry_boids_v0.1.rb hungry_boids_v0.2.rb 28a29,31 > click do |_,x,y| > foodstuff.push Food.new(x,y) > end 58,59c61,62 < def initialize < spawn
> def initialize(x=(rand$app.width),y=(rand$app.height)) > spawn(x,y) 61c64 < def spawn
> def spawn(x=(rand$app.width),y=(rand$app.height)) 63c66 < @position = VectorK.new rand * $app.width, rand * $app.height
@position = VectorK.new x,y
actually i see one bug in os x: the shapes sometimes flicker in and out, showing the white background instead. if i add more food, it gets worse. i can only really observe this on the food. the boids themselves move too fast for me to tell if this happens.
I noticed this food flashing under Ubuntu Linux too.
I really like this. Used to play around with boids like agent sims for years in qbasic wayyyyy back. I’m thinking I might have to have a play with your code. Thanks :)
it doesnt work any more with the new build of shoes :(
oh and i’m using osx..
Seems Shoes 0.r646 can’t draw a zero radius circle. I took the liberty of fixing the code.
Fantastic!
v0.5 works really cool on my Windows XP laptop with Shoes 2.
Great work, thanks.
very good work!!!

cute! works fine in os x. i would also like to see how an experienced rubyist would refactor this.