Author Topic: Chameleon genes  (Read 4327 times)

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
Chameleon genes
« on: August 06, 2006, 11:12:33 AM »
I must be missing something here, want the set of genes as a closed loop in the bots code. Figured that *.memval can only be used for one value per turn.

Biggest problem has been *.reqmemval and *.reqmemloc ending up as the same value when I make minor changes

Have been testing against Ymir which uses a value of 8741 in mem loc 604 for ID

I've tried lots of different ways but seem to always end up against a brick wall.  

Test bot I have been using:

def count 987
def foundmemloc 51
def reqmemval 52

cond
*.count 1 =
*.reqmemval 0 !=
*.foundmemloc 0 !=
start
0 .count store
stop

'CHAMELEON GENES
'********************Adding count to next genes makes refmemval and foundmemloc same
cond
*.refeye 0 !=
'*.count 1 =
*.eye5 0 >
*.refshoot *.myshoot !=
*.foundmemloc 0 !=
'***********************Why not this line? (makes reqmemval and foundmemloc same)
'*.reqmemval 0 =
start
*.foundmemloc .memloc store
*.memval .reqmemval store
stop

cond
'*.count 1 =
*.reqmemval 0 !=
*.foundmemloc 0 !=
start
*.reqmemval *.foundmemloc store
stop

cond
*.refeye 0 !=
*.eye5 0 >
*.refshoot *.myshoot !=
*.robage 1 >
*.foundmemloc 0 =
'*.reqmemval 0 =
start
.memloc .memloc store
*.memval .foundmemloc store
'1 .count store
stop

'*****BOT******
cond
*.nrg 1000 >
start
50 .repro store
stop

cond
*.numties 0 =
*.count 0 = and
*.refshoot *.myshoot !=
*.eye5 0 >
start
*.refxpos *.refypos angle .setaim store
10 .up store
-1 .shoot store
stop

cond
*.eye5 0 =
*.refshoot *.myshoot = or
start
145 .aimsx store
stop
end

Would appreciate it if someone could check the code and tell me why the bot seems to like living in cloud cuckoo land everytime I make these changes.  
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
Chameleon genes
« Reply #1 on: August 07, 2006, 09:23:19 AM »
I don't see any place in the genes above where you actually stored the value in .reqmeloc into a memory location

Basically, in order to read .memval you have to first store a value into .memloc

if you want to find a value of 8741 in memory location 604, you need something like...

Code: [Select]
cond
start
  604 .memloc store
stop

cond
  *.memval 8741 =
start
  'do whatever you want
stop
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
Chameleon genes
« Reply #2 on: August 07, 2006, 09:44:42 AM »
Hiya PY  

Thanks for looking at the code. It's a bit muddled because I switched the order of genes to see if that helped.

The first time it sees an enemy it should do:

.memloc .memloc store
*.memval .foundmemloc store (what value do you have in memloc)

The next time it sees an enemy it should do:

*.foundmemloc .memloc store
*.memval .reqmemval store  (what value do you have in the location you store in memloc)

And then store the value in the same memory location using:

*.reqmemval *.foundmemloc store

All of which leads to the bot, using the code posted, to display the correct behaviour against Ymir, it probably won't win but it will last for a while.

However, if I enable the line:

'***********************Why not this line? (makes reqmemval and foundmemloc same)
'*.reqmemval 0 =

It won't work properly.

Or if I enable the count cond in the chameleon genes it won't work properly.
So I figure there is something I'm not taking account of, normally I can work out why the code isn't working but not this time.  
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
Chameleon genes
« Reply #3 on: August 07, 2006, 09:48:49 AM »
I can't see amy obvious reasopn why it shouldn't work.

Have you tried stepping it through with the console?
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
Chameleon genes
« Reply #4 on: August 07, 2006, 09:59:04 AM »
Only as far as working out that the reason it stops working (if I add those extra bits) is that it stores 604 in location 604 or doesn't store 8741 in location 8741.

Can't figure why though. (Beyond reqmemval and foundmemvloc are the same.)

I'll go and run it through the console a few more times. See if I can find anymore info about how it goes wrong.

[Edit]It could be reading the value from it's friends instead I suppose, hmm, might be problem.
« Last Edit: August 07, 2006, 10:06:34 AM by Jez »
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
Chameleon genes
« Reply #5 on: August 07, 2006, 10:46:38 AM »
Ok, think I've figured it out...

It takes two turns to store each value!

So the order of activations is:

1.Sees enemy:
Stores value of 0 in 51 (G4)

2.Next turn,
Stores value of 604 in 51 (G4)

3.Next turn,
Stores value of 604 in 52 (G2+3)

4.Next turn,
Stores value of 8741 in 52 (G2+3)

Continues with (G2+3) no change to values.

If I add the line *.reqmemval 0 = to gene 2 then it won't reach step 4 leaving me with 604 in both 51 and 52. (604 in mem location 604)

If this is how it's meant to work, (memval reads the location stored in memloc last turn) then I think I can work around it and will update Wiki syvars.  
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
Chameleon genes
« Reply #6 on: August 07, 2006, 12:47:07 PM »
Yes I believe that is how it works.

It's been a long long time since I tinkered with that bit of code. As I recall I had a hell of a lot of trouble trying to get it to work on one cycel. The problem is that all sysvar senses are loaded at the beginning of the cycle, before the DNA is parsed in the main loop so by the time the main loop knows it has to look for a value in a specific memory location, it's too late to do so immediately so it has to do it next itme around.

You should be able to do it in 3 steps tho instead of 4. You can change the value in .memloc on the same cycle that you read the value in the old memory location. Might save you a bit of time.
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Chameleon genes
« Reply #7 on: August 07, 2006, 04:21:21 PM »
Yes memloc loads the memory value into memval the next cycle.  memloc is more like a request to read the value of a mem location than a way to immediately read it.