Author Topic: making my own DB fan-version  (Read 1412 times)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7689
    • View Profile
Re: making my own DB fan-version
« Reply #15 on: December 29, 2015, 01:27:43 PM »
yes store commands can and often times do evolve in the cond start section like the sim i am currently running, and yes the values on the stack do nothing. either they disappear or are untouched idk. however values can gene hop and be executable in later genes(an unused value in gene 1 can be executable in gene 5 for example) this could ably to the cond start values being executable in the start stop section too.

values can genehop?? wait, the stack persists through multiple genes? is there a COND ... START stack persisting through all genes COND ... START and so on?

The cond ... start ... stop architecture is a legacy artifact of how the DNA used to work.  Any more, there's an integer stack, a boolean (conditions) stack, and operators that do things to those stacks.  I think start ANDs together all the values on the boolean stack.  That's it, really.  The inc, dec, and store commands will only actually store values if the top value on the boolean stack is true.  I think cond basically clears out the stacks.  Which makes drawing neat lines between genes more difficult.  But then, that's kind of true of real life too :)

The actual details you'll have to get from the source code for DNA execution.

There's also a C# sort-of version (it's got a lot of changes that aren't compatible, and features the old DNA doesn't have like limited looping ability and function calls) of the DNA that I'm using for a newer version I'm working on.  It's not Java, but it might give you some ideas, and Java and C# are very close to each other syntactically.  You might want to start looking through the source code here to get an idea about the commands.

Offline EnderCrypt

  • Bot Builder
  • **
  • Posts: 58
    • View Profile
Re: making my own DB fan-version
« Reply #16 on: December 29, 2015, 01:44:26 PM »
wow, theres so incredibly much things i dont know, and the fact that my windows is basically broken and im stuck on mac (i hate mac's) really aint helping..

okay so, what i understood so far
  • things can only get stored on memory when the stack is empty/has true on top[/lix]
    • the cond operator is the only operator that resets the stack? does the start operator not do this?

    wait.. is the integer stack.. an integer stack, like.. cant you put decimal'ed values into stack, i know the memory doesent allow decimals, but.. the stack? also, hows does sin and cos operate?

    also, thank you for the source, i had it very difficult trying to navigate the source links from the wiki :)

    hmm, wow, i need to learn some VB some day
WARNING: Found unknown Windows version: Windows 7

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7689
    • View Profile
Re: making my own DB fan-version
« Reply #17 on: December 29, 2015, 02:40:26 PM »
things can only get stored on memory when the stack is empty/has true on top

An empty boolean stack is treated like 'true'.  An empty integer stack is treated like '0'.  So yes, things will only get stored to memory when the boolean stack is either empty or has true on top.

Quote
the cond operator is the only operator that resets the stack?

I think so.

Quote
does the start operator not do this?

No.  The start operator ANDs together all the values on the boolean stack.  But it doesn't touch the integer stack, I don't think.  It's been a while so I might not be the best resource on this anymore.

The stop operator basically skips executing anything until the next cond statement is found.  This basically lets you put "junk DNA" between genes if you feel so inclined.

Note that you can still use the cond...start...stop format.  It will just sort of magically work like you would expect.  But the underlying DNA language is actually quite a bit more flexible.

Quote
wait.. is the integer stack.. an integer stack, like.. cant you put decimal'ed values into stack, i know the memory doesent allow decimals, but.. the stack?

Commands know which stacks to operate on so they don't get confused.  Basically if you expect something to return true/false it will get put on the boolean stack.  If you expect something to return a number, it goes on the integer stack.

Quote
also, hows does sin and cos operate?

The wiki entry on cos is up to date actually.  The input is in radians * 200 (so basically between 0 and 628), and the output is the normal value between -1 and 1, but multiplied by 32000.

Offline EnderCrypt

  • Bot Builder
  • **
  • Posts: 58
    • View Profile
Re: making my own DB fan-version
« Reply #18 on: December 29, 2015, 05:02:22 PM »
thank you for your reply, it helped alot :)

does your code, when given a strong of dna code, split each gene into its own object? im thinking of doing this

also, what did you mean by the fact that the START operator AND's the boolean stack ? could you further try explain? thank you :)
WARNING: Found unknown Windows version: Windows 7

Offline EnderCrypt

  • Bot Builder
  • **
  • Posts: 58
    • View Profile
Re: making my own DB fan-version
« Reply #19 on: December 30, 2015, 02:57:59 PM »
why does .setaim accept a value between 0 to 1256, and also, is .setaim prioritized over things like .aimdx and .aimsx?
WARNING: Found unknown Windows version: Windows 7

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7689
    • View Profile
Re: making my own DB fan-version
« Reply #20 on: December 30, 2015, 05:09:49 PM »
does your code, when given a strong of dna code, split each gene into its own object? im thinking of doing this

In both versions, the final result of the DNA parsing is an ordered list of base pairs.  It doesn't try to break things apart in to genes except when it reparses it back for users to look at.

