Darwinbots Forum

Code center => Suggestions => Topic started by: Botsareus on February 21, 2005, 06:22:50 PM

Title: Arrays other topic
Post by: Botsareus on February 21, 2005, 06:22:50 PM
Dim memory(1000) as Intager 'this actualy already Exists in the program

Do '<--- this loop is the robot stack loop itself
memory(0) = 0
Do
memory(memory(0) + 100) = 999 - memory(0)*2 '<--- inpossible in the current virsion
If memory(0) > 100 Then Exit Do
Loop
Loop

***Can you later add the ability for the DNA to store values in arrays , not in memory one by one

***And Robots will be able to mutate all this stuff naturaly

***THE ABOVE CODE WHEN WRITTEN IN DB DOES NOT USE ANY NEW LOOPS , IT CAN USE THE Cycling of the program itself as a loop. That makes even more sense because now a robot takes more time to store a bigger erray
Title: Arrays other topic
Post by: Botsareus on February 21, 2005, 07:19:41 PM
ok I think what I am talking about is in the program already ex:

Quote
*.32 20 >
is a pointer from memory 32, is it greater then 20 ?

Therfore please include that it will mutate also; naturaly by the program: "Bots use there own memory to think , for once"

Am I correct some ? Am I wrong some ? , whats going on?
Title: Arrays other topic
Post by: Numsgil on February 21, 2005, 10:30:42 PM
A quick note:

"*32", not "*.32"
Title: Arrays other topic
Post by: PurpleYouko on February 22, 2005, 09:19:01 AM
Quote
ok I think what I am talking about is in the program already ex:

Quote
*.32 20 >
is a pointer from memory 32, is it greater then 20 ?

Therfore please include that it will mutate also; naturaly by the program: "Bots use there own memory to think , for once"

Am I correct some ? Am I wrong some ? , whats going on?
Yes it will mutate naturally by the program.

 :D PY  :D
Title: Arrays other topic
Post by: Botsareus on February 22, 2005, 12:47:48 PM
OK MY FURTHER WORK/EXPERIMINTATION WITH ARRAYS/MATH :

cond
*20
0
=
start
20
21
store '21 is the pointer to memory location 20
1
22
store
22
23
store '23 is the pointer to memory location 22
stop

cond
start
20
inc
stop

cond
*20
100
>
start
0
*21
store
stop

end

PROBLEM :

WHEN I ADDED :
Quote
1
22
store
22
23
store '23 is the pointer to memory location 22

THIS STOPED WORKING :
Quote
20
inc

ANY ONE KNOW A SOLUTION?
Title: Arrays other topic
Post by: Botsareus on February 23, 2005, 02:05:24 PM
I should of posted this in the bugs board , can any one help? , this is a real bug!


also will be nice if robots mutate stuff like :

Quote
*21
store

once thats possible , all erray monipulations are possible , but costly
Title: Arrays other topic
Post by: Numsgil on February 23, 2005, 02:34:17 PM
First, I'd recommend using some labels, cause *21 makes peoples' heads hurt.

Secondly I'll give it a look.
Title: Arrays other topic
Post by: Numsgil on February 23, 2005, 02:42:15 PM
Here's a labeled up version of what bots posted:

Code: [Select]
def a 20
def apoint 21
def c 22
def cpoint 23

cond
*.a 0 =
start
.a .apoint store store 'apoint points to a
1 .c store
.c .cpoint store 'cpoint points to c
stop

cond
start
.a inc
stop

cond
*.a 100 >
start
0 *.apoint store
stop
end
Title: Arrays other topic
Post by: Botsareus on February 23, 2005, 02:52:49 PM
The problem is that robots will mutate the "unlabled-up" virson , so check that one as well , thanks in advance

Someone please ans:
Quote
*21 'can a pointer followed by a store mutate?
store

well can it?
Title: Arrays other topic
Post by: PurpleYouko on February 23, 2005, 03:01:26 PM
Anything can mutate

The DNA is stored in two parts. The first thing that the program does is to de-tokenize the sysvars and make them into numbers.

