Newsgroups: comp.ai.games
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!newsfeed.internetmci.com!news.sprintlink.net!new-news.sprintlink.net!EU.net!Portugal.EU.net!news.rccn.net!newsfeed.sunet.se!news01.sunet.se!sunic!news99.sunet.se!liuida!t91matfa
From: t91matfa@ida.liu.se (Mattias Fagerlund)
Subject: Evolving a flock/army
X-Nntp-Posting-Host: astmatix.ida.liu.se
Message-ID: <t91matfa.829227479@news>
Sender: news@ida.liu.se
Organization: CIS Dept, Linkoping University, Sweden
X-Newsreader: NN version 6.5.0 #6 (NOV)
Date: Thu, 11 Apr 1996 12:57:59 GMT
Lines: 152

[Long mail]


The idea
--------

I've been toying around with an idea for the last couple of days now,
and I though I'd test it on you guys since it seems to have some
applications within the ai.games genre, and because I've seen several
of the topics discussed here allready (I'm a long time lurker).

Having read alot about *boids (all the online info I could get my hands
on) I was struck by the idea that boids would a really cool system to
put through a genetic programming system; let several flocks evolve 
instead of several individuals. This could be used to 'evolve' a 
computer game ai, but that's further ahead than I'm currently looking.

(* Se the end of the post for an short explanation on boids)

There is a program called boids.exe that use 'genetic algorithms' to 
evolve the behaviour of 3 flocks, but the program only 'trims' a previously
designed set of rules, there is no rule mutation.

The idea that has attracted me most is using a fuzzy-control system 
(why not use *all* buzz words in the same system?) for controlling
the boids, and evolving the ruleset of the control system.
As a simple evaluator function, my idea was to start out with 
'the flock that has least crashes between birds is best fit to survive'.
Several flocks would live in the same 'universe' and therefore have
to avoid eachother.


The controlling system (most ideas stolen)
------------------------------------------
The controller would consist of a bunch of rules that all
suggest a new heading and/or a new speed.
All of the rules have priority evaluation routine that derermines how 
important the rule is in the current context. When all rules have been
weighted, the one rule that has the highest priority get to decide how
the boid is to behave. 
Alteretively, all rule outputs are weighted against their priority and
the descition is a sum of all the rules (this is probably better).
On rule could be;

Separation rule;
 // Calculate the priority of the rule, an attempt at fuzzy rules ;)

Priority = (Obstacle_Dist is Near) and 
	     (Obstacle_Pos is Dead_Ahead)

// All avoidance is done to the right, will look weird and be less than optimal.
Direction = Current_Direction + Max_Turn 

// Slow down
Speed = Current_Speed - Current_Speed*0.1


Mutation of rules
-----------------
Most mutation would take place in the constants of the rules, seldom will a
rules be changed alot and rarely will a rule be added/removed.

A mutation of the separation priority rule might be;

// This bird is more protectionistic than most, it starts turning
// earlier and it avoids birds further away from its direction
// of movement.
Priority = (Obstacle_Dist is Very_Near) and 
	     (Obstacle_Pos is Close_To_Ahead)

This may or may not be a better bird, that depends on alot of factors. For 
instance, a bad prio function could make the flock behave in total chaos, 
always trying to avoid birds far far away. Such a species would soon be
exstinct though, because the chaos would cause the birds to collide frequently.


What then?
----------
Enhancements for version 2.0 could be;

  * Add a carnivore/omnivore hierarchy.
    Introducing food?

  * Evolving a species physical charactaristics, ie optimizing their 
    size/speed/agility/sight... capabilities to fit their strategy.

  * Intruducing several communications channels (with limited range);    
    - If channel[150] is active then panic_mode; 
	This would allow an individual to sound an alarm (scream basicly) when  
	a carnivore attacks, therefore helping the species.
    - If channel[149] is active then move_towards_sound;    
      This would allow an individual to notify the rest of the flock that food
      has been found.
 
  * Network-wide evolving of flocks...now that *would* be cool, a couple of GA/GP 
    programs seem to be moving that direction right now.

  * Different weapons/shields/... could be thrown into the genepool to
    evolve game-ai instead.


Related projects
----------------
OK, I know project Von Neumann, when done, could probably be geared towards 
this.
The WASTE engine, when done, could house the universe the flocks live in,
but the universe I've envisioned is simpler then what both Von Neumann and
WASTE are aiming for. I'm more or less thinking of a 2d world right now,
it could probably easily be expanded into 3d later on.


What I have done so far
-----------------------
Well, I've written this post. That's about it.


So? What's the point?
-------------------
Well, I'd really love to hear your ideas on this. I'd also want to know if
anyone has heard of anything similar done/being done. Is anyone other than
me interested in this?
I probably couldn't pull it off myself, because I have a severe lack of time
(who hasn't) and I havn't really done alot of programming (read none) using
GA/GP or fuzzy logic. I've been programming for 12 years otherwise
though, so I'm not a complete newbie ;)

To submit comments, either contact me; mfa@dtek.se, or post to this newsgroup.
Though I'd really prefer both, because my newserver isn't all that reliable.


About Boids
-----------

A boid is an computer controlled individual in a flock.
This from http://reality.sgi.com/employees/craig/boids.html ;

******************************************************************************
Each boid has direct access to the whole scene's geometric description, 
but reacts only to flockmates within a certain small radius of itself. 
The basic flocking model consists of three simple steering behaviors: 

   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. 
******************************************************************************

-mattias fagerlund
--
---------------------------------------------------------------------------
t91matfa@und.ida.liu.se = Mattias Fagerlund, Linkoeping Sweden
One day I'll make me a real .signature, one day. You'll see.
---------------------------------------------------------------------------
