Welcome To Darwinbots > Newbie

Enemy Recognition.

(1/3) > >>

Chlorate:
So I've been fiddling around with a bit of code for a while, as I mentioned in my greeting message, so my bot uses more of its eyes to find food instead of spinning and moving around randomly.

So my bot's eyes are set up like so:

--- Code: ---cond
start
 628 .eye3dir store
 90 .eye1dir store
 -628 .eye7dir store
 -90 .eye9dir store
stop
--- End code ---

Eyes 3 and 9 aren't doing anything right now, but I'm considering doing something with them later.
Eyes 1 and 9 are moved further apart slightly to give a wider field of view.

I've set it up so that if it sees something in eye 1 or eye 2 (or indeed eyes 8 or 9), but not in eye 5 it'll turn to face it.
However no matter what I try, I can't make the bot not turn to face a member of its own species and as a result they'll often end up going around in circles with each other and getting eaten.

Here's an example of what I've been trying:

--- Code: ---cond

 *.refeye *.myeye !=
 *.eye5 0 =
 *.eye1 0 >
 *.eye2 0 > or

start
 100 .aimsx store
stop
--- End code ---

Does the condition  *.refeye *.myeye != only work if it's referring to a robot in view of eye5?

I've been scratching my head and not getting very far because of this problem, can anyone hint as to what may be wrong?

Thanks.

bacillus:
If you want to use the refvars on anything other than .eye5, you have to change the focus eye. For example, this code sets the focus eye to eye 3:

-2 .focuseye store

Check out OCULUS II in the gene depository, it's a command that sets the focus eye to the nearest object.

Chlorate:
Thanks for the boot in the right direction.

Although I couldn't make head nor tail of OCULUS II.  

So now I've written the code that makes my bot focus on the nearest object, however I still can't get it to not turn to face members of its own species.

Here's the bit of code responsible for turning the bot:

--- Code: ---'8 Turn to face
cond
 *.refeye *.myeye !=
 *.eye5 0 =
 *.focuseye 0 !=
 *.eye1 *.eye2 add 0 >
 *.eye8 *.eye9 add 0 > or
start
 *.focuseye -30 mult .aimsx store
stop
--- End code ---

Any more pointers would be appreciated, this is getting quite infuriating now  

ashton15:

--- Quote from: Chlorate ---Thanks for the boot in the right direction.

Although I couldn't make head nor tail of OCULUS II.  

So now I've written the code that makes my bot focus on the nearest object, however I still can't get it to not turn to face members of its own species.

Here's the bit of code responsible for turning the bot:

--- Code: ---'8 Turn to face
cond
 *.refeye *.myeye !=
 *.eye5 0 =
 *.focuseye 0 !=
 *.eye1 *.eye2 add 0 >
 *.eye8 *.eye9 add 0 > or
start
 *.focuseye -30 mult .aimsx store
stop
--- End code ---

Any more pointers would be appreciated, this is getting quite infuriating now  
--- End quote ---

the refvars your using only work for the focuseye, what I'd reccomend is have 2 eyes facing forwards (eye5 and eye6 for example) make 6 the focuseye and then with eye5 you can use memloc (like a ref but you specify what you ref) and the in out communication sysvars so point eye5 to whatever is closest and you can use memloc to tell wether it is your species or not (I'd advise using Dna length for this rather than eyes because it's harder to fake) then you can keep the focuseye looking at the vegetable or enemy or whatever it's looking at without turning. Just say if you need some help coding it (hint: use  .eye5dir). if you do work it out as a favour I can put it into unconditional logic for you which would make it use less energy. That's a thing mr green tentacle monster I looked at your occulus 2 thing again now I understand the code, couldn't you easily improve it byadding in some unconditional condiditions so you don't store a value every cycle and again rather than a store could you just go through logic gates and do incs and decs so if it moved just one eye to the right you could use a tenth of the energy you would normally use. Just an idea.

Chlorate:
But the target bot is being looked at by the focus eye, as I mentioned before I wrote some code that switches the focus eye from eye5 to whichever has the closest bot to it.

Forgive me if I turn down your favour, but I've only been at this for a couple of days now, and I'm still trying to understand the basic syntax.
Thanks anyway.

Navigation

[0] Message Index

[#] Next page

Go to full version