Author Topic: Overall Concept  (Read 7614 times)

Offline Trooper5445

  • Bot Neophyte
  • *
  • Posts: 11
    • View Profile
Overall Concept
« on: May 05, 2008, 10:10:21 PM »
Well I've been trying to create a bot for a while now and I've found I'm having a lot of trouble. To be honest what is messing me up is the fact that I am somehow lacking the "big picture." I can read others code and understand, and I know what I want my bots to do, but I don't understand the way the variables and functions interact to actually do it. Espcially for the latest version. Everytime I try the wiki I want to know something it just links me to another page until I forget what I was after in the first place.

So I suppose I'm just frustrated and looking for analysis of the variables in the latest version.

It isn't really a question but I was wondering if anyone else has had a similar experience or has some help? Thanks for whatever you can provide.
Quotation is a suitable substitute for wit

- Oscar Wilde

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Overall Concept
« Reply #1 on: May 05, 2008, 11:48:29 PM »
Hi.  Welcome aboard.

Happy to help, but can you give me a little more info?  Do you understand the RPN notation the DNA uses?  Gene structure?  The difference between the DNA and the bot's memory?  You should start simple, with just a few sysvars, like .up and .shoot.  Get your bot to move and shoot.  All else will follow.
Many beers....

Offline Trooper5445

  • Bot Neophyte
  • *
  • Posts: 11
    • View Profile
Overall Concept
« Reply #2 on: May 06, 2008, 12:03:02 AM »
I'm at the basic stage. I can get the thing to move but I'm not sure how to do advanced structures. Theoretically speaking I want the bot to halt all functions until a certain gene is activated which allows other genes to activate. The idea is have a bot rotates using little energy, and waits for prey to approach. It then rapidly accelerates and attacks the prey. Reproduction would be asexual and based on a high energy count. I uploaded a couple of my test organisms to the server (where they will be slaughtered in under a 100 cycles probably.)

Here is what I have so far:

Code: [Select]
' L-Sesilia

' Gene 5 - Reproduce
cond
  *.nrg 7500 >
start
  50 .repro store
stop

' Gene 4 - Shoot the food
cond
  *.eye5 40 >
start
  -1 .shoot store
stop

' Gene 3 - Persue Food
cond
  *.refye 5 !=
start
  5 .up store
stop

' Gene 2 - Avoid Friendlies
cond
   *.refeye 5 =
start
  -104 .aimdx store
stop

' Gene 1 - Detect Enemies
cond
  *.eye1 *.eye5 >
start
  -104 .aimdx store
stop


end

In case your curious about the name, it is Lazy Sesillia and the word sessile describes an organism that does not move of its own power.

But the point of this thread was that it was very general. That is what I want to do with one bot, but I just generally lack and understanding of the variables and the ways in which they can be manipulated to accomplish a task.

As to your questions I do indeed understand RPN and Gene structure. I'm a little shaky on the difference between DNA and memory. As for your questions sessilia has maxed out its population in the 30s but does move and eat and reproduce.
Quotation is a suitable substitute for wit

- Oscar Wilde

Offline Shasta

  • Administrator
  • Bot Destroyer
  • *****
  • Posts: 231
    • View Profile
Overall Concept
« Reply #3 on: May 06, 2008, 12:11:56 AM »
Hey don't worry its pretty confusing at first, here are some things to help you out.
[blockquote]The Operators and Sysvars pages contain the most helpful information in the wiki (to me at least) it lists all the ways you can  effect anything the bot does or is in its memory

I know you said you dont want to use anyone else's code in your bots, but that is really the easiest way to learn, the Basic Bot tutorial breaks down Animal Minimalis very well. Or try modifying Animal Minimalis to use some shell or slime or shoot a virus. (the advanced shot bot tutorial covers this a bit and is a good follow up on the basic bot one.)

As for how variables work, to create a variable (w/ a name) you must type
Code: [Select]
def myname locationwere the location is a free variable slot, 50 - ~180 is the preferred range I believe

