Darwinbots Forum

General => Off Topic => Topic started by: EnderCrypt on December 13, 2015, 08:29:02 PM

Title: making my own DB fan-version
Post by: EnderCrypt on December 13, 2015, 08:29:02 PM
Hello, first of all, i wasnt sure where i wanted to put this thread, so.. i apologize if putting it in the off-topic was... unfitting, anyways my name is Magnus and since i first found DarwinBots, its always inspired me, ALOT, inspired me in many fields, such as evolution, coding, ai. and while these things has always intrested me, this awesome application really made me want these things more (ps. writting this late midnight so i apologize if i write a bit strangely)

i have always considered making my own version of Darwinbots a personal goal in the field of programming, and recently i was lucky to get into a really good java course in my country, and while i did have previous programming experience in many languages (including java) this really helped and.. yeah im kinda feeling like im actually getting close to getting enough skill to actually make my own version of Darwinbots, though.. i doubt its gonna get even close to as awesome as the original, now, i actually tried making a Darwinbots fan-version in the past year or so.. 3 times
1st  time.. chatastrophic failure (forgot which coding language)
2th time.. chatastrophic failure (lua)
3th time.. (java) semi functional.. um.. random dna.. which.. granted, is basically a chatastrophic failurure xD
a few days ago, i made my fourth attempt (in java) and.. well i managed to after alot of work get it to run "cond start 5 .up store stop"
and my position variable outputted
Position[x=5.0,y=0.0]
Position[x=12.5,y=0.0]
Position[x=21.25,y=0.0]
etc etc which made me very happy to finally have a (even though basic) working version :D
and, i'd absolutley love occasional help with technical details of my project then and then, at the moment, im trying to think on how to code the eye similarly to how Darwinbots does it, it be nice if someone could explain to me how Darwinbots calculates it, thanks :)

also ,i did find the source code link (http://wiki.darwinbots.com/index.php?title=Source_Code) in the forum here, however.. i wasnt able to.. um.. navigate it to find the code i was looking for, some pointers would be great? ^_^

have a nice day everyone

~Magnus (EnderCrypt)
Title: Re: making my own DB fan-version
Post by: MysticalDumpling on December 14, 2015, 08:17:10 PM
! Sounds interesting. However, starting with a blank slate, you could try features unfeasible in DB while simplifying others. If you are a sadist, bots with Befunge-like code would be interesting.
Title: Re: making my own DB fan-version
Post by: Shadowgod2 on December 15, 2015, 02:01:44 AM
cool i kinda wanted to make a db type program myself but almost no programming experience and absolutely no time to do so. but what i have learned is keep things organized. once it starts getting messy you may as well start over just to understand the code again(java does make it relatively easy to do so). i may be able to help on how the eyes work but the actual calculations... well i have no clue. good luck
Title: Re: making my own DB fan-version
Post by: EnderCrypt on December 15, 2015, 08:17:18 AM
im not very good at keeping codes organized, however i am doing my best at keeping javadoc's for every method, also i am considering putting this on github as open source


but yeah, the code is messy and not as stable as i wished, at the moment im just trying to get things running, i worked very hard on getting things just up and running normally

! Sounds interesting. However, starting with a blank slate, you could try features unfeasible in DB while simplifying others. If you are a sadist, bots with Befunge-like code would be interesting.

MysticalDumpling, could you tell me more about these ideas you got, i am very intrested in hearing about it :)
Title: Re: making my own DB fan-version
Post by: MysticalDumpling on December 18, 2015, 04:01:54 PM
You could disable shots, only allow ties- forcing MB formations. You could make DNA blocks of code, with a "master gene" that regulates their activation and combinations, etc. The sky (if you choose to make it) is your limit, lol.
Title: Re: making my own DB fan-version
Post by: EnderCrypt on December 19, 2015, 07:53:49 PM
You could disable shots, only allow ties- forcing MB formations. You could make DNA blocks of code, with a "master gene" that regulates their activation and combinations, etc. The sky (if you choose to make it) is your limit, lol.

intresting, could you elaborate further on your idea? a "master gene"?
Title: Re: making my own DB fan-version
Post by: MysticalDumpling on December 20, 2015, 12:06:28 PM
In this situation, the DNA has 2 parts, the reference part and the master part. The reference is just blocks of code. The master genes regulate which section of the reference and what combinations are activated. It is a different type of abstraction.
Title: Re: making my own DB fan-version
Post by: EnderCrypt on December 20, 2015, 12:09:54 PM
In this situation, the DNA has 2 parts, the reference part and the master part. The reference is just blocks of code. The master genes regulate which section of the reference and what combinations are activated. It is a different type of abstraction.

could you give a.. theoretical example of how this DB dna code would look like? :)
Title: Re: making my own DB fan-version
Post by: MysticalDumpling on December 22, 2015, 03:55:01 PM
Obv stripped down.
part 1
if x
a
if !x & y
b
if x &y
c

