Darwinbots Forum

Code center => Darwinbots Program Source Code => Topic started by: Tj3 on February 21, 2011, 06:00:27 PM

Title: How to help with darwinbots 3 development?
Post by: Tj3 on February 21, 2011, 06:00:27 PM
I've been really excited for DB3, and all the new features, and would like to contribute to the project. I know C#, and have experience using XNA (We are using XNA, right?). So how exactly can I help with it? Especially since development seems a bit slow, and I think I could probably get some stuff done on it. I've coded a few C# XNA 2d physics engines, and done a bunch of other stuff, so I might even be able to dig out one of my physics libraries, or just help code a new one. So, yeah......
Title: Re: How to help with darwinbots 3 development?
Post by: Shasta on February 21, 2011, 10:55:03 PM
Most of the current work is very heavy on math and physics, but Numsgil has posted some tasks on Mantis that are available for people to work on and shouldn't be too hard.

Mantis Link (http://www.darwinbots.com/Mantis/)

You will need Subversion (SVN) to get the code checked out. This wiki page  (http://www.darwinbots.com/WikiManual/index.php/Darwinbots_3)will help you get everything set up.
Title: Re: How to help with darwinbots 3 development?
Post by: Numsgil on February 21, 2011, 11:40:10 PM
Yeah, we're using XNA (actually, it's pluggable with other technologies if we so desire, but XNA is the main one).  If you have XNA experience, does that mean you have HLSL experience (ie: shaders)?  The current graphics code is languishing because it just takes more time to work on it than I have.  If someone can own it and just make it do what I want, that would be fantastic.

Basically it's a vector graphics library that uses pixel shaders to draw vector graphics.  That way we get the hardware acceleration of shaders and the anti-aliased and zooming properties of vector graphics.  I've got the shader basically working (it can draw circles and squares), but in terms of being feature complete and actually usuable, it's not there yet.  The shader stuff left to do isn't terrible if you understand shaders.  And also the shaders are more complex than I'd like (currently using SM3 I think), so if we can pare down the instruction count that would be good, too.

The high level interface is also terrible.  And the application I use to test it (the idea being something simple ala MSPaint but for vector graphics) is also barely functional.

If any of that sounds interesting, that would help me out a lot.

Graphics and physics are holding up most everything else, and I don't have a super great idea of how I want physics to work yet, so it's hard to farm tasks out from that.
Title: Re: How to help with darwinbots 3 development?
Post by: Numsgil on February 21, 2011, 11:49:10 PM
Oh, also you'll need to get the code and get it up and working.  This page on the wiki (http://www.darwinbots.com/WikiManual/index.php/Darwinbots_3) tells you how to get started.  If you successfully download the source, there's also a lot of text files in different directories that talk about what's going on.  Basically, the program is divided into modules, and at present they're fairly separate and independent, since I don't have a main EXE just yet.  Look for *.sln files.  These are the main points-of-entry into the different modules.  Blacklight.XNA.sln would be the one for graphics.
Title: Re: How to help with darwinbots 3 development?
Post by: Tj3 on February 21, 2011, 11:56:59 PM
I haven't used HLSL that much, so I don't know how much of that I could work on. Any other graphics-related stuff I could do (Like in the C# code, etc.) If you decide on how the physics will work, I have some experience with that, and have some ideas. I've also recently been reading a lot on Artificial Life, Genetic Algorithms, and stuff like that, so I might be able to help with the DNA / evolution side of the program. I'll look through the code and see if there's anything I can do tonight, and try to get some stuff done on it.  I have off of school for a week this week, so I'll probably be able to figure out some of the shader stuff, and other things.  :)
Title: Re: How to help with darwinbots 3 development?
Post by: Tj3 on February 22, 2011, 12:00:22 AM
Also, how will Internet Mode work in DB3? How did it even work exactly in DB2? I didn't do too much with it, mostly because it didn't work too well. I had some ideas for that in DB3 also. Will that even exist in DB3, and is it being done yet? Because when I finish some shaders stuff, I might look at that if possible. How would it work, though: Central Server, and clients connect to see / introduce bots; Clients connect to each other, or something else? Well, that's probably gonna be for after the program "works", since before then... Kinda useless. Anyway... Back to work!
Title: Re: How to help with darwinbots 3 development?
Post by: Shasta on February 22, 2011, 12:06:59 AM
The current version of DB2 IM doesn't work (Stuck between updates). It actually works by http post and get. Before that it worked by FTP. I was thinking about making an actual socket server we can run over mono for DB3.
Title: Re: How to help with darwinbots 3 development?
Post by: Tj3 on February 22, 2011, 12:12:19 AM
Yeah, I was thinking the same thing.

And I just opened up the blacklight solution!  :D
Now if I manage to actually make something work ( Yeah, right :P ), how would I commit the change to the SVN? Is there a password?
Title: Re: How to help with darwinbots 3 development?
Post by: Tj3 on February 22, 2011, 12:14:11 AM
Ok, problem already.  >:(
I'm using VC# 2010, and I think it used 08/05... Should I convert, or just use an older version? I might have c# 08.... Wow, why can nothing work right? :(
Title: Re: How to help with darwinbots 3 development?
Post by: Tj3 on February 22, 2011, 12:19:48 AM
And, of course, I have: Web Developer 08, C++ 08, and VB.NET 08.... Converting would make it non-compatible with old versions, or no? Because then it wouldn't matter, but otherwise I shouldn't commit it.....
WAIT, idea... Could I just not commit the sln file??? Since that's all it changes(i think)... Although then I couldn't add new files...
Title: Re: How to help with darwinbots 3 development?
Post by: Tj3 on February 22, 2011, 12:32:42 AM
Have the code, looking through source files, and found in Elipse.cs in Blacklight.Xna, the class is just:
//Nothing special about rectangles

Does elipse drawing need to be implemented? Although, will that use shaders? I hate shaders, mostly because I don't feel like learning HLSL at the moment. And, anything specific that needs to be done? Not really sure exactly what to do...
Title: Re: How to help with darwinbots 3 development?
Post by: Numsgil on February 22, 2011, 01:42:53 PM
Ok, problem already.  >:(
I'm using VC# 2010, and I think it used 08/05... Should I convert, or just use an older version? I might have c# 08.... Wow, why can nothing work right? :(

It uses VS 2008.  I haven't upgraded yet.  If you can find C# 2008 (I'm not sure if they're still providing access to the free express edition, for instance), that would be preferred.

If they don't offer VS 2008 express anymore, I'll have to bit the bullet and upgrade.  The thing with upgrading is that it has to modify all the project files so once you upgrade there's no going back.  I'm fine with upgrading but then it's expensive for me to get the real version.  I could use the express version, (which I use for my laptop, I believe), but I use Professional edition at work, and they're different enough that I hate switching between them.

Also, it's still a bit of a pipe dream that I'd like to get this on the XBox at some point.  Presumably VS 2010 is compatible with XNA community developer blah blah but can someone check that?

Quote
Does elipse drawing need to be implemented? Although, will that use shaders? I hate shaders, mostly because I don't feel like learning HLSL at the moment. And, anything specific that needs to be done? Not really sure exactly what to do...

It's working with shaders right now.  How much of API driven graphics programming/theory are you familiar with?  Like, do you understand what a draw call is, or passes, and on like that?  Do you understand the matrix math that converts from "world space" to "projection space" to "screen space"?  The basic idea is that all the shapes are, as far as vertices go, just transformed quads, but then I draw on those quads in the pixel shader.

Working in the shader is definitely the most obvious thing needing doing.  Most of the non-shader XNA work is done, since it just needs to populate data for the shader to process.  If you look at Solid.fx, you might be surprised how much of it makes sense (it's heavily based in C).  The shader draws ellipses and rectangles right now, and draws them antialiased by basically drawing 5 mostly overlapping versions of the shape, but jittered by a half pixel or so.  It should (hopefully) make a bit of sense if you understand the basic linear algebra that graphics programming uses and C.  If you don't really understand converting from world space to screen space, for instance, this would be tricky to play with, but otherwise it should be pretty easy to pick up the shader language (there's references online for HLSL).

This (http://www.darwinbots.com/Mantis/view.php?id=12) is the specific task I have in mind.  This (http://www.google.com/imgres?imgurl=http://www.shoprallynumbers.com/i//outcir.jpg&imgrefurl=http://www.shoprallynumbers.com/catalog/item/7240924/7495262.htm&usg=__DmmyqC6ir8oOquL9P7QPZOQB8CI=&h=603&w=600&sz=43&hl=en&start=0&zoom=1&tbnid=WsWdXzx1_qUESM:&tbnh=118&tbnw=114&ei=Vv9jTZjQEo6asAPfhaHHCA&prev=/images%3Fq%3Dcircle%2Boutline%26um%3D1%26hl%3Den%26biw%3D1770%26bih%3D1139%26tbs%3Disch:1&um=1&itbs=1&iact=hc&vpx=946&vpy=202&dur=362&hovh=123&hovw=122&tx=108&ty=111&oei=Vv9jTZjQEo6asAPfhaHHCA&page=1&ndsp=61&ved=1t:429,r:6,s:0), for instance, would be an ellipse shape with a white inside color and a black outside color.  So it's just a matter of getting the pixel shader to change the color it samples instead of just changing the alpha.

...

I haven't thought about IM much.  The basic program will probably have a client/server architecture so that graphics and UI are in one .exe (the client) and the actual simulation is another .exe (the server).  With the idea being that you can run the server on a different computer from the client, maybe a computer you don't actually control.  So people could upload bots to a central server farm, and then view the different instances from their computer.

And probably a unified build that combines them into a single binary, too.

But that's all down the road a ways.
Title: Re: How to help with darwinbots 3 development?
Post by: Shasta on February 22, 2011, 02:37:30 PM
You can download VS 2008 Express here.  (http://www.microsoft.com/express/Downloads/)You will want the C# version. It is a bit hidden away, wouldn't be too surprised if it disappears at some point.

Quote
Presumably VS 2010 is compatible with XNA community developer blah blah but can someone check that?
Yup. (http://msdn.microsoft.com/en-us/library/bb203916.aspx) XNA 4.0 actually requires VS2010 + .NET 4.0
Title: Re: How to help with darwinbots 3 development?
Post by: Numsgil on February 22, 2011, 02:54:17 PM
A bit of reading later...  We can probably upgrade fine, but switching from targeting .NET 3.0 to .Net 4.0 can cause problems.

I'll try and download VS 2010 express at some point and upgrade everything, but in the mean time you'll still want to use 2008 express.

...

Oh, for SVN access, just let me know when you have something you want to commit.  I'll probably want to do a code review of changes first (just to make sure you're not coding in Python or something :P), then we can set up SVN access.
Title: Re: How to help with darwinbots 3 development?
Post by: Tj3 on February 22, 2011, 05:08:21 PM
Don't worry, I won't do it in Python. I'll probably use javascript :P

Anyway, you know what, I'm just gonna spend five hours making these stupid shaders work, and see what I get.
*.fx files for HLSL, right? Now where do these go exactly??? Do we have one content directory, or one for each component...?

So now, getting out my XNA book with like 100 pages of shaders stuff, and see if I can get this outline border color different thing to work...
Title: Re: How to help with darwinbots 3 development?
Post by: Numsgil on February 23, 2011, 02:10:48 PM
So thinking how to fix the case for skewed ellipses...  I think you're going to need to re-evaluate the radius of the inner ellipse so that the thickness of the border always looks constant.  This gamedev post (http://www.gamedev.net/topic/505331-drawing-an-ellipse-via-its-implicit-equation-in-a-pixel-shader/) looks relevant.  Fixing it is going to involve getting neck deep in some computational geometry, so let me know if you think you can handle it or not (I don't know the solution off the top of my head, certainly).
Title: Re: How to help with darwinbots 3 development?
Post by: Numsgil on February 23, 2011, 02:25:38 PM
If that doesn't sound appetizing, I have another thought:

Set up something that allows us to make movies of the render buffer (where 1 frame of output is 1 frame of the movie.  That way, slow running simulations could be watched in "real time").  The idea I have at present is to save a PNG after every frame and then combine them with FFmpeg (http://ffmpeg.org/) (see clicky (http://electron.mit.edu/~gsteele/ffmpeg/)), but there's probably sexier ways to do this, too.  If using FFmpeg, you can just set it up so that it saves the PNGs to a certain directory and names the PNGs correctly so FFmpeg can use them.  Probably write a sample batch script that uses FFmpeg to combine the screens into a movie.
Title: Re: How to help with darwinbots 3 development?
Post by: Botsareus on March 29, 2011, 04:46:17 PM
How about we won't use ellipses and use this instead:

(http://img534.imageshack.us/img534/4862/ideaxg.jpg) (http://img534.imageshack.us/i/ideaxg.jpg/)

Uploaded with ImageShack.us (http://imageshack.us)

For one thing the collision physics on these will be alot simpler
Title: Re: How to help with darwinbots 3 development?
Post by: Numsgil on March 29, 2011, 07:47:22 PM
My current favorite is actually an arbitrary quad (http://en.wikipedia.org/wiki/Quadrilateral).  Because it allows for things like a streamlined kite shape for single bots, a chevron (or arrowhead) for segmented worms, and something like a trapezoid for segemented circle bots (eg: something like this (http://www.google.com/imgres?imgurl=http://i.ehow.co.uk/images/a04/rl/hp/newtons-theory-color-4.1-800X800.jpg&imgrefurl=http://www.ehow.com/about_5101113_newtons-theory-color.html&usg=__xn1IC7SNnbQGCiRAC980XyaE8WE=&h=382&w=382&sz=37&hl=en&start=57&zoom=1&tbnid=gG_YFsMEvSsnVM:&tbnh=142&tbnw=142&ei=Lm-STeLoFYWssAPRsKHgBQ&prev=/images%3Fq%3Dsegmented%2Bcircle%26um%3D1%26hl%3Den%26biw%3D1920%26bih%3D1109%26tbs%3Disch:10%2C1200&um=1&itbs=1&iact=rc&dur=255&oei=KG-STaunFdLSiALNzNHyAQ&page=2&ndsp=59&ved=1t:429,r:7,s:57&tx=109&ty=91&biw=1920&bih=1109) if each color were a different bot).

Note that the shapes for bots above is independent of the graphics, though.  In the graphics system, I'm treating ellipses as simply a type of draw primitive.
Title: Re: How to help with darwinbots 3 development?
Post by: Botsareus on March 31, 2011, 03:04:46 PM
 :blink: ok, then why are we messing with ellipsis?



I like the movie idea ( as long as it is optional) for a different reason:

Let's say I am running a simulation over night and I want to see what happend while I was sleeping.

All I have to do is go to View > View Playback. and It opens Movie player and shows me what happend.
Title: Re: How to help with darwinbots 3 development?
Post by: Numsgil on March 31, 2011, 03:47:47 PM
It's not (shouldn't) be all that much extra work to get circles/ellipses drawing over quads.  The idea is that I want to get a functional graphics library in one strong push.  It doesn't have to be the greatest vector graphics library in the history of forever, or even entirely feature complete, but when it comes to iterating on the actual look of bots and shapes and such I want more than just quads to work with.  Plus it's a fun problem :P

Somewhat related, I'm sort of half thinking that I want to support a subset of SVG (http://en.wikipedia.org/wiki/Scalable_Vector_Graphics).  Save out screenshots as SVG, be able to load in and display SVG files (or at least support a lot of the primitives, if not all of them).  So I might play with curves and such, too.  Which could be used for graphs.  And there might be a cool way to combine SVG files into an animated SVG for movies, although I'm not entirely sure how animated SVGs work outside of browser environments.  And actually, if the graphics are SVG compatible, there might be a way to set up a Chrome-based client.  So we could do things like visibly examine a simulation running on a server using just a web address.
Title: Re: How to help with darwinbots 3 development?
Post by: Botsareus on April 01, 2011, 05:10:22 PM
SVG idea, good.

Graphics libraty:

Hey, I am not the developer here, but, If I knew what I was doing, I would not make it harder on myself. (as I mentioned before I want at least basic physics working before I am comfortable enough to mess with DB3, and we are just still doing basic graphics?!   )
Related: I am doing c# in school right now. So, I might worm up to c# enough to actually help with the code. No promises though, I am not going to sit there and figure out when Numsgil wants to paint quads and when he wants to paint ellipses.

(Numsgil: oops, I didn't mean to edit this.  I think I undid the editing I did).
Title: Re: How to help with darwinbots 3 development?
Post by: Numsgil on April 01, 2011, 06:51:32 PM
Quote
Hey, I am not the developer here, but, If I knew what I was doing, I would not make it harder on myself. (as I mentioned before I want at least basic physics working before I am comfortable enough to mess with DB3, and we are just still doing basic graphics?!  :wacko: )

Yeah, I'm not super good at that :)  If this were a professional game/program with a budget and investors and all that this would be a terrible business model.  As it happens, it's more that I (often) get fixated on interesting programming/math problems, and if they tangentially relate to DB3 so much the better.  I'd be concerned about over-polishing/shoot-the-engineer type issues except there's obvious forward progress, if just rather slow (the linear algebra in Azimuth, the DNA module, and the unit testing framework are 'done').

I'm presently working mostly on physics.  When I get tired of that, I do play around with the graphics.  I'm kind of working on the ellipse problem right now.  For skew transformations, it looks very wrong (see picture.  The border doesn't look like it has uniform thickness ).

Quote
Related: I am doing c# in school right now. So, I might worm up to c# enough to actually help with the code. No promises though, I am not going to sit there and figure out when Numsgil wants to paint quads and when he wants to paint ellipses.

:P I think I am just going to write the shader off as Numsgil-only code, since the skill set to effectively work on it is just too broad (C#, XNA, HLSL, and strong ability with computational geometry).  Actually, I am having a very hard time coming up with tasks which are interesting (ie: not just thinking up test cases for unit tests) and that don't require very strong math skills (eg: numerical analysis, linear algebra, computational geometry, etc.), which makes farming out tasks difficult.  It also makes the tasks interesting to me and I sort of want to do them myself the more I explain what I want :P
Title: Re: How to help with darwinbots 3 development?
Post by: Botsareus on April 30, 2011, 02:51:08 PM
Hey, Numsgil question:

Can we use an arraylist that is of a custom class object type that has an arraylist in it???

If NO, my instructor suggested a RAM based database.
Title: Re: How to help with darwinbots 3 development?
Post by: Numsgil on May 01, 2011, 08:37:26 PM
To store what?
Title: Re: How to help with darwinbots 3 development?
Post by: Botsareus on May 03, 2011, 02:46:12 PM
Modification on variable length DNA for a variable length amount of robots...
Title: Re: How to help with darwinbots 3 development?
Post by: Numsgil on May 03, 2011, 04:39:20 PM
Oh, I see.

The DNA isn't so very large that anything super clever needs to happen.  Right now it's set up as a tree of arrays (that is, a list of base pairs is a codule, a list of codules is a chromosome, a list of chromosomes is a bot's DNA).  The way .NET works, each array stores a reference to the elements in it instead of the actual objects, so it's not at all tricky for different bots' DNA to share the same physical representation.

And even if each bot has 10K base pairs, and there are 10K bots in the world, and no DNA is being shared, you're only looking at about 100 MBs.  So not something I'm super concerned about.