As for how the variables and functions work to make the bot perform a task, think of it as all your math and conditions are the bot thinking, while a store command is the bot doing something, weither it has thought about it or not

so as in Animal Minimalis's first gene:
Code: [Select]
<pre> *.eye5 0 >
  *.refeye *.myeye !=
 </pre>
here the bot is deciding if it is looking at food or not
Code: [Select]
*.refveldx .dx store
 *.refvelup 30 add .up store
and here the bot is acting upon that decision by following the food

[/blockquote]I hope that helps If I have said something wrong please correct me I really should be asleep right now.
>_< not really necessary now, yea for typing slow hope it still helps
« Last Edit: May 06, 2008, 12:14:55 AM by Shasta »

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Overall Concept
« Reply #4 on: May 06, 2008, 12:16:36 AM »
Okay, cool.  So, what you need to do to accomplish what you want is to use a "free" memory location as a flag that you set in your enemy detection gene and use the value of the flag as a condition is the rest of the genes.  By free, I mean a location that simulator does not interpret as an instruction by the bot to do something or a location where it will write something.  Only about 250 of the 1000 memory locations every bot has are used by the simulaotr.  The rest are totally under bot control to do with what it wants.   Locations 50-175 are guarenteed to be free for the forseeable future I.e. I won;t use them for new features down the road.

So, do something like this:

'Set location 50 to 1 if I see something in eye5
cond
*.eye5 0 >
start
1 50 store
stop

'Set location 50 to 0 if I don't see anything
cond
*.eye5 0 =
start
0 50 store
stop

'Shoot if location 50 is non zero
cond
*50 0 !=
start
-1 .shoot store
stop

EDIT:  Ah, Shasta beat me to it with better advice...  
« Last Edit: May 06, 2008, 12:17:54 AM by EricL »
Many beers....

Offline Trooper5445

  • Bot Neophyte
  • *
  • Posts: 11
    • View Profile
Overall Concept
« Reply #5 on: May 06, 2008, 12:25:22 AM »
Thank you so much for your help. That has cleared it up for me a bit. I'll see what I can do to help my little bot.

Thanks for the prompt replies. I'll post in here if I have any more questions to avoid clutter.
Quotation is a suitable substitute for wit

- Oscar Wilde

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Overall Concept
« Reply #6 on: May 06, 2008, 12:43:53 AM »
We like clutter

Offline Trooper5445

  • Bot Neophyte
  • *
  • Posts: 11
    • View Profile
Overall Concept
« Reply #7 on: May 06, 2008, 11:52:23 PM »
So I've been working on the little (creature? bot?) and this what I've come up with. It has some intresting behaviors but I'm having some problems.

A: I'm not sure my sex code is right
B: It is attacking its own species
C: Is the whole reproduction code I wrote even working?
D: Code seems very inefficient

Testing has found some intersting things though

A: Population expodes every 500 cycles or so. (So it seems some of the Reproduction code is working)
B: Low mutations
C: Normally Population multiplies by about 1.5 every population explosion, then loses half of the new population for a total gain of 25%.

Code:

Code: [Select]
' L-Sesilia
' A robot that really doesn't want to do anything
' With help from the kind community (EricL, Shasta)
' Lazy Sessile

' Gene 9 - Sexual Reproduction if energy is less than 7500
cond
  *.50 1 =
  *.robage 500 >
start
  robbage 500 -
  -8 .shoot store

' Gene 8 - Reproduce asexually if energy is greater than 7500
cond
  *.50 1 !=
  *.robage 500 >
start
  25 .repro store
  robbage 500 -
stop

' Gene 7 - Set a varible for reproduction to be used later.
cond
  *.nrg 7500 >
start
  1 50 store
stop

' Gene 6 - Dispose of excess waste
cond
  *.waste 45 >
start
  -4 .shoot store
  *.waste .shotval store

' Gene 5 - Persue Food by acceleration
cond
  *.refye 5 !=