Quote
also, what did you mean by the fact that the START operator AND's the boolean stack ? could you further try explain? thank you :)

suppose you have this gene:

Code: [Select]
cond
1 2 >
3 4 < and
start
5 .up store
stop

The gene wouldn't fire, since 1 is not greater than 2.  The two conditions were ANDed together, so the gene is basically if 1 > 2 and 3 < 4 then store 5 in up.

For legacy reasons, if not explicitly stated, an implicit AND is assumed.  The above will function identically to this:

Code: [Select]
cond
1 2 >
3 4 <
start
5 .up store
stop

In order to get this behavior, when a start is encountered, if there's more than one value on the boolean stack they're all combined together with an AND.

Quote
why does .setaim accept a value between 0 to 1256

A complete circle is 2 pi radians.  Multiply that by 400 and you get 1256, which is sort of close to 1000 (which is a nice round number) and can be evenly divided in to 8 slices.  So a full circle is 1256 units, and the number was chosen kind of arbitrarily.  There are better numbers to choose (1080 is also close to 1000, maps to degrees, and has better prime factors (2, 2, 2, 3, 3, 3, 5) ), but for legacy reasons we're stuck with it.

You might double check my answer about sine/cosine.  I'd expect them to use the same same scale, so I might have gotten it wrong.

Quote
and also, is .setaim prioritized over things like .aimdx and .aimsx?

I think so but I'm not sure actually.  Try it and see :)

Offline EnderCrypt

  • Bot Builder
  • **
  • Posts: 58
    • View Profile
Re: making my own DB fan-version
« Reply #21 on: December 30, 2015, 08:36:06 PM »
Quote from: Numsgil
In order to get this behavior, when a start is encountered, if there's more than one value on the boolean stack they're all combined together with an AND.
ah, so basically.. the gene executes aslong as there are no false in the boolean stack (correct me if im wrong)

Quote from: Numsgil
A complete circle is 2 pi radians.  Multiply that by 400 and you get 1256, which is sort of close to 1000 (which is a nice round number) and can be evenly divided in to 8 slices.  So a full circle is 1256 units, and the number was chosen kind of arbitrarily.  There are better numbers to choose (1080 is also close to 1000, maps to degrees, and has better prime factors (2, 2, 2, 3, 3, 3, 5) ), but for legacy reasons we're stuck with it.

wow, you been thinking about this alot! :D

hmm, im gonna try go for the 1080, also, could you explain the prime factor thing? i dont really understand the point of it, except that multiplying them gets you 1080, also, what stops us from multiplying pi with (1000/pi) which would make a circle be 0 to 1000?


also, speaking of what i said:
Quote from: endercrypt
and also, is .setaim prioritized over things

does the sysvar list on darwinbots have some sort of .. priority of execution? because at the moment i got a randomly ordered list of all sysvars, and during each cycle all the sysvars get re-init (dont know what to call it, but i think you get what i mean, for example .robage, always get set to the robots age, before gene execution ) and after that it executes some code, for all sysvars, again randomly because the randomly ordered list

also, just realised a thing while writting the quote.. did i mess up by not making my e (first letter) in endercrypt, capital, i see you got your first letter as capital... but i dont.. great

Quote from: Numsgil
Try it and see :)
that is so tempting! but yeah, sadly.. im stuck on mac, and i dont think that will change.. for a long time.. so yeah, the only option i got to re-live darwinbots is playing at some other computer or.. make my own version, and making my own version is kinda fun + with your/administrators permissions, i'd love to open source my code at github (as approaches completion), problably wont get even close to as awesome as the real version of darwinbots which, for me has always stood as.. the holy grail for me, in a programming perspective :D i mean, darwinbots is the program that made me intrested in evolution and artificial intelligence ^^

edit:

http://wiki.darwinbots.com/w/Anglecmp
it says "Calculates the shortest angle between the two angles given. Angles in DarwinBots are expressed in radians multiplied by 200."
so... didnt we previously say that radians in DB was multiplied by 400?

also could you give an example of how to use this operator, as i never used it myself
« Last Edit: December 31, 2015, 11:04:24 AM by endercrypt »
WARNING: Found unknown Windows version: Windows 7

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7689
    • View Profile
Re: making my own DB fan-version
« Reply #22 on: December 31, 2015, 09:14:05 PM »
Quote from: Numsgil
In order to get this behavior, when a start is encountered, if there's more than one value on the boolean stack they're all combined together with an AND.
ah, so basically.. the gene executes aslong as there are no false in the boolean stack (correct me if im wrong)
Yeah, basically.

Quote
hmm, im gonna try go for the 1080, also, could you explain the prime factor thing? i dont really understand the point of it, except that multiplying them gets you 1080, also, what stops us from multiplying pi with (1000/pi) which would make a circle be 0 to 1000?

