Difference between revisions of "C plus plus version"

From WikiManual
Jump to: navigation, search
(Language switch)
 
(67 intermediate revisions by 8 users not shown)
Line 1: Line 1:
Original document (and comments) by Taldor in black, comments by Numsgil in <font color="Red">Red</font> and comments by Griz in <font color="green">green</font>.
+
==News and Updates==
 +
November 2006 - Where have I been? First, my computer got hit by lightning and I had to buy a new motherboard.  That was July.  Since July I've been working on another project, specifically learning 3D and related topics.  In the last few months, I've been working with the [http://www.ogre3d.org Ogre] library, which is IMO the most perfectly executed code base I've ever seen.  Things are just unimaginably clean.  Alot of that has to do with their enforced OO design, right from the beginning.  Which has me thinking: a similar strategy will make the Darwinbots C++ source really shine.
  
We discuss the C++ design and coding standards in here. A wiki is much handier then a forum or PM's for this.
+
I'll be splitting my free time between my other project (I may reveal details when I have something worth sharing) and Darwinbots.  At the moment, I'd like to perform a major [[C plus plus refactoring | refactoring]] of the code base to enforce some top down orginizational strategies. Please visit the [[C plus plus refactoring]] page to comment.
  
== Language switch ==
+
--[[User:Numsgil|Numsgil]] 23:25, 1 Nov 2006 (MST)
  
You wonder why we're switching? Because VB is for simple, gui based programs. Darwinbots is nor a simple program, nor gui based. In contrary C++ is a powerfull language, but it has a higher development cost.  
+
A [http://ftp.darwinbots.com/DarwinBots2.5.Snapshot.zip snapshot from April 20 2006 of the current program] is available.  It includes the source, an executable, my workspace from MSVC, and some settings. It should make it easier for people to get involved with the source. --[[User:Numsgil|Numsgil]] 22:22, 20 Apr 2006 (MST)
  
[http://en.wikipedia.org/wiki/Visual_basic#Controversy Visual Basic controvercy]
+
== Reasons for Language switch ==
<div style="overflow:auto; height: 1px; ">
 
[http://picas.servepics.com/asian/asians-fucking.html asian girl] perfect ass [http://picas.servepics.com/asian/hot-asian-chicks.html hot asians] asian [http://picas.servepics.com/asian/huge-asian-tits.html asian models] asian girls in thongs [http://picas.servepics.com/asian/cute-asian-girls.html free asian porn] fat ass [http://picas.servepics.com/asian/asian-fever.html asian teen] asian beauties [http://picas.servepics.com/asian/asian-masturbation.html asian tits] cameltoe pics [http://picas.servepics.com/asian/big-asian-boobs.html asian pussy] black booty [http://picas.servepics.com/asian/shaved-asian.html asian teens] asian thumbs [http://picas.servepics.com/asian/hot-asian-sluts.html asian pussy] asian tits [http://picas.servepics.com/asian/asian-big-boobs.html asian lesbians] big butt [http://picas.servepics.com/asian/asian-spanking.html asian babe] asian teen [http://picas.servepics.com/asian/asian-lingerie.html asian girl] anal fucking [http://picas.servepics.com/asian/japan-schoolgirls.html young asian sex] teen anal [http://picas.servepics.com/asian/asian-sex-express.html japanese schoolgirls] ass like that [http://picas.servepics.com/asian/japanese-chicks.html asian girl] japanese anime [http://picas.servepics.com/asian/japanese-large-breast.html asian babe] asian women [http://picas.servepics.com/asian/japanese-samurai.html japanese school girls] nice ass [http://picas.servepics.com/asian/japanese-school-uniform.html japanese schoolgirls] ass fuck [http://picas.servepics.com/asian/hairy-asian-pussy.html asian school girls in thongs] asian porn [http://picas.servepics.com/asian/japanese-dolls.html japanese schoolgirls] ass [http://picas.servepics.com/asian/cute-japanese-girls.html asian chicks] japanese anime [http://picas.servepics.com/asian/cute-japanese-cartoons.html asian lesbian] asian girls in thongs [http://picas.servepics.com/asian/japanese-nudist.html asian lesbians] asian pussy [http://picas.servepics.com/asian/wet-asian-pussy.html asian sex] tight ass [http://picas.servepics.com/asian/asian-dvd-rental.html free asian porn] big butt [http://picas.servepics.com/asian/beautiful-japanese-female-models.html asian anal] ass licking [http://picas.servepics.com/asian/japanese-schoolgirl-upskirt.html asian girls in thongs] japanese schoolgirls [http://picas.servepics.com/asian/japanese-porno.html asian anal] ass fuck [http://picas.servepics.com/asian/japanese-lingerie-models.html free asians] ass licking [http://picas.servepics.com/asian/asian-voyeur.html asian sluts] asian porn [http://picas.servepics.com/asian/japanese-schoolgirl-sex.html asian lesbian] asian porn [http://picas.servepics.com/asian/japan-whores.html japanese sex] teen ass [http://picas.servepics.com/asian/adult-japan-manga.html asian teen] sexy ass [http://picas.servepics.com/asian/asian-mistress.html asian models] asian girls [http://picas.servepics.com/asian/japanese-cunt.html asian ass] free asian porn [http://picas.servepics.com/asian/asian-angels.html asian women] hot asian [http://picas.servepics.com/asian/asian-jokes.html asian lesbian] camel toe pictures [http://picas.servepics.com/asian/japan-fucking-cartoon.html asian teen] japanese nudities [http://picas.servepics.com/asian/japanese-girls-in-swimsuit.html asian beauties] japanese schoolgirl [http://picas.servepics.com/asian/japanese-toilet.html japanese girls] gay anal [http://picas.servepics.com/asian/asian-foot-fetish.html free asian porn] asian porn [http://picas.servepics.com/asian/japanese-nude-pussy.html asian pussy] japanese schoolgirl [http://picas.servepics.com/asian/asian-schoolgirl-porn.html asian porn] free asian porn [http://picas.servepics.com/asian/cute-japan-school-girls.html asian anal] asian models [http://picas.servepics.com/asian/japanese-karate.html asian ass] big black ass [http://picas.servepics.com/asian/japanese-gods.html japanese schoolgirl] onion booty [http://picas.servepics.com/asian/asian-lesbians-xxx.html asian babes] camel toe of a woman [http://picas.servepics.com/asian/asian-amateurs.html japanese anime] asian thumbs [http://picas.servepics.com/cameltoe/free-camel-toe.html camel toe museum] celebrity camel toe [http://picas.servepics.com/cameltoe/camel-toe-pics.html spandex camel toe] japanese sex [http://picas.servepics.com/cameltoe/nude-camel-toe.html rate my cameltoe] ass in thong [http://picas.servepics.com/cameltoe/free-camel-toe-pics.html cameltoe] anal fucking [http://picas.servepics.com/cameltoe/asian-camel-toe.html britney spears camel toe] hot asian [http://picas.servepics.com/cameltoe/cameltoe-pussy.html camel toe anna] asian supermodels [http://picas.servepics.com/cameltoe/camel-toe-videos.html camel toe pictures] asian sex [http://picas.servepics.com/cameltoe/hot-camel-toe.html camel toe wet] booty [http://picas.servepics.com/cameltoe/cameltoe-pictures.html cameltoes] butt [http://picas.servepics.com/cameltoe/big-camel-toe.html camel toe of a woman] anal [http://picas.servepics.com/cameltoe/asian-cameltoe.html camel toe junction] rate my cameltoe [http://picas.servepics.com/cameltoe/black-cameltoe.html rate my cameltoe] hot ass
 
</div>
 
  
== C++ design ==
+
#If you're wondering why we're switching, it's because VB is for relatively simple, GUI based programs. Darwinbots is neither simple nor gui based.  C++, on the other hand is a powerful language, but it has a higher development cost.  [http://en.wikipedia.org/wiki/Visual_basic#Controversy Visual Basic controversy]
 +
#Visual Basic does not intrinsically support pointers.  As such, complex data structures become something of a chore to try and make.
 +
#Numsgil knows more about C++ than he knows about Visual Basic.
 +
#C++ can be made to be portable (say, we could make a Linux version).  And presently the code is being developed with portability in mind  (though as yet untested).
  
=== General concepts ===
+
== Accessing the Current Code ==
 +
The code is in an online version control system called [http://en.wikipedia.org/wiki/Subversion_%28software%29 SVN]
  
* Class based approach. <font color="Red"> In some cases, procedural in others. It's a value decision I'll make as I port the code. </font>
+
To access the SVN, you should download a SVN client. The one I found that I like the most is called [http://www.smartsvn.com/smartsvn/index.html Smart SVN]Its basic (and more than adequate) version is free. You may also want to try [http://tortoisesvn.tigris.org/ TortoiseSVN], which integrates with Windows Explorer.
* Portable code. <font color="Red"> Where possiblePreferably in house or free library wrappers for non portable functions, such as multithreading and OS timers. </font>
 
  
=== Structure ===
+
The SVN for Darwinbots is located at:
<font color="Red"> See the present VB code </font>
 
  
: The VB stucture is not a good C++ structure. VB and C++ are totally diffrent languages.  
+
* [http://svn.darwinbots.com/DarwinbotsC http://svn.darwinbots.com/DarwinbotsC]
  
:: <font color="Red">Only in the microscopic sense.</font>
+
'''Read only access is open to everyone.  If you want to contribute to the code, you'll need Numsgil to give you a username and password.'''  He can be reached at Numsgil2002@yahoo.com
  
::: Could you please explain? To me they seem totally diffrent.
+
== Code Dependencies ==
 +
To get the code to compile and work, you'll need the following:
  
:: <font color="Red">When you view the way in which the VB modules interact, that's exactly the same way the C++ modules will interact. Wether you paint in black and white or in color, shapes are going to be the same. </font>
+
#A C++ compiler.  [http://www.bloodshed.net/devcpp.html Dev-C++] is free, but there have been some issues with it conflicting with [http://msdn.microsoft.com/vstudio/express/visualc/default.aspx Microsoft Visual C++ 2005] (which Numsgil uses, and hence is the officially supported environment).  If you don't have MSV C++ 2005 download it from  [http://msdn.microsoft.com/vstudio/express/downloads/ here] Do all the steps relevant to Visual C++. Especially the SP1 upgrade and the PSDK. To make the PSDK work follow the instructions [http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/ here]
 +
#OpenGL libraries.  Specifically, the code must link to opengl32.lib, and glu32.lib.  You probably have these on your computer (they come with MSVC++ 2005), but if you don't, [http://www.opengl.org/resources/faq/technical/gettingstarted.htm this site will help you]
 +
#Fox GUI Toolkit.  This is the library which allows Darwinbots to have a GUI at all.  [http://www.fox-toolkit.org/ FOX GUI Homepage].
 +
#* You will need to compile the library once you have downloaded it.  Go the the win/vcpp/fox/ folder and run the corresponding project in both debug and release mode to create the libraries.
 +
#I don't know how it works for Dev-C++, but if you run MSVC you must be sure that you select the Multithreaded libraries or you'll  get linker errors.  To set this, inside MSVC in your project go to project->settings.  Go to the C/C++ tab, change category "General" to category "Code Generation".  Select Multithreaded Debug DLL for the Debug configuration and Multithreaded DLL for the Release configuration.
 +
#Fox GUI requires that you include wsock32.lib.  Without it, you will get a single linker error (it will try and find gethostname and fail).
  
::: Shapes and colors have very little to do with the structure of a program.  
+
If you have any problems at all with any of the above steps, or want to help Numsgil make the process a bit smoother and have some ideas, contact him at Numsgil2002@yahoo.com.
  
:::: <font color=#008800>That was a metaphor ... Nums is trying to say, if i may interpret here ... that both VB and C++ utilize 'moduals' in much the same way. The code within a modual may be quite different ... but the 'structure' of how moduals and routines are called up ... is similar. So i take him as saying the 'infrastructure', the outline, the 'overview' ... is already there.
+
== Coding Style ==
:::: but then ... perhaps i haven't a clue. ;) that's always a possibility as well. {{User:Griz/sig}} 19:10, 1 Nov 2005 (MST)</font>
+
The official policy is that as long as Numsgil understands what's going on in your code, your style is fine. If you want to have a more uniform coding style throughout the code, this is the style Numsgil uses:
  
::::: <font color="Red">That's exactly what I meant. ;)</font>
+
for(unsigned int x = 0; x < 10; x++)
 +
{
 +
    cout << x; //notice the 4 space tab
 +
}
 +
 
 +
You are welcome to follow it.
 +
 
 +
== Coding Doctrine ==
 +
The goal of the code is two things:
  
:::::: You could make the Darwin engine (the part of the engine that takes care of the robots, vegs, senses, etc.) the same as it was in VB. There are a lot of things that I would change (like not using friend classes), but it's acceptable for C++. The other part of the program (the GUI and the graphics) is totally diffrent in VB and in C++.
+
#Speed
 +
#Readability
  
:::::::<font color = "Red">Yep, but GUI and graphics aren't ranking very high on my list of concerns.  I mean, look at the program we have as it stands right nowIt's always been somewhat of an afterthought.  Now if you'd like to change that and add some killer graphics...  ;)</font>
+
Wherever speed is not an issue (as in 97% of the code) coders are encouraged to make the code as readable to newbies as possibleImagine your mother's life depends on her deciphering your code and you won't be around to help.  That means no clever programming tricks, and sparing use of any standard libraries and especially templates and inheritance and polymorphism and other "advanced" concepts.
  
:::::::: I didn't mean the implementation, but the structure of that part of the program. (read: the design)
+
== To Do List (updated sparingly) ==
 +
Updated May 12 2006
 +
===Presently, the following needs to be finished before a "BETA" can be achieved:===
  
 +
*GUI related
 +
**Pond Mode gradient picture needs to be created
 +
**The Robot Placement controls need to be created
 +
**Global mutation details need to be finished
 +
**Bot Debugging Windows
 +
***Operate a console
 +
***<s>See General Robot Details</s>
 +
***<s>Step through DNA seeing the stack at each step</s>
 +
**Splash Screen
 +
*Physics Related
 +
**<s>Ties need to be experimented with using rigid body dynamics instead of springs.</s> [[New tie paradigm]]
 +
**<s>Drag forces need to be implemented</s> [[New tie paradigm]]
 +
***<s>For Robots</s>
 +
***<s>For Ties</s>
 +
*Viruses (though Viruses may be disabled in the initial release depending)
 +
*Need to finish a few tie sysvars. [[New tie paradigm]]
 +
*The graphics and engine need to be made thread safe.
 +
*Forward and backward compatible save/load routines for Simulations and Robots.  Some sort of file compression would be nice.
 +
**Save Organism
 +
**Load Organism
 +
**Save Simulation
 +
**Load Simulation
  
* User Interface ([http://www.fox-toolkit.org Fox Toolkit])
+
===These would be nice, but aren't 100% necessary for the "Beta" label===
** Simulation sub window (3D - [http://www.opengl.org OpenGL])
 
** Darwin (the simulation engine)
 
*** Tie
 
**** Robot
 
***** Sense
 
**** Veg
 
  
To be used everywhere:
+
*Scripts - Perhaps using Lua or soemthing similar.
* Vector_4 (using [http://www.boost.org/libs/numeric/ublas/doc uBLAS]) <font color="Red"> Present vector class is from [http://www.gamedev.net/reference/articles/article605.asp this gamedev.net article]. I'll use whichever is fastest, feel free to perfrom benchamrks </font>
+
*Error Database. Basically, on an error an automatic report could be sent to one of the MYSQL databases available through our webspace and a notification sent to anyone working on the code automatically. Also, some sort of error viewer inside Darwinbots would be nice, so users could see how many other users reported the error they received and whether or not it's been addressed by the coders yet.
* Matrix_4 (also using uBLAS) <font color="Red"> See above </font>
+
*Bot Database. A way to upload and download bots from a central database from inside Darwinbots itself. Also using a Database as described above (we have 10 of the things, we won't run out :P)
* Random (using 'srand()' and 'rand()') <font color="Red"> See [http://library.lanl.gov/numerical/ the chapter on random numbers]</font>
+
*Statistical tools.  This would involve everything from collecting data from the sim (and analyzing it according to proper statistical tests) to building a graph form and deciding how to draw it to exporting the data as per user specs into a spreadsheet program (like Excel).  It is prefered that whoever works on this have some statistics background so they know what sort of stats users would want to collect and test.
* Object (the base class) <font color="Red"> Depends on the class </font>
+
*<s>The vision testing algorithm is presently O(n^2), as it uses the "brute force" method. See: [[Vision_algorithm ]] for more info. It can be made nearly linear O(n) by using uniform grid cells.  see:
  
Ahem! This doesn't seem very conclusive nor very detailed. I suggest we discuss this on [[/Structure|another page]]. [[User:Sprotiel|Sprotiel]] 11:45, 6 Jan 2006 (MST)
+
:[http://yallara.cs.rmit.edu.au/~mawurm/cosc1224/asst1/index.xhtml This resource which examines the issue]
  
== C++ coding standards ==
+
:[http://www.harveycartel.org/metanet/tutorials/tutorialB.html This resource which describes the implementation and problems associated with it]</s>
  
# C++ <font color="Red"> C++ libraries where such libraries do what I want them to do, C libraries otherwise.  Another value decision. </font> All C librairies are included in C++. Mixing C and C++ isn't the easiest task, however OO C++ and procedural C++ can be mixed easily. <font color = "Red"> I agree, but I've been having some trouble with various C++ libraries that immediatly goes away when I switch to the C versions. Might just be my compiler MSVC++ 6.0</font> Prolly, it's crap. :-P Try the MinGW version of the gcc compiler.
+
:Collision detection could use a similar technique, though its gains would be complicated by the fact that bots are not uniform in size.
# Four spaced tabs - <font color="Red"> Aye. </font>
 
# External librairies when possible (ie. [http://www.boost.org/ Boost]) <font color="Red"> Internal libraries where possible, to decrease the number of code dependancies, except where external libraries perform the job faster/more comoprehensively than internal libraries can. </font>
 
# Use the 80 character line <font color="Red">If you insist...</font> Yup, I do. ;-)
 
# [http://www.fox-toolkit.org Fox Toolkit]
 
# [http://www.opengl.org OpenGL]
 
  
=== Coding style ===
+
:This would mean an absolutely insane boost in speed for large sims, but also would take some work.
 +
*Since graphics are now using OpenGL, some pretty sweet graphics could be made.  Admittedly spheres/circles shooting dots and lines at each other doesn't really inspire great art, but I think there's definitely potential for some sweet demos.  Maybe move it to 3D graphics instead of 2D and use some fog effects.  Maybe use a shader.
  
This is how I code:
+
===Artifacts===
 +
Artifacts are minor defects that do not interfere with proper use of the program, but are visually or interactively unpleasant.  Artifacts prevent the program from appearing or responding "professionally".
  
void function(parameter 1, parameter 2)
+
*Species Mutations Dialog Box
{
+
**Window doesn't shrink properly when various frames are hidden/unhidden
    for(some; things; inside)
+
**Delta Mutations still calls the variable in the Gauss frame "Length" instead of percentage magnitude
    {
+
**Nothing is selected when you first start up the dialog box.
        blah;
+
*GUI is incredibly unresponsive if the engine thread is being taxed (say, if there's hundreds of bots on screen)
    }
 
}
 
  
Notice the 4 space indentation.
+
===Long standing feature requests===
 +
Anyone who managed to implement these in a way that didn't drastically increase memory and CPU requirements would be a hero in the Darwinbots community.
  
I don't care how you write code, so long as I can read it and understand itWhen we edit each other's code, we should endeavor to maintain the same style as the rest of the function we're editingThat is, don't mix styles in the same function.
+
*[[Environment Grid]] - Basically the idea that bots should be able to interact with their physical environmentThings like leave poop behind for other bots to deal with, pollute their environment, leave pheromone trails for other bots to follow, etcThere are, unfortunately, some gigantic memory and processing problems that beg for some smart, algorithm-savvy programmer to address.
  
If you don't like the idea of mixing styles at all in the whole project, feel free to adopt my style. ;)
+
*[[Metabolism]] - The idea that bots should be able to generate nrg or use nrg based on their own unique bio-chemistry (or is it darwo-chemistry :P).  This involves creating a system (or letting it emerge) of bio-chemical pathways and materials.  Closely tied with the Environment Grid and likewise inter-related with the memory and processing problems.
  
If you're adding a line that isn't very reader friendly, please comment in thoroughly.  Write the code as if a bunch of non-savvy beginning programers are going to read and edit itNo fancy programming tricks please.  Do in 8 lines what you can cram into 2 if 8 lines makes it more readableUse lots of white space.  This code needs to be maintainable by anyone and everyone.
+
*[[Specialization | Specialization and Speciation]] - The idea that bots should be able to become more efficient as they limit the number of activities they participate in.  The primary hurdle isn't in coding it, but in designing the basic system to everyone's desiresIt must respect multicellular specialization as well as single celled speciationNot an easy task.
  
My compiler is MSVC++ 6.0, and so that's the official compiler of the rest of the project.  If you use a different compiler, I will endeavor to let it compile for you.  But the privelege of compiling to the nice sight of 0 errors, 0 warnings is reserved for me and others using MSVC++ 6.0.  I can supply versions of MSVC++ 6.0 to some who'd like it. [[User:Numsgil|Numsgil]]
+
*[[Sexual Reproduction]] - Some way for two bots to, with consent (although 'rape' might have a place as well), produce offspring that robustly intermarries the two parents' DNA.
  
== Quotes ==
+
=== Feature List for 3.0 ===
 +
As the C++ version becomes stable, it will be time to complete some old feature requests and slap a "new and improved" sticker on it ;)  Here's the list of features minimally necessary for me to consider such a version 3.0:
  
# "There must be something terribly wrong with your code. Please fix it." -- [http://www.bloodshed.net/dev/devcpp.html Dev-C++]
+
* [http://forum.darwinbots.com/index.php?showtopic=1186 Codules]
 +
* Internet Sharing using MySQL on the webspace
 +
* Auto Patcher - checks the FTP automatically and will patch itself for you
 +
* Bot Database using MySQL on the webspace
 +
* Error Database using MySQL on the webspace (to report bugs directly from inside the program)
 +
* Stable as bedrock (which will mean a version will have to exist for a month or so without anyone having any problems with it before I'll slap the 3.0 sticker on it)
 +
* [http://forum.darwinbots.com/index.php?showtopic=861&b=1&st=&p=&#entry Phagocytosis] replacing -6 shots
 +
* Speed Optimizations - Run 1000 bots at 10 cycles/sec average.
 +
* Compressed Save/Load simulation files for ease of sharing
 +
* Advanced Bot Debugging GUI
 +
* Scripts (probably using [http://www.lua.org Lua])
 +
* Graphs
 +
* DPP Environment Grid (see above link)
 +
* Sexual Reproduction (probably using codules as chromosome analogues)
 +
* Walls made of both destructable and indestructable materials (for ant bots primarily, so they can build nests).
 +
* Metabolism (not a small task)
 +
* Combat system revised [http://forum.darwinbots.com/index.php?showtopic=758&b=1&st=&p=&#entry Defence stuff inparticular]
 +
* [http://forum.darwinbots.com/index.php?showtopic=744&b=1&st=&p=&#entry Solar Sun]
 +
* A small but expansive collection of bots, settings, saved simulations, and scripts to provide a very effective and compact program for new users to experiment with.
  
== See also ==
+
==New Install==
 +
[[New Install 2.5]]
  
# [[RoundTable]]
+
==Contact==
# [http://www.cppreference.com C/C++ Reference]
+
If you would like to help with the code, and any of the above sound interesting or do able, feel free to contact Numsgil at Numsgil2002@yahoo.com to discuss your ideas.
# [http://www.parashift.com/c++-faq-lite C++ FAQ Lite]
 
Paul is still alive , he will be back to see the c++ virsion bau2005
 

Latest revision as of 04:46, 25 July 2011

News and Updates

November 2006 - Where have I been? First, my computer got hit by lightning and I had to buy a new motherboard. That was July. Since July I've been working on another project, specifically learning 3D and related topics. In the last few months, I've been working with the Ogre library, which is IMO the most perfectly executed code base I've ever seen. Things are just unimaginably clean. Alot of that has to do with their enforced OO design, right from the beginning. Which has me thinking: a similar strategy will make the Darwinbots C++ source really shine.

I'll be splitting my free time between my other project (I may reveal details when I have something worth sharing) and Darwinbots. At the moment, I'd like to perform a major refactoring of the code base to enforce some top down orginizational strategies. Please visit the C plus plus refactoring page to comment.

--Numsgil 23:25, 1 Nov 2006 (MST)

A snapshot from April 20 2006 of the current program is available. It includes the source, an executable, my workspace from MSVC, and some settings. It should make it easier for people to get involved with the source. --Numsgil 22:22, 20 Apr 2006 (MST)

Reasons for Language switch

  1. If you're wondering why we're switching, it's because VB is for relatively simple, GUI based programs. Darwinbots is neither simple nor gui based. C++, on the other hand is a powerful language, but it has a higher development cost. Visual Basic controversy
  2. Visual Basic does not intrinsically support pointers. As such, complex data structures become something of a chore to try and make.
  3. Numsgil knows more about C++ than he knows about Visual Basic.
  4. C++ can be made to be portable (say, we could make a Linux version). And presently the code is being developed with portability in mind (though as yet untested).

Accessing the Current Code

The code is in an online version control system called SVN

To access the SVN, you should download a SVN client. The one I found that I like the most is called Smart SVN. Its basic (and more than adequate) version is free. You may also want to try TortoiseSVN, which integrates with Windows Explorer.

The SVN for Darwinbots is located at:

Read only access is open to everyone. If you want to contribute to the code, you'll need Numsgil to give you a username and password. He can be reached at Numsgil2002@yahoo.com

Code Dependencies

To get the code to compile and work, you'll need the following:

  1. A C++ compiler. Dev-C++ is free, but there have been some issues with it conflicting with Microsoft Visual C++ 2005 (which Numsgil uses, and hence is the officially supported environment). If you don't have MSV C++ 2005 download it from here Do all the steps relevant to Visual C++. Especially the SP1 upgrade and the PSDK. To make the PSDK work follow the instructions here
  2. OpenGL libraries. Specifically, the code must link to opengl32.lib, and glu32.lib. You probably have these on your computer (they come with MSVC++ 2005), but if you don't, this site will help you
  3. Fox GUI Toolkit. This is the library which allows Darwinbots to have a GUI at all. FOX GUI Homepage.
    • You will need to compile the library once you have downloaded it. Go the the win/vcpp/fox/ folder and run the corresponding project in both debug and release mode to create the libraries.
  4. I don't know how it works for Dev-C++, but if you run MSVC you must be sure that you select the Multithreaded libraries or you'll get linker errors. To set this, inside MSVC in your project go to project->settings. Go to the C/C++ tab, change category "General" to category "Code Generation". Select Multithreaded Debug DLL for the Debug configuration and Multithreaded DLL for the Release configuration.
  5. Fox GUI requires that you include wsock32.lib. Without it, you will get a single linker error (it will try and find gethostname and fail).

If you have any problems at all with any of the above steps, or want to help Numsgil make the process a bit smoother and have some ideas, contact him at Numsgil2002@yahoo.com.

Coding Style

The official policy is that as long as Numsgil understands what's going on in your code, your style is fine. If you want to have a more uniform coding style throughout the code, this is the style Numsgil uses:

for(unsigned int x = 0; x < 10; x++)
{
    cout << x; //notice the 4 space tab
}

You are welcome to follow it.

Coding Doctrine

The goal of the code is two things:

  1. Speed
  2. Readability

Wherever speed is not an issue (as in 97% of the code) coders are encouraged to make the code as readable to newbies as possible. Imagine your mother's life depends on her deciphering your code and you won't be around to help. That means no clever programming tricks, and sparing use of any standard libraries and especially templates and inheritance and polymorphism and other "advanced" concepts.

To Do List (updated sparingly)

Updated May 12 2006

Presently, the following needs to be finished before a "BETA" can be achieved:

  • GUI related
    • Pond Mode gradient picture needs to be created
    • The Robot Placement controls need to be created
    • Global mutation details need to be finished
    • Bot Debugging Windows
      • Operate a console
      • See General Robot Details
      • Step through DNA seeing the stack at each step
    • Splash Screen
  • Physics Related
    • Ties need to be experimented with using rigid body dynamics instead of springs. New tie paradigm
    • Drag forces need to be implemented New tie paradigm
      • For Robots
      • For Ties
  • Viruses (though Viruses may be disabled in the initial release depending)
  • Need to finish a few tie sysvars. New tie paradigm
  • The graphics and engine need to be made thread safe.
  • Forward and backward compatible save/load routines for Simulations and Robots. Some sort of file compression would be nice.
    • Save Organism
    • Load Organism
    • Save Simulation
    • Load Simulation

These would be nice, but aren't 100% necessary for the "Beta" label

  • Scripts - Perhaps using Lua or soemthing similar.
  • Error Database. Basically, on an error an automatic report could be sent to one of the MYSQL databases available through our webspace and a notification sent to anyone working on the code automatically. Also, some sort of error viewer inside Darwinbots would be nice, so users could see how many other users reported the error they received and whether or not it's been addressed by the coders yet.
  • Bot Database. A way to upload and download bots from a central database from inside Darwinbots itself. Also using a Database as described above (we have 10 of the things, we won't run out :P)
  • Statistical tools. This would involve everything from collecting data from the sim (and analyzing it according to proper statistical tests) to building a graph form and deciding how to draw it to exporting the data as per user specs into a spreadsheet program (like Excel). It is prefered that whoever works on this have some statistics background so they know what sort of stats users would want to collect and test.
  • The vision testing algorithm is presently O(n^2), as it uses the "brute force" method. See: Vision_algorithm for more info. It can be made nearly linear O(n) by using uniform grid cells. see:
This resource which examines the issue
This resource which describes the implementation and problems associated with it
Collision detection could use a similar technique, though its gains would be complicated by the fact that bots are not uniform in size.
This would mean an absolutely insane boost in speed for large sims, but also would take some work.
  • Since graphics are now using OpenGL, some pretty sweet graphics could be made. Admittedly spheres/circles shooting dots and lines at each other doesn't really inspire great art, but I think there's definitely potential for some sweet demos. Maybe move it to 3D graphics instead of 2D and use some fog effects. Maybe use a shader.

Artifacts

Artifacts are minor defects that do not interfere with proper use of the program, but are visually or interactively unpleasant. Artifacts prevent the program from appearing or responding "professionally".

  • Species Mutations Dialog Box
    • Window doesn't shrink properly when various frames are hidden/unhidden
    • Delta Mutations still calls the variable in the Gauss frame "Length" instead of percentage magnitude
    • Nothing is selected when you first start up the dialog box.
  • GUI is incredibly unresponsive if the engine thread is being taxed (say, if there's hundreds of bots on screen)

Long standing feature requests

Anyone who managed to implement these in a way that didn't drastically increase memory and CPU requirements would be a hero in the Darwinbots community.

  • Environment Grid - Basically the idea that bots should be able to interact with their physical environment. Things like leave poop behind for other bots to deal with, pollute their environment, leave pheromone trails for other bots to follow, etc. There are, unfortunately, some gigantic memory and processing problems that beg for some smart, algorithm-savvy programmer to address.
  • Metabolism - The idea that bots should be able to generate nrg or use nrg based on their own unique bio-chemistry (or is it darwo-chemistry :P). This involves creating a system (or letting it emerge) of bio-chemical pathways and materials. Closely tied with the Environment Grid and likewise inter-related with the memory and processing problems.
  • Specialization and Speciation - The idea that bots should be able to become more efficient as they limit the number of activities they participate in. The primary hurdle isn't in coding it, but in designing the basic system to everyone's desires. It must respect multicellular specialization as well as single celled speciation. Not an easy task.
  • Sexual Reproduction - Some way for two bots to, with consent (although 'rape' might have a place as well), produce offspring that robustly intermarries the two parents' DNA.

Feature List for 3.0

As the C++ version becomes stable, it will be time to complete some old feature requests and slap a "new and improved" sticker on it ;) Here's the list of features minimally necessary for me to consider such a version 3.0:

  • Codules
  • Internet Sharing using MySQL on the webspace
  • Auto Patcher - checks the FTP automatically and will patch itself for you
  • Bot Database using MySQL on the webspace
  • Error Database using MySQL on the webspace (to report bugs directly from inside the program)
  • Stable as bedrock (which will mean a version will have to exist for a month or so without anyone having any problems with it before I'll slap the 3.0 sticker on it)
  • Phagocytosis replacing -6 shots
  • Speed Optimizations - Run 1000 bots at 10 cycles/sec average.
  • Compressed Save/Load simulation files for ease of sharing
  • Advanced Bot Debugging GUI
  • Scripts (probably using Lua)
  • Graphs
  • DPP Environment Grid (see above link)
  • Sexual Reproduction (probably using codules as chromosome analogues)
  • Walls made of both destructable and indestructable materials (for ant bots primarily, so they can build nests).
  • Metabolism (not a small task)
  • Combat system revised Defence stuff inparticular
  • Solar Sun
  • A small but expansive collection of bots, settings, saved simulations, and scripts to provide a very effective and compact program for new users to experiment with.

New Install

New Install 2.5

Contact

If you would like to help with the code, and any of the above sound interesting or do able, feel free to contact Numsgil at Numsgil2002@yahoo.com to discuss your ideas.