Author Topic: Newbie question about coding behaviors into DNA.  (Read 3288 times)

Offline PhiNotPi

  • Bot Builder
  • **
  • Posts: 64
    • View Profile
Newbie question about coding behaviors into DNA.
« on: April 19, 2011, 09:53:49 PM »
Even though I understand how to create genes for simple things (when this happens, do this), I am having trouble coding higher level behaviors into DNA.  The hunting strategy that I wanted to implement was a simple hunting in a swarm behavior.  My bot would form in loose swarms, and when one bot sees food, everyone else in the swarm follows.  I can write a gene telling the bot to follow conspecs.  I can write a gene that tells the bot to back away from conspecs when too close.  I even figure out how to get other bots to follow the bot who sees food.  But when I combine them, the end result does not function as I anticipate.  What happens is that, when feeding, all of the bots become to close to each other, and they all end up shooting each other when they try to feed off of the prey.  This allows the prey the opportunity to destroy the entire swarm, which usually happens.  (the code for my bot is saved on a different computer) Besides just this one example, what is some advice to help me code higher level behaviors?
I am biased neither towards nor against any single mathematical constant.

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
Re: Newbie question about coding behaviors into DNA.
« Reply #1 on: April 20, 2011, 03:15:02 AM »
Welcome to the wonderful world of emergent behaviour, where simple rules give complex and unexpected results. It's part of the game...
When programming my bot, Gimmick I learned that swarming is actually not good behaviour in this sim. That is to say, a species avoiding it own defeats a swarming variety in a death match. Solitary rules. Reason being that the odds on a species level the amount of food consumed increases if they look for different prey.

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Newbie question about coding behaviors into DNA.
« Reply #2 on: April 20, 2011, 05:24:09 AM »
ikke: I'd say that a swarm definitely is more interesting than a single bot to watch, but it isn't really that beneficial, as you said, for the species.

Erm, PhiNotPi: If you show us the code, then we might be able to help you. Something will change a value somewhere and a gene later on will try to use that same value, getting a different one, than you hoped.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Newbie question about coding behaviors into DNA.
« Reply #3 on: April 21, 2011, 01:03:29 PM »
If the problem is stray shots, you may find that tie feeding works better for herd feeding.  At least there you can check before you start feeding what you ended up tieing to.