The more prime factors you have, the more ways you can evenly divide the number in to equal parts.  For instance, say a full circle is 1000 units.  Say you want to turn 120 degrees (basically a third of a circle).  You'd have 333.33333333 units, which you'll have to truncate to 333, since it's all integers.  It'll be very difficult to have exactly three equal rotations then.  That may or may not be a problem, of course, depending on your goals.  I'd say you either want lots and lots of prime factors, or none and have it be a prime number.  The prime number would necessarily add some "fuzz" to integer angular calculations, which could be desirable.

Quote
does the sysvar list on darwinbots have some sort of .. priority of execution?

Not really.  There's the order things are run in, but I'm not sure that has any particle rhyme or reason to it.

Quote
also, just realised a thing while writting the quote.. did i mess up by not making my e (first letter) in endercrypt, capital, i see you got your first letter as capital... but i dont.. great

I can fix it if you care.

Quote
im stuck on mac

Try running it under Wine.  I've had success doing that under linux.

There's also virtual machine installs if you want to play around with that.  Depends how tech savvy you feel.

Offline EnderCrypt

  • Bot Builder
  • **
  • Posts: 58
    • View Profile
Re: making my own DB fan-version
« Reply #23 on: December 31, 2015, 11:38:17 PM »
i'll definetly be going for 1080 yeah ^^

Quote
Quote
also, just realised a thing while writting the quote.. did i mess up by not making my e (first letter) in endercrypt, capital, i see you got your first letter as capital... but i dont.. great

I can fix it if you care.

ah, well.. its not really important, but if its not too much of a hassle, i definetly wouldnt mind being named properly as: "EnderCrypt"


Quote
Quote
im stuck on mac

Try running it under Wine.  I've had success doing that under linux.

There's also virtual machine installs if you want to play around with that.  Depends how tech savvy you feel.

i think i already got wine under mac here, lets see..
ah, here we go: the moment i press "start new" simulation i get:


and then it crashes, and i get this message:


(after closing it, darwinbots re-appers, but no buttons work, and i had to just close it)

now, according to the wine forum, your not suppose to give admin to files under wine because of security risks or something, im not sure, but yeah, im not so good with macs, but i definetly think i'd be able to get a virtual machine up with some googling.. hmm.. dont have a windows cd though...
WARNING: Found unknown Windows version: Windows 7

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7689
    • View Profile
Re: making my own DB fan-version
« Reply #24 on: January 01, 2016, 02:06:46 PM »
It looks like a program crash.  That is, something independent of the fact that it's running under Wine.  Admin here I think means Darwinbots admin, ie: the guy currently fixing things.  You can look at the files it wants to send, there's nothing in there really interesting from a security perspective.  It's just a save of the Darwinbots sim and some of the settings.

If you create a new thread in the bugs and fixes forum with the attached settings that's a good way to have someone maybe look at it.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
    • DJ Paul Kononov
Re: making my own DB fan-version
« Reply #25 on: January 02, 2016, 10:34:34 AM »
Some quick notes here:

Quote from: Numsgil
The cond ... start ... stop architecture is a legacy artifact of how the DNA used to work.

Well, it is still kinda used for stuff like virus and gene deletion. So for pure ALife like Darwinbots it will be wise to keep such things.

Quote from: EnderCrypt

http://wiki.darwinbots.com/w/Anglecmp
it says "Calculates the shortest angle between the two angles given. Angles in DarwinBots are expressed in radians multiplied by 200."
so... didnt we previously say that radians in DB was multiplied by 400?

also could you give an example of how to use this operator, as i never used it myself

So if you google "how much is one radian" and you put in Pi for radian you get 180 degrees.
So two radians is the full circle or 360 degrees or 6.28~. If you multiply 6.28 by 200 you will get 1256 which is what db uses.

Now the difference between to angles is more interesting then taking the absolute value of subtracting one angle from another because like on a clock if you take 12:00 and subtract that from 1:00 you will not get 11:00 back but you will get 1:00.

Offline EnderCrypt

  • Bot Builder
  • **
  • Posts: 58
    • View Profile
Re: making my own DB fan-version
« Reply #26 on: January 02, 2016, 11:18:51 AM »
ah, i think i got it :)
so it basically just returns the fastest way to turn into one direction, man thats usefull, i think i got a code somewhere that does it, so i can just port it over to java

would something like this be a working code?

*.aim 500 500 angle anglecmp .aimdx store

would that turn towards point 500,500 on the map?

ps. thank you Numsgil for correcting the capitalization on my username :)
WARNING: Found unknown Windows version: Windows 7

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
    • DJ Paul Kononov
Re: making my own DB fan-version
« Reply #27 on: January 02, 2016, 11:32:27 AM »
Yes. Should work.

Offline EnderCrypt

  • Bot Builder
  • **
  • Posts: 58
    • View Profile
Re: making my own DB fan-version
« Reply #28 on: January 02, 2016, 04:24:37 PM »
how do things like .mass work?  its a combination of body, waste? am i missing anything
WARNING: Found unknown Windows version: Windows 7

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
    • DJ Paul Kononov
Re: making my own DB fan-version
« Reply #29 on: January 02, 2016, 05:05:41 PM »
You will find that under CalcMass() in physics.bas