Darwinbots Forum

Code center => Darwinbots Program Source Code => Topic started by: Greven on June 22, 2005, 07:28:39 AM

Title: Eyes in DB!?
Post by: Greven on June 22, 2005, 07:28:39 AM
This is both a question and a suggestion.

I havent checked this and therefore my question is:
I know that if a bot do use any eye commands, the function is entirely skipped, but what if there is only one, say eye8? Do the program calculate every single eye? I dont know have the eye distance etc. is calculated, but if eye9 aint dependent on anyother eye, there is no meaning in calculating eye1, if only eye9 is represented in the genome. or what? Please reply! Because if the program does this, calculates eye1, when only eye9 is used, this could speed the program!
Title: Eyes in DB!?
Post by: Ulciscor on June 22, 2005, 07:46:48 AM
Just wondering if this idea would be messed up by a virus inserting a gene which uses another .eye location? Like a bot using only .eye5 gets an insertion with a reference to .eye8 but this wouldn't work because the program only calculates .eye5.
Unless every cycle the program checks how many eye references there are, and calculates the appropriate values, but wouldn't that take a lot of time?
Title: Eyes in DB!?
Post by: Carlo on June 22, 2005, 08:15:07 AM
It works like that: the dna isn't explored at all; instead, each bot has a flag which is called eyeused (or something like that), which is false at birth. When a value is read from any one of the eye locations, that flag is set to true. When the flag is true, the sight routines are calculated. So, each robot sees only from the second time it tries to see in its life; on the other hand, the procedure will still work with viruses or everything else. There's no point in calculating only single eyes, since all eyes are calculated together with a single search on near robots.
Title: Eyes in DB!?
Post by: Ulciscor on June 22, 2005, 08:19:47 AM
So does that mean that the first time an eye location is read it won't get a value? Or is it read, the flag set the routine called and then the value passed back?
Title: Eyes in DB!?
Post by: PurpleYouko on June 22, 2005, 09:00:46 AM
That is right. When robot age is zero they are completely blind. By age 1 they can recognize everything around them.
Title: Eyes in DB!?
Post by: Ulciscor on June 22, 2005, 10:17:16 AM
Just out of interest what value is returned the first time it reads an .eye address? 0?
Title: Eyes in DB!?
Post by: PurpleYouko on June 22, 2005, 10:30:26 AM
The first time it reads it (at age 1) it is pretty much always facing its parent so the number in eye5 is quite high. In versions prior to 2.35 this was extremely predictable and read exactly 77 every time.
In the newer versions the eyes have been somewhat overhauled so I am not sure what is returned now. Try running a sim frame by frame till a robot gives birth then switch to the baby and check its eyes at age 0 and 1. I haven't done this with the new version yet.
In the upcoming 2.4 it is going to be almost impossible to predict since the robot sizes will vary much more dramatically.
Title: Eyes in DB!?
Post by: Greven on June 22, 2005, 10:43:22 AM
I have tested what PY suggested serveral times, and I got 150 and/or 155 at age 0, with the simplebot2. Then it rotates and then nothing in eye5.
Title: Eyes in DB!?
Post by: Ulciscor on June 22, 2005, 10:47:40 AM
I think I meant what value is returned when the bot tries to get the value when the address hasn't been "activated" yet. Like when it tries to access an .eye address for the first time, a flag is set, but is a value still returned?
Title: Eyes in DB!?
Post by: PurpleYouko on June 22, 2005, 11:04:44 AM
At age zero it will (or should) return zero since the eyes array has yet to be populated.
Title: Eyes in DB!?
Post by: Numsgil on June 22, 2005, 11:16:07 AM
There are actually alot of shortcuts you can use since you know the eyes together form a 90 degree angle.  But I have thought about limiting eye recognition to 9 if only 5 is used.

