Author Topic: wxBots  (Read 6275 times)

Offline goffrie

  • Bot Builder
  • **
  • Posts: 65
    • View Profile
wxBots
« on: August 23, 2008, 10:29:17 PM »
(Updated!)

wxBots is my personal (re)implementation of Darwinbots in C++. It uses wxWidgets for its GUI, so it looks native on Windows and GTK+-based systems and Box2D for physics. (It also uses AGG as an optional, anti-aliased renderer, and the Boost C++ libraries.) It's at a pretty early state, but it's mostly usable and doesn't crash very much  I licensed it under the very liberal 2-clause BSD license.

It depends on the SVN version of Box2D (revision 172 right now), Boost 1.35.0 or 1.36.0, AGG 2.4 (2.5 works too but it's licensed under the GPL), and wxWidgets 2.8.8 (earlier versions might or might not work). It also needs zlib for loading/saving (XML-based save files are huge, and compression helps a lot).

Attached is the source code and a UPX-compressed Windows binary.

Things which work:
  • Loading most bots
  • Movement (but is calibrated somewhat differently from Darwinbots, I need to fix that)
  • Veggies with either nrg/cycle or nrg/kilobody feeding
  • Shots (with poison, venom, but shell is currently not handled correctly, and viruses don't work because I don't have a gene splitter)
  • Ordinary reproduction (.repro only)
  • Eyes (along with some refvars, eyeXwidth/dir work)
  • Rendering with either native (non-antialiased through wxWidgets) or AGG (anti-aliased, much slower) rendering
  • Dragging bots around and panning with the mouse (note: double clicking on a bot results in a bot properties dialog which shows basic statistics as well as code and memory)
  • Tie shooting, display and (sort of working) physics. No bot interaction yet though other than .tie for shooting, and having a lot of ties messes up the physics - any help on that?
  • Loading and saving in a gzip-compressed XML format
[attachment=980:src.zip]
[attachment=981:wxBots.exe]
« Last Edit: September 03, 2008, 08:20:42 PM by goffrie »

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
wxBots
« Reply #1 on: August 24, 2008, 02:17:46 AM »
2 questions
1) why?? (personal curiosity of mine, there are no wrong answers)
2) compiles with??

Offline goffrie

  • Bot Builder
  • **
  • Posts: 65
    • View Profile
wxBots
« Reply #2 on: August 24, 2008, 09:24:00 AM »
1. Because I was bored for a few weeks
2. I used GCC/MinGW to compile it. Code::Blocks was used for development, so if you have it you can use the wxBots.cbp project file. There are also Makefiles in the source zip, Makefile is my UNIX-like-system makefile while Makefile.mingw32 is for the Windows build - MSYS is probably necessary to get a working make (you probably need to edit CXX/LD/CXXFLAGS/LDFLAGS, standing for (C++) compiler, linker, compiler flags, linker flags respectively to fit your own paths). I would have used MSVC++ but (1) it uses 1.1GB of disk space and my VirtualBox-emulated Windows machine only has 5 GB total, (2) GCC is the native compiler on my development machine (running Linux). It should not be too hard to get it to work with MSVC though.

Oh, I forgot to mention that because it uses wxWidgets for GUI, it should work on most 32-bit platforms which wxWidgets supports.
« Last Edit: August 24, 2008, 09:27:14 AM by goffrie »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
wxBots
« Reply #3 on: August 24, 2008, 05:05:34 PM »
Yeah, MSVC is sort of the 800 pound gorilla of C++ IDEs.

Did you cannibalize any of my abortive attempt at a C++ version, or is it all your own code from scratch?

Offline goffrie

  • Bot Builder
  • **
  • Posts: 65
    • View Profile
wxBots
« Reply #4 on: August 24, 2008, 09:16:23 PM »
Quote from: Numsgil
Yeah, MSVC is sort of the 800 pound gorilla of C++ IDEs.

Did you cannibalize any of my abortive attempt at a C++ version, or is it all your own code from scratch?