The first part of the DNA array is "tipo" (Italian for type)
The second part is "value" (Italian for value  :rolleyes: )

I can't be bothered to check the exact coding for this right now but it goes something like this.

*20 becomes DNA(n).tipo=1 and DNA(n).value=20

The type 1 indicates that this is a pointer to a memory address.

If you leave off the * then tipo wil be 0

if it was *. then the interpretter looks for an alpha-numeric sysvar and tipo becomes 2

When the robot mutates tipo and value are randomized for the particular line of DNA code so that any outcome is possible.

if tipo is 0 then the number after it is just a number.
if tipo is 1 then the number after it represents a pointer to a memory address
if tipo is 2 then the number after it is treated as a sysvar (if one exists for that number)

And so on

 :D  PY  :D
Title: Arrays other topic
Post by: Botsareus on February 23, 2005, 03:25:56 PM
Num what you gave me in the dna viewer looks like:
Quote
cond
  *20
  0
  =
start
  20
  21
  0 'notice all the extra zeros , thats another bug...
  0
  0
  0
  1
  22
  store
  22
  23
  store
  0
  0
  0
  0
stop
-------------- 2
cond
start
  20
  inc
stop
-------------- 3
cond
  *20
  100
  >
start
  0
  *21
  store
stop
-------------- 4
end
and it does not reset after 100 back to 0
and without the "def" stuff it works completly different too ; try it without the def ,the way I wrote it, because: if this code ever will accure naturaly , thats the way it will accure: without the "def"s

P.S.

Quote
.a .apoint store store 'apoint points to a

was an error fixed by:
Quote
.a .apoint store 'apoint points to a
Title: Arrays other topic
Post by: Numsgil on February 23, 2005, 03:27:21 PM
Oh, yeah, sometimes comments aren't commented out, I'm not sure why.

I'll fix it, hold on.
Title: Arrays other topic
Post by: Numsgil on February 23, 2005, 03:29:43 PM
Code: [Select]
def a 20
def apoint 21
def c 22
def cpoint 23

cond
*.a 0 =
start
.a .apoint store store
'apoint points to a
1 .c store
.c .cpoint store
'cpoint points to c
stop

cond
start
.a inc
stop

cond
*.a 100 >
start
0 *.apoint store
stop
end

This works right.
Title: Arrays other topic
Post by: Botsareus on February 23, 2005, 03:32:07 PM
Quote
and without the "def" stuff it works completly different too ; try it without the def ,the way I wrote it, because: if this code ever will accure naturaly , thats the way it will accure: without the "def"s

Quote
The problem is that robots will mutate the "unlabled-up" virson , so check that one as well , thanks in advance

Here it is again , stay with me here , :

Quote
cond
*20
0
=
start
20
21
store '21 is the pointer to memory location 20
1
22
store
22
23
store '23 is the pointer to memory location 22
stop

cond
start
20
inc
stop

cond
*20
100
>
start
0
*21
store
stop

end

one more thing:

Quote
.a .apoint store store 'apoint points to a

I know it works but why do you write store twice , whats the use of that?
Title: Arrays other topic
Post by: Numsgil on February 23, 2005, 03:39:21 PM
If you're having trouble with that bot code, Bots, its 'cause the comments aren't commenting out.

Has anyone ever had success with in-line comments?  It might be that they never worked, and we (atleast Bots and I) keep thinking they do.

The two stores you noticed is my brain collapsing.  Pay no mind to the man behind the curtain.   :rolleyes:
Title: Arrays other topic
Post by: Botsareus on February 23, 2005, 03:47:27 PM
Quote
Has anyone ever had success with in-line comments? It might be that they never worked, and we (atleast Bots and I) keep thinking they do.

:unsure: ok

Now how about making in-line commands actualy work? so robots can (I am repeating again) "naturaly evolve them"

About time eh?

thanks for staying with me so far Num because next we will Tackle:
Quote
*20
*22
add
20
store

and while we will be at it will check sub and squrt and all the rest of them...
 ;)