start
  5 .up store
stop

' Gene 4 - Avoid Friendlies, Spin Right if detected
cond
   *.refeye 5 =
start
  -104 .aimdx store
stop

'Gene 3 - Shoot if location 75 is not equal to zero
cond
*75 0 !=
start
-1 .shoot store
stop

'Set location 75 to 0 if nothing is seen
cond
*.eye5 0 =
start
0 75 store
stop

'Set location 75 to 1 if something is seen in eye5
cond
*.eye5 0 >
start
1 75 store
stop

end

I was trying to base this on the fact that several animals reproduce sexually only when having problems surviving and when they are doing well reproduce asexually. Any help or comments are welcome.
Quotation is a suitable substitute for wit

- Oscar Wilde

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Overall Concept
« Reply #8 on: May 07, 2008, 01:23:30 AM »
You have a few syntatical errors.  You might want to take a look at the bot's DNA as the simulator sees it by double clickign on a loaded bot in a sim and using the bot properties dialog to spot syntax problems.

Gene 9 (top gene, actually gene 1 as far as the DNA is concerned)  is missing a stop.  Also 'robbage' is not a sysvar.  Misspelling?  Note sure what you are trying to do with that line and same line in gene 8 (gene 2 as far as the DNA is concerned).

Gene 6 is also missing a stop.

It's coming along though.   Stick with it.  It gets easier!!

Many beers....

Offline Trooper5445

  • Bot Neophyte
  • *
  • Posts: 11
    • View Profile
Overall Concept
« Reply #9 on: May 07, 2008, 01:31:03 AM »
What I mean was robage which is a variable for age according to the wiki. http://www.darwinbots.com/WikiManual/index.php?title=.robage

Fixed the stops.

and rewrote Gene 9

Code: [Select]
cond
  *.50 1 =
  *.robage 500 >
start
  robage 500 -
  -8 .shoot store
  50 .sexrepro
stop

EDIT: It seems to be working. Its amazing to see population explode at 500 cycles. It goes from 5 (the intial) to around 60 in about 50 frames. By 1500 frames it is up to about 650 bots.
« Last Edit: May 07, 2008, 01:42:49 AM by Trooper5445 »
Quotation is a suitable substitute for wit

- Oscar Wilde

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Overall Concept
« Reply #10 on: May 07, 2008, 01:45:30 AM »
You mispelled robage as "robbage" above in a couple places.

Also, it should be either .robage or *.robage depending on what you are trying to do.  .robage is just an easy way to refer to the number 9 I.e. memory location #9 is where the simulator uses to write the age of the bot.  *.robage will be the contents of memory location 9, the bot's actual age.

Note that .robage is read only.  The simulator will overwrite whatever the bot stores there every cycle.

Also, the minus sign "-" is not subtraction.  It negates the top value on the stack.   I think you want "sub".
Many beers....

Offline Trooper5445

  • Bot Neophyte
  • *
  • Posts: 11
    • View Profile
Overall Concept
« Reply #11 on: May 07, 2008, 01:57:22 AM »
Is there anyway to set some form of timer then so I can have reproduction be simultaneous?
Quotation is a suitable substitute for wit

- Oscar Wilde

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Overall Concept
« Reply #12 on: May 07, 2008, 02:33:00 AM »
Use *.timer.  It's guarenteed to stay in sync between children and parents (unless you overwrite it of course).

Offline Trooper5445

  • Bot Neophyte
  • *
  • Posts: 11
    • View Profile
Overall Concept
« Reply #13 on: May 07, 2008, 09:17:18 PM »
Argh, code is all messed up. The Bots are not firing and Reproduction is messed up with none taking place. I can't seem to locate the problem.

Code: [Select]
' L-Sesilia
' A robot that really doesn't want to do anything
' With help from the kind community (EricL, Shasta)
' Lazy Sessile

' Gene 11 - Sexual Reproduction if energy is less than 7500
cond
  *.nrg 7500 <
  *12 .timer 500 >