a- meh store
b- blah inc
c- generic phrase dec
Title: Re: making my own DB fan-version
Post by: EnderCrypt on December 22, 2015, 06:41:17 PM
Obv stripped down.
part 1
if x
a
if !x & y
b
if x &y
c

a- meh store
b- blah inc
c- generic phrase dec

so basically nested cond-itions? :) intresting idea, and how would this look in DB code?

cond
condition 1
start
statement 1
cond
condition 2
start
statement 2
stop
stop
or something
Title: Re: making my own DB fan-version
Post by: MysticalDumpling on December 23, 2015, 04:07:24 PM
:P It would be confusing. Ill give it a run after Christmas.
Title: Re: making my own DB fan-version
Post by: EnderCrypt on December 27, 2015, 05:30:13 PM
:P It would be confusing. Ill give it a run after Christmas.

:D yes
edit: merry christmass :)

on another note, after carefull consideration (not really, it was pretty easy to change my mind), i have decided to make the code into a JAVA library instead and upload the jar and source to github for anyone to use, by doing this, anyone should be able to quickly create their own java darwinbots program,. ofcourse due to the extreme complexity and awesomeness of darwinbots, this (like.. all projects) will take alot of time, but i'll do my best and when i feel that its ready, i'll definetly share the link here

but yeah, by using this library, my hope is to make it easy for people to make a darwinbots-like software/game, though well see if i can manage this succesfully! :)

i'll also try make a real darwinbot clone/fan version by using my own library like initially planned in this post :)
Title: Re: making my own DB fan-version
Post by: EnderCrypt on December 28, 2015, 08:02:26 PM
question: according to http://wiki.darwinbots.com/w/Execution_Flag (http://wiki.darwinbots.com/w/Execution_Flag) no type of store command is allowed to execute whitin
COND ... START
can store commands still exist and mutate into this position?

edit: also, when executing an operator like for example.. store (whitin the COND ... START) will it still take 2 values from the stack and then do nothing? thank you

thank you
Title: Re: making my own DB fan-version
Post by: Shadowgod2 on December 29, 2015, 12:08:33 AM
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.
Title: Re: making my own DB fan-version
Post by: EnderCrypt on December 29, 2015, 12:57:23 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?
Title: Re: making my own DB fan-version
Post by: Numsgil 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 (http://svn.darwinbots.com/Darwinbots2/trunk/Darwinbots2/DNA.bas).

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 (http://svn.darwinbots.com/Darwinbots3/Trunk/Modules/Sunweaver/Source/Commands/) to get an idea about the commands.
Title: Re: making my own DB fan-version
Post by: EnderCrypt 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
Title: Re: making my own DB fan-version
Post by: Numsgil 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 (http://wiki.darwinbots.com/w/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.
Title: Re: making my own DB fan-version
Post by: EnderCrypt 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 :)
Title: Re: making my own DB fan-version
Post by: EnderCrypt 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?
Title: Re: making my own DB fan-version
Post by: Numsgil 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 :)
Title: Re: making my own DB fan-version
Post by: EnderCrypt 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
Title: Re: making my own DB fan-version
Post by: Numsgil 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 (http://www.davidbaumgold.com/tutorials/wine-mac/).  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.
Title: Re: making my own DB fan-version
Post by: EnderCrypt 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 (http://www.davidbaumgold.com/tutorials/wine-mac/).  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:
(http://i.imgur.com/Jt7paJZ.png)

and then it crashes, and i get this message:
(http://i.imgur.com/pLUgL9i.png)

(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...
Title: Re: making my own DB fan-version
Post by: Numsgil 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.
Title: Re: making my own DB fan-version
Post by: Botsareus 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.
Title: Re: making my own DB fan-version
Post by: EnderCrypt 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 :)
Title: Re: making my own DB fan-version
Post by: Botsareus on January 02, 2016, 11:32:27 AM
Yes. Should work.
Title: Re: making my own DB fan-version
Post by: EnderCrypt on January 02, 2016, 04:24:37 PM
how do things like .mass work?  its a combination of body, waste? am i missing anything
Title: Re: making my own DB fan-version
Post by: Botsareus on January 02, 2016, 05:05:41 PM
You will find that under CalcMass() in physics.bas
Title: Re: making my own DB fan-version
Post by: EnderCrypt on October 24, 2016, 03:39:20 PM
its been quite awhile since i posted here (over 120 days according to a warning)
 
but i failed with the initial db version that i was making when i started this thread.. luckily i started a new try recently, and this one.. well i actually managed to make some goood progress

repository: https://github.com/EnderCrypt/JDarwin (https://github.com/EnderCrypt/JDarwin)

i managed to allow movement and integrate some basic sysvars, quite fun so far :D

(https://media.giphy.com/media/l0MYJx6Q1bBlxteuY/giphy.gif)