Questions tagged [boids]

Boids is a computer model of coordinated animal motion such as bird flocks and fish schools.

The algorithm itself is simple. The flock is modeled as a group of individuals, and the behavior of each individual "boid" is governed by three rules:

  1. Separation: steer to avoid crowding local flockmates
  2. Alignment: steer towards the average heading of local flockmates
  3. Cohesion: steer to move toward the average position of local flockmates

These rules are applied independently to each boid, such that there is no assigned leader.

Some useful resources for implementation:

  • Craig Reynold's boids page is the canonical reference, and contains links to many implementations and articles discussing uses of the algorithm.
  • Boids pseudocode gives an overview of the basic algorithm and various tweaks to model effects like wind, targeting and scattering.
54 questions
15
votes
2 answers

What are some good resources on flocking and swarm algorithms?

Awhile ago I read the novel Prey. Even though it is definitely in the realm of fun science fiction, it piqued my interest in swarm/flock AI. I've been seeing some examples of these demos recently on reddit such as the Nvidia plane flocking video…
mmcdole
  • 91,488
  • 60
  • 186
  • 222
9
votes
3 answers

2D Spatial Data Structure suitable for Flocking Boids in Java

I'm working on a flocking boids simulation just for fun, and I want to optimise it a bit. The area that needs work is finding boids near a given boid. I figure that to do that some kind of spatial data-structure suited to the task would be my best…
Iskar Jarak
  • 5,136
  • 4
  • 38
  • 60
8
votes
4 answers

Flocking boids behaviour problem

Yesterday I came across Craig Reynolds' Boids, and subsequently figured that I'd give implementing a simple 2D version in Java a go. I've put together a fairly basic setup based closely on Conrad Parker's notes. However, I'm getting some rather…
Iskar Jarak
  • 5,136
  • 4
  • 38
  • 60
5
votes
1 answer

Defining a vision cone in unity

I am attempting to implement a boids flocking model in unity. I have managed to implement steering behaviours (separate, align, cohere) but I am currently using a fixed radius from the agent to define its neighbourhood (essentially a bubble around…
Chris Headleand
  • 6,003
  • 16
  • 51
  • 69
4
votes
2 answers

XNA field of view in 2D

I'm working on a 2D game in XNA based around flocking. I've implemented Craig Reynold's flocking technique and now I want to dynamically assign a leader to the group to guide it towards a target. To do this, I want to find a game agent that does…
Jason
  • 1,065
  • 1
  • 16
  • 26
4
votes
2 answers

Scala swing panel disappears when trying to change contents (only when running a Thread)

So I'm writing a boid simulation program as a project for school. My program supports multiple different groups of these boids that don't flock with other groups, they all have different settings which I do by adding a BoxPanel to the main GUI of…
RusinaRange
  • 341
  • 1
  • 4
  • 18
3
votes
2 answers

Understanding velocity and implementing Boids algorithm?

So I'm working on porting Boids to Brightscript, based on the pseudocode here. I'm trying to understand the data structures involved, for example is Velocity a single value, or is it a 3D value? (i.e. velocity={x,y,z}) It seems as if the pseudocode…
alphablender
  • 2,168
  • 5
  • 27
  • 42
2
votes
1 answer

Boids Algorithm. pygame.Rect shape not displayed properly in the window

I am trying to rewrite some code to take advantage of pygame sprites in Boids Algorithm implementation. Currently the goal is to create multiple sprites on screen (number determined by "flock" variable) and get them moving in random directions,…
2
votes
0 answers

How to best create an Octree/BVH in GPU memory without pointers?

I've been working on a GPU-based boid simulation recently. I've spent most of my time trying to get the underlying sorting system working, in an attempt to avoid having each boid check every other boid—I'm ideally looking for this algorithm to end…
2
votes
2 answers

Defining velocity in a boid simulation

New to programming, for one of my first projects I am following a code for a boid simulation and I am unsure what the sin and cos functions are doing in this part of the code. N = numer of boids angles = 2*math.pi*np.random.rand(N) vel =…
user6204921
2
votes
2 answers

Boids colliding with each other

I was looking at some pseudocode for boids and wrote it in C++. However, I am finding that boids will occasionally collide with each other. I thought that I had programmed it correctly, given how simple the psuedocode is. yet, when i display the…
calccrypto
  • 8,583
  • 21
  • 68
  • 99
2
votes
3 answers

Python : local variable referenced before assignment error

I keep having the error UnboundLocalError: local variable 'new_speedDx' referenced before assignment while trying to run the following function: def new_speedD(boid1): bposx = boid1[0] if bposx < WALL: new_speedDx = WALL_FORCE …
user2089012
  • 101
  • 1
  • 8
1
vote
1 answer

Problem with making Circle properly appear on screen in Pygame

I think my understanding of Pygame is a little bit weak. I would appreciate any help in general about the intricacies of the code (since this was given by the teacher) or simply how I can at least make the obstacle visible. def draw(screen,…
jbg05
  • 51
  • 7
1
vote
1 answer

I cant import scipy.spacial.distance properly

from scipy.spacial.distance import squareform, pdist, cdist it says 'could not be resolved'. I am using python for a boids program.
Jeremi
  • 153
  • 1
  • 1
  • 7
1
vote
0 answers

Python/pygame flocking boids can't create borders

I'm new to python/pygame and I'm trying to make a boids simulation but can't seem to get to create the borders so that the boids don't go outside of the window. Here's what I've done so far. #importing the needed modules and libraries import…
1
2 3 4