Author Topic: Bot Code Analysis Tool  (Read 15204 times)

Offline Prsn828

  • Bot Destroyer
  • ***
  • Posts: 139
    • View Profile
Bot Code Analysis Tool
« on: June 23, 2010, 07:33:47 AM »
First version:
http://www.mediafire.com/?i3pshzg3os73luk

This one isn't so much a suggestion as it is me stating what I'm going to try to do.
I figured this would be a good place to get commentary on the idea.

Here's what I have in mind:

Some sort of (probably java based) text editor that can take a gene and use an algorithm to parse bot code into infix notation using parenthesese.  I'd want to put other things in too, but for starters I think that alone would be helpful.

The other thought I had was to allow it to provide toggling between integers and their associated sysvars, so we could try to decipher evolved bots' codes more easily.

I haven't worked on any coding of bots recently, but I'm very confident I can get this working (and it'd help me to write some bots too).

I'm also thinking I might be able to have it work the other way, being able to take infix and translate it into postfix (while also preserving the infix version, or parsing it back for later editing).

Does this sound like something that would be helpful, or am I being overly ambitious here?
« Last Edit: September 11, 2010, 09:50:42 AM by Prsn828 »
So, what will it be? Will you submit to my will, or must I bend reality to suit my needs?
Better answer before I do BOTH!

Offline Ammeh

  • Queen of the Internets
  • Bot Destroyer
  • ***
  • Posts: 169
    • View Profile
Re: Bot Code Analysis Tool
« Reply #1 on: June 23, 2010, 08:28:11 AM »
That sounds amazingly useful. If you think you can do it, go for it :D

Offline Prsn828

  • Bot Destroyer
  • ***
  • Posts: 139
    • View Profile
Re: Bot Code Analysis Tool
« Reply #2 on: June 23, 2010, 08:38:34 AM »
I'm sure I can do it, but it will take me some time  :P
I'll work on it when I get home today.
So, what will it be? Will you submit to my will, or must I bend reality to suit my needs?
Better answer before I do BOTH!

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Bot Code Analysis Tool
« Reply #3 on: June 23, 2010, 02:37:37 PM »
The hard part really would be parsing the code.  Not that it's hard conceptually just that it's a bit of a project, and everything else (conversion from postfix to infix) you can look up online somewhere.

You might also want to try something of an "optimizing compiler".  ie: given an evolved bots code you can prune out junk DNA which you know can't influence the bot's behavior.

Like if you had a bot that did:

0 0 10 sqrt 400 10 .repro store mul 0 0

You can do some static analysis and get that the "effective" DNA is only:
10 .repro store

Likewise if something does:

10 10 3 mul dup mul 9 div store

Since those are all constants you can collapse it down to:

10 300 store

which is the same as:

10 .repro store.

...

I want to add something like this to DB3 eventually (basically the end goal is a bot writing IDE that integrates into the program, let's you single step debug through bot code, watch windows, etc.), so if you make the code clean and readable we can probably steal some of it when the time comes.

Offline Prsn828

  • Bot Destroyer
  • ***
  • Posts: 139
    • View Profile
Re: Bot Code Analysis Tool
« Reply #4 on: June 23, 2010, 03:55:18 PM »
Actually, I was thinking of taking it even further, and letting it tell the user what genes, for instance, might rely on one another.

That comes later though, first is getting it running with basic conversions from postfix to infix and identifying where numbers are being used as sysvars, etc.
So, what will it be? Will you submit to my will, or must I bend reality to suit my needs?
Better answer before I do BOTH!

Offline Ta-183

  • Bot Destroyer
  • ***
  • Posts: 105
    • View Profile
Re: Bot Code Analysis Tool
« Reply #5 on: June 25, 2010, 05:08:48 PM »
Really, I would probably kill for a tool like that. It would likely spell the difference that launches DB from an obscure a-life simulator used by only a couple dozen and upheld by even fewer to the 'killer app' of the programming game nerd. Most people that I tell about darwinbots think it's a neat idea until I reveal that the language used is a reverse-polish assembler. This could also really influence the creation of more and more complex league bots and would prove invaluable in the far more complex environment of DB3. Bots with complex diagnostic, error handling and antivirus systems would be far simpler to create and become far more common. The applications for bot development that such a program would have are boundless. The simple use of it as an error-checking and debugging tool would have far more immediate usefulness.

Who among us DOESN'T want to go back and make our best bots behave exactly as we wanted them to? It love to make SF2 work correctly. Half the time, I don't even know what the hell it's doing. Such is the reality of implementing complex structures in an esoteric assembly language. (DB4.0, now in Brainfuck!)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Bot Code Analysis Tool
« Reply #6 on: June 25, 2010, 08:39:25 PM »
(DB4.0, now in Brainfuck!)

Hmm...

:)

Offline Prsn828

  • Bot Destroyer
  • ***
  • Posts: 139
    • View Profile
Re: Bot Code Analysis Tool
« Reply #7 on: June 26, 2010, 11:05:30 AM »
Well, I've managed to get it started, so we'll see what happens.

It won't be too hard to get the first part, the infix to/from postfix, to work correctly.
When it does I might release a beta version of the tool (more accurately I'd say it's like an alpha).

Also, I've got it structured so that all of the actions it performs are in utility classes, so it should be easy to incorporate them into other programs.

If I do this right, you will be able to code in either infix or postfix, or can switch between the two.

I'll keep everyone informed of the progress as I get parts of it working.

[EDIT:]
I have the postfix to infix functionality working.  I tested it on Jeffalish from the bestiary, and it seems to work properly.  I don't know how well it might do with evolved code though.
The next step is infix to postfix.
« Last Edit: June 26, 2010, 03:25:21 PM by Prsn828 »
So, what will it be? Will you submit to my will, or must I bend reality to suit my needs?
Better answer before I do BOTH!

Offline Prsn828

  • Bot Destroyer
  • ***
  • Posts: 139
    • View Profile
Re: Bot Code Analysis Tool
« Reply #8 on: August 17, 2010, 08:02:45 AM »
I have ended up scrapping the Java in favor of Python.  As a bonus, it appears that I will now be able to add in tooltips, and have them directly pointed at the wiki (Ex: if your cursor is after the word add, and you press control + space, a small window appears with the wiki page for the add command.)

It uses WxPython, so anyone who wants to use it will also have to install Python and WxPython, but for anyone interested in something as code oriented as writing bots, this really shouldn't be a problem.

I have to re-implement the postfix/infix translations, but that shouldn't be too hard to do.

I'll release a beta once I get at least one of the useful features working fully. (Besides load, save, and saveAs, which I already have built into it)
So, what will it be? Will you submit to my will, or must I bend reality to suit my needs?
Better answer before I do BOTH!

Offline Shasta

  • Administrator
  • Bot Destroyer
  • *****
  • Posts: 231
    • View Profile
Re: Bot Code Analysis Tool
« Reply #9 on: August 18, 2010, 12:01:25 AM »
When you put out a version, could I request using py2exe? It makes way easier for everyone to just download and use it.
« Last Edit: August 19, 2010, 10:40:14 AM by Shasta »

Offline Prsn828

  • Bot Destroyer
  • ***
  • Posts: 139
    • View Profile
Re: Bot Code Analysis Tool
« Reply #10 on: August 19, 2010, 10:19:46 AM »
When you put out a version, could I request using py2exe? It makes way everyone to just download and use it.
Sure, that sounds like a good idea to me.
Hopefully I will get some spare time to work on it soon.  No garuntees though, as I have been pretty busy lately.
I also might have hit a snag on the tooltip idea, but I won't know for sure until I have the time to try it out.

I'll be sure to keep everyone updated whenever I make any progress.
So, what will it be? Will you submit to my will, or must I bend reality to suit my needs?
Better answer before I do BOTH!

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Bot Code Analysis Tool
« Reply #11 on: August 19, 2010, 02:11:27 PM »
Please do keep us updated. This is sounding good.

Offline Prsn828

  • Bot Destroyer
  • ***
  • Posts: 139
    • View Profile
Re: Bot Code Analysis Tool
« Reply #12 on: August 20, 2010, 10:18:07 AM »
[Edit] I have this mostly figured out now.  All that is left is to find the time to code it.
          Might not be able to get to it for a while though.


After doing a little searching, I believe I have found a nice solution for distribution of the program.
While py2exe is nice and referenced quite often, I have found PyInstaller, which appears to be much simpler for both the user and the programmer (no license issues or .dll's to worry about).

Most likely I will make some decent progress this weekend.
« Last Edit: August 21, 2010, 08:26:09 PM by Prsn828 »
So, what will it be? Will you submit to my will, or must I bend reality to suit my needs?
Better answer before I do BOTH!

Offline Prsn828

  • Bot Destroyer
  • ***
  • Posts: 139
    • View Profile
Re: Bot Code Analysis Tool
« Reply #13 on: August 23, 2010, 08:34:52 AM »
I have some more news for everyone.

I have all of the basic preparations complete.
IDE is set up, I have decided what libraries and extensions I will be using, and I have a good mental picture of how it will end up looking.

It is going to require that you have Internet Explorer installed at first, but I will add the option to use different browsers later.
This requirement is to facilitate code tooltips directly linked to the wiki.

I am also playing with the idea of adding in an obfuscation functionality.  I figure it could cause some pretty interesting evolution since it could separate the human aspect from the code.

postfix to and from infix will be supported, and I will likely distinguish the two notations using hilighting.

I'll set it up so that when it saves it will be converted to postfix.
I might use comments to allow it to be read back in using the same notation it had before the conversion for saving.

I can't make any garuntees, but I may also be able to add code completion.
Less likely but also still within the realm of possibilities is offline wiki support (basically storing a copy of the wiki locally).

I hope to also attempt a partial interpreter, allowing in-editor debugging. Wish me luck with this, but please don't hold your breath waiting for this feature.

I'll probably get the structure of the program figured out by the time I leave work today (gotta love spare time), so expect more news on that later today or tomorrow.
So, what will it be? Will you submit to my will, or must I bend reality to suit my needs?
Better answer before I do BOTH!

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Bot Code Analysis Tool
« Reply #14 on: August 23, 2010, 05:26:29 PM »
I hope to also attempt a partial interpreter, allowing in-editor debugging. Wish me luck with this, but please don't hold your breath waiting for this feature.