start
  12 .timer 500 -
  -8 .shoot store
  50 .sexrepro
stop

' Gene 10 - Reproduce asexually if energy is greater than 7500
cond
  *.nrg 7500 >
  *.timer 500 >
start
  25 .repro store
  12 .timer 500 -
stop

' Reproducing Allowing gene (Test)
cond
start  
  12. timer 0 =
stop

' Gene 6 - Dispose of excess waste
cond
  *.waste 45 >
start
  -4 .shoot store
  *.waste .shotval store
stop

' Gene 5 - Persue Food by acceleration
cond
  *.refye 5 !=
start
  5 .up store
stop

' Gene
cond
  *.eye9 *.eye5 >
start
  25 .aimdx store
stop

' Gene
cond
  *.eye1 *.eye5 >
start
  25 .aimsx store
stop

' Gene 3 - Shoot if location 75 is equal to one
cond
  *.75 1 =
start
  -1 .shoot store
stop

' Set location 75 to 0 if nothing is seen
cond
  *.eye5 0 =
start
  0 75 store
stop

' Set location 75 to 1 if something is seen in eye5
cond
  *.eye5 0 >
start
  1 75 store
stop

end
Quotation is a suitable substitute for wit

- Oscar Wilde

Offline goffrie

  • Bot Builder
  • **
  • Posts: 65
    • View Profile
Overall Concept
« Reply #14 on: May 07, 2008, 09:50:19 PM »
Quote from: Trooper5445
Argh, code is all messed up. The Bots are not firing and Reproduction is messed up with none taking place. I can't seem to locate the problem.

Woah. "*12 .timer 500 >" ? That doesn't do a whole lot (is always false), and your *12 seemingly doesn't do anything.
You're missing a few "store"s, and I don't think your sexual reproduction genes are exactly working. You can't just randomly fire off a -8 shot and also store 50 in .sexrepro, that doesn't do anything but impregnate a bot in front of you. If that bot happens to be you own species, it won't try to reproduce for another 500 cycles and by that time the fertilized-ness will have worn off. Finally, your position-75 storing for eye5 is pretty useless, you could just replace that condition directly with an eye5 condition.

Most of these things fixed, plus spelling errors. (I didn't fix the sexual-reproduction problem, as I can't think of any good way to fix that with your desired 500-cycle reproduction.)
Code: [Select]
' L-Sesilia
 ' A robot that really doesn't want to do anything
 ' With help from the kind community (EricL, Shasta)
 ' Lazy Sessile
 
 ' Gene 11 - Sexual Reproduction if energy is less than 7500
 cond
   *.nrg 7500 <
   *.timer 500 >=
 start
   0 .timer store
   -8 .shoot store
   50 .sexrepro store
 stop
 
 ' Gene 10 - Reproduce asexually if energy is greater than 7500
 cond
   *.nrg 7500 >
   *.timer 500 >=
 start
   25 .repro store
   0 .timer store
 stop
 
 
 ' Gene 6 - Dispose of excess waste
 cond
   *.waste 45 >
 start
   -4 .shoot store
   *.waste .shootval store
 stop
 
 ' Gene 5 - Persue Food by acceleration
 cond
   *.refeye *.myeye !=
 start
   5 .up store
 stop
 
 ' Gene
 cond
   *.eye9 *.eye5 >
  *.eye5 0 =
  *.refeye *.myeye = or
 start
   25 .aimdx store
 stop
 
 ' Gene
 cond
   *.eye1 *.eye5 >
  *.eye5 0 =
  *.refeye *.myeye = or
 start
   25 .aimsx store
 stop
 
 ' Gene 3 - Shoot if something is seen which isn't a conspec
 cond
   *.eye5 0 >
  *.refeye *.myeye !=
 start
   -1 .shoot store
 stop
 
 end
« Last Edit: May 07, 2008, 09:52:21 PM by goffrie »