Title: Arrays other topic
Post by: Numsgil on February 23, 2005, 03:51:43 PM
I'll look at the parsing code for comments.

Note that you can't evolve comments, because comments are stripped from DNA when it's loaded into the program.  Comments just help us humans handle abstract DNA code.

instead of:
*20
*22
add
20
store

you can use the wonderful new 'addstore' command.

Like this:

*22 20 addstore

I think.
Title: Arrays other topic
Post by: PurpleYouko on February 23, 2005, 03:52:47 PM
NOOOOO!  :o

Num is going to beat me to 100 posts  :(

 :ph43r:  PY  :ph43r:
Title: Arrays other topic
Post by: PurpleYouko on February 23, 2005, 03:54:48 PM
Quote
NOOOOO!  :o

Num is going to beat me to 100 posts  :(

 :ph43r:  PY  :ph43r:

Ah Crud. He just did.

 :wacko: PY  :wacko:
Title: Arrays other topic
Post by: Numsgil on February 23, 2005, 03:56:39 PM
Bow before me, pawn!

Mwahahaha!
Title: Arrays other topic
Post by: Botsareus on February 23, 2005, 03:59:31 PM
:huh: But please fix the inlines I was talking about please ;;

Are you saying robots can evolve "addstore" but cant evolve "add" "div"

This "addstore" in my opinion just makes everything more confusing

how about then we add

"divstore"

"substore"

"multstore"

"squrtstore" ' means a ^ b

??

or we just use good old "store" and add "squrt"

??

Ok I know its all confusing but hey I live for danger

 :D Bau  :D

I suggest evolve "add" and "sub" and "squrt" and the rest of it...

I suggest fix the program so my originaly posted dna works...
Title: Arrays other topic
Post by: PurpleYouko on February 23, 2005, 04:01:52 PM
NO!!

Inline comments don't work!

They have to be at the start of a line.

Not sure why but they have never worked.


Quote
The two stores you noticed is my brain collapsing. Pay no mind to the man behind the curtain. 


What that weird little man over there shouting into the megaphone and twiddling knobs and stuff?

 :D  PY  :D
Title: Arrays other topic
Post by: Numsgil on February 23, 2005, 04:02:12 PM
Have you checked out the DNA commands I added in 2.35?

Check the readme.  They're all listed there.

When I said inline comments don't work, I mean inline comments don't work.

That is:

.a .b store 'blah blah comment

doesn't seem to work, but

.a .b store
'blah blah comment

does work.

The DNA all loads and runs correctly.  The comments that are on the same line as DNA code seems to be loaded in as 0's.
Title: Arrays other topic
Post by: Numsgil on February 23, 2005, 04:05:26 PM
And its sqr, not squrt.
Title: Arrays other topic
Post by: Botsareus on February 23, 2005, 04:07:20 PM
Rofl ok I think PY and Num is completly confused , who is talking about "commants" here? I am talking about suggestions to fix the actual prossesing of the program

Some one read what we all wrote please
 :(


OK OK its "sqr" not squrt" , how about we just replase it all with actual signs

Quote
+
-
*
/
^

good one ?
Title: Arrays other topic
Post by: Numsgil on February 23, 2005, 04:10:01 PM
Bots, you said:
Quote
I suggest fix the program so my originaly posted dna works...

The reason your posted code didn't work is cause the comments were being parsed when they shouldn't

Just post your comments on spereate lines and they'll work.
Title: Arrays other topic
Post by: PurpleYouko on February 23, 2005, 04:10:35 PM
Quote
Are you saying robots can evolve "addstore" but cant evolve "add" "div"


No he isn't saying that at all.

A robot can evolve [span style=\'font-size:14pt;line-height:100%\']ANY[/span] command at all. It will almost alway just appear as a number though.

Example:

A robot evolves a .mrepro command where .repro used to be.
Where previously it had been

50 .repro store

it will now be

50 301 store

Make sense?

All the mutation code does is to randomize a new number. ANY number. If the sysvar has a numeric equivalent then it CAN be mutated.

 :D  PY  :D
Title: Arrays other topic
Post by: Numsgil on February 23, 2005, 04:10:47 PM
sqr has no sign for it, except that funny radical symbol, so how can we use a symbol for it in the DNA?

the power function uses ^ though.
Title: Arrays other topic
Post by: Botsareus on February 23, 2005, 04:18:13 PM
Thats how its called , its called the "power function" so we can use somthing like "pow" or just change everything into the actual symbols like:
+ - * / ^

anyway I am talking about stuff like:
add sub mult div pow

I WANT IT TO MUTATE IN THE PROGRAM , BUT I AM NOT SURE IF IT WORKS CORRECTLY YET BECAUSE EVEN:

cond
*20
0
=
start
20
21
store '21 is the pointer to memory location 20
store
1
22
store
22
23
store '23 is the pointer to memory location 22
stop

cond
start
20
inc
stop

cond
*20
100
>
start
0
*21
store
stop

end

NOTICE THIS IS THE VIRSION WITHOUT "DEF" BECAUSE THATS HOW IT WILL LOOK LIKE IF IT ACCURES NATURALY (MUTATES) WILL LOOK LIKE

DOES -*- NOT -*- WOOOOORK!!!!!!!!!
HEEEELLLLLPPPPP!!!!!!!

DONT REWRITE IT WITH DEFS AGAIN PLEASE!!!!!!!

THE VIRSION WITH "DEF" NUM GAVE ME WORKS GOOD , THATS NOT THE POINT
Title: Arrays other topic
Post by: Numsgil on February 23, 2005, 04:20:17 PM
Alright Bots, listen very closely.

Remove the comments from your code.  Put them on their own lines.  Either way, pick one and do it.  Your code will now work again.

In case there's confusion over what comments are, these are the comments in your code that are screwing it up:

Quote
'21 is the pointer to memory location 20

and

Quote
'23 is the pointer to memory location 22
Title: Arrays other topic
Post by: Botsareus on February 23, 2005, 04:22:57 PM
OMFG ^%$^^%$

SORRY NUM I FORGOT THERE ARE STILL COMMENTS IN MY ORIGINAL CODE , Checking now...

LOL , YES IT WORKS MOVING ON TO USING +ADD+ , checking now...

IT WORKS , FINALY

TY TY TY
Title: Arrays other topic
Post by: Numsgil on February 23, 2005, 04:25:56 PM
:D It's all good Bots, just making sure we're speaking the same language.
Title: Arrays other topic
Post by: Numsgil on February 25, 2005, 06:45:16 AM
Just finished up coding the parser so that it will allow the following crazy coding styles:

Code: [Select]
cond                  5                   6 >
start                              'do lotsa crazy stuff
5              6                 store
stop
cond 'this is more normal
start
stop 'pretty cool huh?
end
Title: Arrays other topic
Post by: Botsareus on February 25, 2005, 11:53:40 AM
rofl , Num whats the use of that?
Title: Arrays other topic
Post by: PurpleYouko on February 25, 2005, 11:57:26 AM
It helps a lot!

Haven't you ever noticed that if you accidentally leave 2 spaces between stuff in a line of DNA code, it just gives a zero instead of the rest of the line?

Also this allows us to put comments directly after code in a line of DNA.

Sounds like a great idea to me.

 :D  PY  :D
Title: Arrays other topic
Post by: Botsareus on February 25, 2005, 12:01:58 PM
no its just
Quote
cond 'this is more normal
start
stop

confused me at first , its all empty

I gess thats what happens when a new gene is added to the Dna
Title: Arrays other topic
Post by: Numsgil on February 25, 2005, 12:02:26 PM
If you noticed, Bots, I put comments after a line of commands as well.  That's what your problem was before.  I fixed it!

this is a coding style I could see happen:

Code: [Select]
cond
start
5 2 store   'explain this comment
5 8 mult    'explain this one too
6 5 add     'wow, and this one
div
stop

You can use spaces to help allign all the text.
Title: Arrays other topic
Post by: Botsareus on February 25, 2005, 12:04:15 PM
:) THANKS NUM  :)