Currently (in my version I'm working on right now), bumping into another bot seems to activate the eyes.  I have absolutely no idea why.
Title: Eyes in DB!?
Post by: Ulciscor on June 22, 2005, 11:46:55 AM
What's the activating condition for an eye anyway?
Title: Eyes in DB!?
Post by: Numsgil on June 22, 2005, 11:56:57 AM
I think if any of the *.eyeXs are attempted to be put on the stsack, the eyes activate.
Title: Eyes in DB!?
Post by: Ulciscor on June 22, 2005, 12:03:57 PM
So either a collision is putting an .eyeX on the stack or there is some hole that is activating the eyes directly? That may require some detective work...
 :blink:
Title: Eyes in DB!?
Post by: Numsgil on June 22, 2005, 12:26:18 PM
Yep, such a pain.
Title: Eyes in DB!?
Post by: Endy on June 22, 2005, 05:32:38 PM
Just out of curiosity, does " *.refxpos *.refypos dist " return the same value as *.eye5 would?

Endy B)
Title: Eyes in DB!?
Post by: Numsgil on June 22, 2005, 05:36:33 PM
the eyes return this:

eyevalue = 12000/distance (120000 = robsize*100)

note that refX variables won't activate if no eyes are used, I don't think.  Has to do with how the refX variables work.
Title: Eyes in DB!?
Post by: Endy on June 23, 2005, 03:52:48 AM
Darn and here I wanted to make a blind bot. :)

Endy B)
Title: Eyes in DB!?
Post by: Numsgil on June 23, 2005, 12:12:23 PM
A bot that uses no eyes would be really cool,  but you just couldn't use anything to tell anything about the other bot.

Even in/out won't work.
Title: Eyes in DB!?
Post by: PurpleYouko on June 23, 2005, 12:35:50 PM
Like Carlo said earlier, the first time the DNA of a new bot is tokenized in the DNA parser, it sets a flag called ".view" if it encounters any .eye(x) command.

This flag sets the stage for the entire set of refvars to be imported on the next (and every) subsequent cycle.

At first I wondered if you could create a robot with one gene that has an eye command, a timer and a gene deletion command. Something like
Code: [Select]
' gene 1
cond
*.robage 2 =
*.eye5 *.eye5 =
start
1 .delgene store
stop
I don't think it will work though since I am pretty sure that the .view flag is reset on every cycle.

Might be worth trying out though.
Title: Eyes in DB!?
Post by: Endy on June 24, 2005, 04:45:03 AM
Worth a shot :D

Umm...Nums what's going to happen when the new stand alone * is developed? Could the numbers fo eyes be changed in midstep?(Alright I'll admit I've figured out a [you]very[/you] complex way to do this already) B)
Title: Eyes in DB!?
Post by: Numsgil on June 24, 2005, 10:27:27 AM
I have absolutely no idea, to be honest.

In fact, the .view flag is beginning to work strangely, sometimes turning the bot off for no reason.  I'm going to have to do some bug hunting :/
Title: Eyes in DB!?
Post by: PurpleYouko on June 24, 2005, 11:35:32 AM
OK here is the lowdown on "view" (in V 2.37.2 source)

.view flag is always set to FALSE for any new bot

The only procedure which can set it to TRUE is "Instack" which is called a lot (to say the least) from the DNA parser.
In short you can't sneak an eye cell into the DNA by any means without the flag getting set pretty darned quickly. Add a virus with an eyecell, to a blind bot and it will be caught on the next cycle.

Once set to TRUE the only way to set it to FALSE again is for the robot to die and become a corpse.

This means that if you design a bot that has an eyecell originally but then loses it, it will keep on seeing the refvars for the rest of its life, however its children will be completely blind as they will never inherit the missing gene.
Title: Eyes in DB!?
Post by: Ulciscor on June 24, 2005, 11:39:12 AM
Maybe it should be set back to false when the .eye genes count is 0? Although I guess this would happen so rarely I don't suppose it would speed the program up much.
Title: Eyes in DB!?
Post by: PurpleYouko on June 24, 2005, 12:30:54 PM
Right it could only happen due to a delgene operation.
Title: Eyes in DB!?
Post by: Endy on June 25, 2005, 03:43:42 AM
Yeah, I noticed the same thing. Thought about giving viruses a shot, but the complexity made it kind of pointless.

I actually gave up on that method and have been working on developing a truly blind bot and letting it evolve. Currently it's good enough to survive, but I'm trying to use what evolution comes up with to help improve on it. Kind of cool project since it is easier to understand what is occuring and why.

So far it's come up with a several cycle randomized turning, following reproduction, presumably to give the child and parent time to seperate. I'm trying to find a method to make it less canabotistic, possibly useing poison shots(ID non plant) would help.

Is there something wrong with *.shflav and *.shang? They seem to stay at whatever the last value was.

P.S.
Found that eyes(when .view 0 =) stay at 150 past robage 1.