You can read about swarms on wiki. They can be used to model clouds, flock of birds ... Flocking is pretty interesting http://www.red3d.com/cwr/steer/ , one can model even cars I guess. So I thought that I will try to implement it in Quake, it might be easy ...
I just love how the rules for behaviour are simple. It reminds me of fractal rules, like the one to make Mandelbrot set ...
I wonder if one can use this to make moster AI. It may be used to make brawling like in God Of War http://www.gamasutra.com/view/feature/3 ... awling.php . But its purpose is to model groups not single monsters ...
I am just musing. Maybe someone tried some interesting things with it. If so, how it was?
I want to test swarm-like behaviour in Quake some day ...
-
- Posts: 185
- Joined: Wed Apr 13, 2011 1:34 pm
Basically what you do push/pull for every member in the group/swarm/flock. I wrote some code for this in nexuiz, heres the relevant part:
Code: Select all
vector steerlib_repell(vector point,float maximal_distance)
{
float distance;
vector direction;
distance = bound(0.001,vlen(self.origin - point),maximal_distance);
direction = normalize(self.origin - point);
return direction * (1-(distance / maximal_distance));
}
vector steerlib_arrive(vector point,float maximal_distance)
{
float distance;
vector direction;
distance = bound(0.001,vlen(self.origin - point),maximal_distance);
direction = normalize(point - self.origin);
return direction * (distance / maximal_distance);
}
.float flock_id;
vector steerlib_flock(float radius, float standoff,float separation_force,float flock_force)
{
entity flock_member;
vector push,pull;
float ccount;
flock_member = findradius(self.origin,radius);
while(flock_member)
{
if(flock_member != self)
if(flock_member.flock_id == self.flock_id)
{
++ccount;
push = push + (steerlib_repell(flock_member.origin,standoff) * separation_force);
pull = pull + (steerlib_arrive(flock_member.origin + flock_member.velocity,radius) * flock_force);
}
flock_member = flock_member.chain;
}
return push + (pull* (1 / ccount));
}