Author Topic: help  (Read 7408 times)

Offline MrMound

  • Bot Destroyer
  • ***
  • Posts: 156
    • View Profile
help
« on: December 03, 2005, 07:35:40 PM »
I want to make a bot that randomly chooses what it will be(like the multibot vegtable). I want it to choos to be a reproducer, a attacker or a defender.  how do I make it choos.  I know it has to do something with the .type command and the rnd command but I don't really know how to code it.
cooperation is working together to achive a common goal
mrmound

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
help
« Reply #1 on: December 04, 2005, 04:43:01 AM »
What you'll want to do is decide on a variable to hod type.

def .type 50

would set this up for you.

Then you have in some gene that decides type:

2 rnd 1 add .type store

this will store 1,2 or 3 in type.

Then you simply check if *.type 1 = etc. etc. for other types in each gene that controls multibot behavior.

Offline MrMound

  • Bot Destroyer
  • ***
  • Posts: 156
    • View Profile
help
« Reply #2 on: December 04, 2005, 04:37:01 PM »
so it would look somthing like this if I wanted a bot to randomly choose witch direction to move.


Code: [Select]
cond
start
def .type 50
stop


cond
*.type > 3
start
2 rnd 1 add .type store
stop

cond
*.type = 1
start
100 .up store
stop

cond
*.type = 2
start
100 .dn store
stop

cond
*.type = 3
start
100 .dx store
stop

end
cooperation is working together to achive a common goal
mrmound

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
help
« Reply #3 on: December 04, 2005, 04:47:32 PM »
Not quite.

The def commands are placed before the start of the actual genome.

def simply sets up a custom sysvar with any name that you choose, to represent a specific memory location. In this case .type becomes the equivalent of memory location 50.

*.type exactly equals *50. it is just easier working with a sysvar than a raw memory location.

Your code should look like this.

Code: [Select]
def .type 50

'genome starts here
cond
*.robage 0 =
start
2 rnd 1 add .type store
stop

cond
*.type = 1
start
100 .up store
stop

cond
*.type = 2
start
100 .dn store
stop

cond
*.type = 3
start
100 .dx store
stop

end

This sets up the ".type" as a custom variable then sets a random value of 1,2 or 3 into it when the robot is born (age = 0). For the rest of the robot's life, .type will contain the same value (unless you change it from another gene at some point)
« Last Edit: December 04, 2005, 04:52:56 PM by PurpleYouko »
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline MrMound

  • Bot Destroyer
  • ***
  • Posts: 156
    • View Profile
help
« Reply #4 on: December 04, 2005, 04:57:32 PM »
ok so with the def command you can set any variable you want?
cooperation is working together to achive a common goal
mrmound

Offline MrMound

  • Bot Destroyer
  • ***
  • Posts: 156
    • View Profile
help
« Reply #5 on: December 04, 2005, 05:25:46 PM »
umm is .type supposed to show up as a 0 in the dna with that robot?
cooperation is working together to achive a common goal
mrmound

Offline Light

  • Bot Destroyer
  • ***
  • Posts: 245
    • View Profile
help
« Reply #6 on: December 04, 2005, 05:30:37 PM »
no it should show up as the number of the address ie 50

Offline Light

  • Bot Destroyer
  • ***
  • Posts: 245
    • View Profile
help
« Reply #7 on: December 04, 2005, 05:34:12 PM »
PY made a mistake in the code
Code: [Select]
def .type 50should be
Code: [Select]
def type 50
« Last Edit: December 04, 2005, 05:34:23 PM by Light »

Offline MrMound

  • Bot Destroyer
  • ***
  • Posts: 156
    • View Profile
help
« Reply #8 on: December 04, 2005, 08:34:32 PM »
is there a way to make a costom sysvar amount increase by 10 every 10 cycles
cooperation is working together to achive a common goal
mrmound

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
help
« Reply #9 on: December 05, 2005, 03:37:47 AM »
yes:

cond
*.robage 10 mod 0 =
start
*.type 10 add .type store
stop
« Last Edit: December 05, 2005, 03:37:55 AM by Numsgil »

Offline MrMound

  • Bot Destroyer
  • ***
  • Posts: 156
    • View Profile
help
« Reply #10 on: December 06, 2005, 07:07:22 PM »
is there a way to ref a costom sysvar in another bot? like using .type as and example would I be able to see if .type is 2?
cooperation is working together to achive a common goal
mrmound

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
help
« Reply #11 on: December 06, 2005, 10:12:48 PM »
You mean from the console?  have you tried:

? .type

If that doesn't work, you probably need to use the actual memory location.

If you mean the bots themselves, you could use memloc and memval.  Are you familiar with them?

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
help
« Reply #12 on: December 06, 2005, 10:21:56 PM »
yes there is a way to do this.

By using .memloc and *.memval, it is possible to read any memory location in a viewed bot.

Something like this would do it.
Code: [Select]
def type 50
def readtype 51

cond
*.eye5 0 !=
start
.type .memloc store
*.memval .readtype store
stop

this should save whatever value that the viewed robot has in memloc 50, into your own memloc 51. You can then read it in later genes as *.readtype.

Don't quote me on this. It has been a couple of years since I tried this last so I can't remember precisely how it works.

Memloc/memval are probably the least used sysvars in the whole genome. I have never seen a robot use them.
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D

Offline MrMound

  • Bot Destroyer
  • ***
  • Posts: 156
    • View Profile
help
« Reply #13 on: December 07, 2005, 09:25:07 PM »
this gene should change .type's value to 3 if the nrg is < 10000 right?
Code: [Select]
cond
*.type 3 =
*.nrg 10000 <
start
1 .type store
stop

I use a gene like this and I think it works but not that one ^.
Code: [Select]
cond
*.type 1 =
*.nrg 20000 >=
start
3 .type store
stop
« Last Edit: December 08, 2005, 10:18:49 AM by Henk »
cooperation is working together to achive a common goal
mrmound

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
help
« Reply #14 on: December 08, 2005, 10:35:16 AM »
The gene that you listed will change the type from type 3 to type 1 if energy is less than 10,000.

The second gene will change .type from 1 to 3 if energy is greater than/equal to 20,000
« Last Edit: December 08, 2005, 10:36:38 AM by PurpleYouko »
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D