Nah, I mostly wrote the code from scratch. I occasionally referenced the VB sources for things like shot handling but that's about it. I forgot about your C++ version actually, despite having the sources on my desktop  

Right now though, the computer I was using for development is.. thoroughly broken (doesn't boot at all, not even to a BIOS screen,) so it'll probably be a while before I get back to developing.

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
wxBots
« Reply #5 on: August 25, 2008, 11:45:13 AM »
Quote from: goffrie
it'll probably be a while before I get back to developing.
Well, next time you get bored, talk to me first.  There is no shortage of interesting projects and enhancements to work on.   I'd rather have all that nervous enery going into the main line code then off on a tangent.
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
wxBots
« Reply #6 on: August 25, 2008, 01:55:33 PM »
... a delicious C++ tangent

Offline goffrie

  • Bot Builder
  • **
  • Posts: 65
    • View Profile
wxBots
« Reply #7 on: August 25, 2008, 02:01:38 PM »
Quote from: EricL
I'd rather have all that nervous enery going into the main line code then off on a tangent.
Unfortunately, I don't have any experience with programming in VB :| Also, my primary development platform is Linux, and my emulated Windows environment is a little annoying to develop on.

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
wxBots
« Reply #8 on: August 25, 2008, 02:16:47 PM »
Quote from: goffrie
Unfortunately, I don't have any experience with programming in VB
Neither did I yet here I am.

Quote from: goffrie
:| Also, my primary development platform is Linux, and my emulated Windows environment is a little annoying to develop on.
Trust me.  It's just as annoying on the real deal.
Many beers....

Offline goffrie

  • Bot Builder
  • **
  • Posts: 65
    • View Profile
wxBots
« Reply #9 on: September 03, 2008, 08:24:09 PM »
Updated to version 0.1. I actually fixed this computer a week ago but just got around to making a new release. I edited the original post. There were a lot of changes and I forgot a lot of them, but I cleaned up the source a lot, fixed loading/saving and changed bzip2 to zlib for faster saving, and implemented a *very basic* tie system that breaks apart when a single bot has a lot of ties.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
wxBots
« Reply #10 on: September 03, 2008, 08:30:59 PM »
Explain the save file format to me.  I was thinking of doing something similar.  Is is the sort of thing that I could unzip separate from the program and make changes by hand?

Offline goffrie

  • Bot Builder
  • **
  • Posts: 65
    • View Profile
wxBots
« Reply #11 on: September 04, 2008, 04:32:43 PM »
I'm using Boost.Serialization to handle the saving/loading, but basically if you use 'gzip' or a compatible program to decompress the save file (adding a .gz extension would be helpful) you can see the XML with somewhat descriptive tags.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
wxBots
« Reply #12 on: September 04, 2008, 09:49:50 PM »
Hah, that's really cool.  I'm gonna try it now.

It works!  Sorta...  Is there binary embedded in the XML?  I'm seeing a lot of stuff that doesn't look quite right:

Code: [Select]
    <storecost>0.039999999</storecost>
    <agecost>9.9999997e-005</agecost>
    <botdensity>1</botdensity>
    <vegfeed>100<9ity>
    <vegfeed>100<9ity>
    <vetem>item_version>
                        <item>2</item>
                        <62>2</item>
tem>
                        <62>2</item>
tem>
                        <62>2</item>
tem>
                        <62>2</item>
tem>
>2</item>
tem>
>2<

Followed by a bunch of gibberish that looks like binary.  I used winace to unzip it, let me try it with 7zip.

EDIT: 7zip said my save was broken.  Maybe it was a bad save or bug or something.  I'm done tinkering for now, but you might want to give it a try.
« Last Edit: September 04, 2008, 09:48:39 PM by Numsgil »

Offline goffrie

  • Bot Builder
  • **
  • Posts: 65
    • View Profile
wxBots
« Reply #13 on: September 05, 2008, 07:20:37 AM »
Huh, it looks like the Windows compilation was broken, it doesn't save valid files but the (theoretically identical) Linux version does. I'll look into this.