Code center > Darwinbots3

Bot testbed

(1/13) > >>

Numsgil:
Okay, at long last, I have completed the first iteration of my bot testbed.

What is it?
A simulation with a single bot in it.  This is a very simple base I'm going to use to build more features on top of.

The single bot is a star shaped polygon.  It has "spindles" arranged around its nucleus.  The bot can control the length of these spindles using its DNA.

So far the only features implemented are the spindles.  It can't reproduce or move or do anything else but change its shape.

Overview
It's multithreaded (to a point) with 3 core threads:

[*] UI - The UI thread handles button clicks and the like.
[*] Simulation - The simulation thread handles running the simulation, running the bot's DNA, etc.
[*] Render - The render thread is in charge of drawing the graphics.
[/list]

Importantly these three threads are independent.  The simulation can run at 10000 cycles/sec and the graphics can run at 5 FPS.  Or the simulation could run at 10 cycles/sec and the graphics could run at 60 FPS.

If one thread crashes, it should largely not cause problems for the other threads.  The simulation thread can continue running in the background if the render thread crashes (as long as it's not frame locked), and vice versa.

Read the DNA help
The DNA langauge that Darwinbots3 uses ("Sunweaver") is similar but distinct from the language in Darwinbots2.  Make sure you read through the Sunweaver manual under the help menu to understand it.  If you want to suggest changes, the raw text for it is here.  Just send me any changes you make to that file.

Help me out
My mission for you guys, if you're willing, is to mess around with this testbed to create bots that do cool things.  Specifically I'd like some bots that move in a way that looks like they're swimming, because I want to try adding fluid to this testbed next, and I want to see if a swimming motion can produce forward motion.

Also, I want to make sure that there aren't any bugs.  If you find crashing bugs, you will get an exception dialog box.  You can see what it looks like by forcing crashes (look under the 'debug' menu).  Copy+paste the exception dialog text and post it here and I can try and reproduce the issue on my side.  Unless you know why it crashed, of course, and it's not a bug. 

Or if you find the interface weird, or have just general comments, please let me know.

What's next
I'm going to start experimenting with adding fluid to this simple testbed.  I'd like to verify that it's possible for bots to swim by manipulating their shapes.

(Edit: Nov 2017.  New version uploaded)

spike43884:
Just partway through reading up that sunweaver manual file... I came up with a few ideas for changes, it'd be pretty sweet if you were able to implement them (if they haven't been yet)

One nice thing would be to include tan in mathematical operators (we currently only have sine and cosine), a 'proportional to' operator, and perhaps some sort of support for percentiles? I'd quite like to also see factorials, perhaps shortcuts for some constants (like pi, the golden ratio, eulers constant and so forth) - Some distinguishing between vector and scalar products would be quite useful too I do think. A couple of probability functions in DNA so we don't have to rely on total randomness...

Finally, and deviating from the maths side of things, a "return to line __" function would be quite nice to force part of the DNA to rerun...

Numsgil:

--- Quote from: spike43884 on April 03, 2017, 02:08:07 PM ---One nice thing would be to include tan in mathematical operators (we currently only have sine and cosine), a 'proportional to' operator, and perhaps some sort of support for percentiles? I'd quite like to also see factorials... A couple of probability functions in DNA so we don't have to rely on total randomness.

--- End quote ---

On purpose I've tried to leave the underlying language with relatively few commands, so it's easier to learn and understand.  It's not meant to be fully featured.  Note you can write codules and set up macros with them, so you have a lot of power to make your own commands and use them the same as if they were natively supported.

So for instance, naively you could define a tangent function as:

(edit: Oops, language is still new to me too.  I've modified this to be right, hopefully).

--- Code: ---{tan dup cos swap sin div }
macro tan @tan

--- End code ---

I say naively because you're just doing integer division, and not using the full range of the integer stack, so the error in the calculation here would be quite large.  Which brings me to point two:


--- Quote ---perhaps shortcuts for some constants (like pi, the golden ratio, eulers constant and so forth) - Some distinguishing between vector and scalar products would be quite useful too I do think.
--- End quote ---

Sunweaver, like the DNA in Darwinbots2, is entirely integer driven.  Pi doesn't make sense in the language, unless you want it to just be 3 :)  You could arbitrarily decide to store as many digits as you could, but that still might not be appropriate depending on what you're trying to do.  For instance, some sort of numerical calculation involving pi might need 100s of digits.  Or it might be fine approximating it as 3.  There isn't really a one size fits all here.  Note that sin and cos, for instance, don't use radians they use degrees (well, degrees / 3). 

Likewise there's nothing inherently vector or not about anything in the language.  Integers get pushed to the stack, and integers get popped from the stack, and integers get written to memory.  How anything is interpreted in between is a question for the programmer.


--- Quote ---Finally, and deviating from the maths side of things, a "return to line __" function would be quite nice to force part of the DNA to rerun...

--- End quote ---

This is another case where the restrictions are on purpose.  Like in DB2, the entire DNA gets executed, start to end, every cycle.  In order to prevent infinite loops from causing the program to hang, infinite loops are simply impossible.  If I supported gotos, I can't guarantee that a given DNA program would terminate.  As a compromise note that DNA supports a finite looping mechanism.  So you can basically run a loop over some code 100 times, for instance.  But even here, I'm not sure if this is too generous.  It's possible to make some really gross nested loops that can eat all the CPU cycles and slow the simulation to a crawl.  But I think the loops, along with the branching mechanisms, might be an important tool for evolution so I wanted to include them.

Shadowgod2:
Primitive it is... i with i could see the memory similarly to db2 but i do have an idea on a swimmer, just after i figure out how the dna works more hopefully i will get a working swimmer in a few days. Looks good.

Numsgil:

--- Quote from: Shadowgod2 on April 04, 2017, 02:09:41 PM ---i with i could see the memory similarly to db2

--- End quote ---

Yes, on my todo list. :/  If you're really desperate you could save the simulation and inspect the memory in the save file.  The saves are just Lua scripts, and fairly readable.

Navigation

[0] Message Index

[#] Next page

Go to full version