This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another Bot
#1
I've been working on a bot that chooses its moves more quickly than the present bot.  Would anyone else be interested in trying this bot?  What is the proper way for me to share the code?
Reply
#2
(06-11-2011, 11:05 PM)impatience link Wrote: I've been working on a bot that chooses its moves more quickly than the present bot.  Would anyone else be interested in trying this bot?  What is the proper way for me to share the code?

Post a patch to the sourceforge site.
Reply
#3
Ok, done.  It's on the patch tracker with ID 3316539, title Faster Bot, with patch name megamek_patch_princess_bot_14_6_2011.txt

Instructions: Download and apply patch, run megamek, start scenario, and select "other bot" from the Select Scenario Players dialog.  I did not include it in the "connect as bot" option, but it is trivial to add as it uses the same interface as the current bot.

About the new bot:  While it is much more simpleminded than the current bot, it is about 50-100 times faster.  For the small scenarios I've tested, its combat effectiveness seems to be competitive with the current bot.  Following are the results of bot vs bot games for some of The Great Refusal scenarios.  Every game the bots switch sides so as to eliminate bias towards one player or the other in the scenario.  However, heavily biased scenarios may hide small differences between bots.  To distinguish between bots, the new bot has been named "Princess" and the current bot is called "TestBot".

2-WolfVsIvesCompact
Princess won 48/98 games, win probability .49 +/- .05
Princess spent 197982 ms moving, TestBot spent 10956235 ms moving, Princess took 1.8 percent as long to move
3-BloodSpiritVsKurita
Princess won 49/97 games, win probability .51 +/- .05
Princess spent 136033 ms moving, TestBot spent 15608692 ms moving, Princess took .8 percent as long to move
4-JadeFalconVsComstar
Princess won 52/98 games, win probability .53 +/- .05
Princess spent 184308 ms moving, TestBot spent 14874754 ms moving, Princess took 1.2 percent as long to move

The bot has not beet tested with vehicles of any kind.
Subjectively, the bot does not seem to handle infantry well, but I don't have a good way to quantify "good infantry handling".
If anyone gets a chance to try the new bot, I am very interested to hear their observations or bug reports.

Also, I would like to extend my thanks to the developers of MegaMek.  It's kept me entertained on many long flights.
Reply
#4
About the infantry, I have noticed that the old bot, TestBot as you have named it, seems to "forget to move infantry" sometimes. I believe this happens when the advance setting for dispersing infantry moves throughout the movement of other units is turned on. It seems the bot does not like being told which unit is has to move. >Sad
Quick fix was to kick the bot, then replace the empty player with a new bot. Gets kind of old after 5 rounds of this. Just wondering if you've noticed similar things.

Also, one final question: "Is this new bot like the old bot, in that the fewer advanced settings turned on the better?"
And awesome statistics even with error bars. Though I must ask (jokingly of course and no need to answer), is the error bar at 95% confidence? Using a Gaussian distribution? (Ha ha, you can tell I have to compute errors, too. Wink )
Reply
#5
I've tried several hours today to apply your patch but honestly i'm to stupid.
Can u post a manual step by step how to apply the patch and compile/build the patched version?
I'm very interested in trying out the new bot. Thx a lot in advance.
Reply
#6
To Xenon:  I think the infantry problem may be a result of infantry having such a small movement.  You have to think about where you want the infantry to be 2 or 3 rounds in advance, and Princess certainly doesn't do that.  Perhaps I could fix that.  I haven't tried changing advanced options, so I can't say whether the bot cares about them.  Were there any in particular that are important?

To Nekonami:  Yeah, it took me several hours just to get the megamek source installed and running so I could edit it.  If anyone else knows how to install a patch without going the whole eclipse->subclipse->svn route, I'd be interested to hear it.  Otherwise, here are my notes from installing eclipse (which lets you edit and compile the source code), subclipse (which lets you download the source), along with the megamek source and the patch:

Log on installing eclipse, megamek, and patching megamek (on windows 7):

dowloaded eclipse from: http://www.eclipse.org/downloads/downloa...x86_64.zip

examined eclipse install guide: http://wiki.eclipse.org/FAQ_Where_do_I_g...Eclipse%3F

right-clicked on eclipse-java-helios-SR2-win32-x86_64.zip -> extract to -> my home directory

in directory just extracted, ran "eclipse.exe"

agreed to whatever workspace it wanted

installing subclipse according to instructions here: http://subclipse.tigris.org/servlets/Pro...eID=p4wYuA

when eclipse has started up, in menu help -> new software
typed in "http://subclipse.tigris.org/update_1.6.x" and clicked add.  named it subclipse
clicked "select all", then "next", then "next" again.
clicked "I accept..." then "finished"
clicked "ok" during some security warning
clicked "restart now"
did not report usage to subclipse team
restart now

following megamek source installation instructions here: http://megamek.info/forums/index.php?topic=25.0

eclipse has restarted, and I've selected the default workspace again.
selected new -> other -> SVN -> Checkout project from SVN.  clicked "next"
clicked "next"
put "https://megamek.svn.sourceforge.net/svnroot/megamek" in Url
FAILURE: Subversion Native Library Not Available.

subclipse page points me to http://www.sliksvn.com/en/download
clicked on Silk SVN 64 bit edition
double clicked on the msi file it downloaded
next, next, typical, next, allow program to make changes, finish

quit eclipse.  started eclipse again.
new -> other -> use existing repository (https://megamek....),
Ok, now we're back on track.
open "trunk" directory select "megamek"
clicked "finish"
in "java" section, selected "java project", next
typed "megamek" in project name box, clicked next, finish, ok
watching progress bar go.  it takes a while. 
clicked "go to workbench (looks like a curved arrow) on the "welcome to eclipse" screen.
opened megamek on the left hand side in the package explorer
right clicked l10n folder, in 'source' selected 'add as source path'
opened "lib" directory in same place.
right clicked on everything in the lib directory ending in .jar, selected "build path -> add to build path" there were 7 of these
opened src-> megamek and double-clicked on MegaMek.java in the package explorer
from top menu, selected run->run
Success.  Megamek runs.

Now to install the patch.

downloaded patch from http://sourceforge.net/tracker/?func=det...tid=448396
back to the package explorer in eclipse.  right clicked "megamek [trunk/megamek]" -> team -> apply patch
selected the downloaded patch file and clicked "finished"
from top menu run->run
megamek is running now
start scenario -> TheGreatRefusal -> 2WolfVs...
Okay, Okay
under compact, selected "Other Bot"
Okay, Okay
and now I'm playing against the other bot

Reply
#7
Thx a lot. Finally got it to work. The new bot is really really fast. Very nice job done by you.
It would be nice if it is added to the next release and if we can select it not only in campaigns but also as a replacement for the normal bot.
Reply
#8
Woot, bot enhancements!

Thanks for this. (And the Eclipse step by step.  I use Visual Studio at work so Eclipse feels goofy and I just wanna throw my hands up in the air when trying to use it  ;D .)

One thing I would recommend for future tests are to comment out lines 192-202 in TestBot.java.  The comparison will look a little better without the Thread.sleep(5000) in there which prevents massive spam of thinking messages.

Also, were you tests run under 32-bit or 64-bit java?  I've taken to always running under 64-bit with -Xmx4096m
I found that a lot of the bot slowness was due to massive time spent in GC.  Maybe there's a leak or fragmentation occurring with all the process the existing bot goes through.  But 64-bit let me give the bot a large number of units without it taking minutes per move.
Reply
#9
An patch that improves princess bot is up on sourceforge with tracker id 3355333, title: Improved Princess Bot.

Aside from fixing some bugs, princess now has a notion of how likely a shot is to cause a critical hit or catastrophic damage (at a small cost to speed).  Princess greatly desires to inflict critical damage, and is willing to risk overheat for a shot with a high likelihood of killing an enemy.  This may have given it an edge over Testbot in some 2 vs 2 battles:

1-SmokeJaguarVsSteinerDavion
Princess won 61/112 games, win probability .54 +/- .04
Princess spent 134160 ms moving, TestBot spent 12825418 ms moving, Princess took 1.0 percent as long to move
2-WolfVsIvesCompact
Princess won 126/187 games, win probability .67 +/- .03
Princess spent 465463 ms moving, TestBot spent 17150267 ms moving, Princess took 2.7 percent as long to move
3-BloodSpiritVsKurita
Princess won 89/114 games, win probability .78 +/- .03
Princess spent 170452 ms moving, TestBot spent 14781148 ms moving, Princess took 1.1 percent as long to move
4-JadeFalconVsComstar
Princess won 57/109 games, win probability .52 +/- .04
Princess spent 295112 ms moving, TestBot spent 17637791 ms moving, Princess took 1.6 percent as long to move

I would imagine that Testbot will have the advantage in battles with more units or larger maps, as Princess neither attempts to predict an enemy's move nor has units work together with any sort of coherence.  It takes longer to get good statistics on larger battles, so I have avoided testing them so far.
Reply
#10
To Tathas:
Oh hey, those lines do cause it to round up to the nearest five seconds, don't they?  Thanks for pointing that out.  It seems for the small games I've been testing where most moves take less than ten seconds to calculate, that makes for an unfair comparison.

My java is 64 bit, but I haven't been adding any memory options.  I found that the Testbot was quite quick in these 2vs2 battles.  It was the 10vs10 battles that really bogged down.  My assumption was that the time the bots take would scale the same with number of units so I could run all my tests on the small battles, but clearly the artificial five second wait makes that assumption invalid.  I'll try removing the wait and running larger battles.

Though I haven't been able to get the eclipse profiler to work, oddly enough I've found the Entity.setFacing() (or maybe it was set secondary facing) function to be a huge time sink for bot routines, so I've avoided it.
Reply
#11
The TestBot's thinking process certainly isn't linear.  The more mechs it has available to move the longer it takes cause it needs to figure out what's the best thing to do again after each move.  But at least it spawns a thread for each mech's calculations before it aggregates it all back together to decide what to do next.

Yeah if you want to watch the bot planning crawl, connect a second instance of MegaMek using the Connect as Bot option and you can watch it move the mechs all around the map and spin to each facing as it plots its turns.  That drastically slows it down though.
Reply
#12
The patch has been applied to SVN trunk.
How about adding a UI option to use princess in non-scenario games, too?
Reply
#13
Tathas:

You were right.  Pulling out the 5 second wait sped up TestBot's performance significantly on small games; Princess is now less than 10 times faster.  I also tried some of the larger games from the LawyersGunsAndMoney series.  TestBot slowed down significantly on these larger games, but it was clearly doing some worthwhile thinking, because it soundly beats Princess.

2-WolfVsIvesCompact
Princess won 80/119 games, win probability .67 +/- .03
Princess spent 280102 ms moving, TestBot spent 2175084 ms moving, Princess took 12.8 percent as long to move
1-TheMistake
Princess won 12/37 games, win probability .32 +/- .07
Princess spent 1830998 ms moving, TestBot spent 29289354 ms moving, Princess took 6.2 percent as long to move
2-ADevelopingSituation
Princess won 13/65 games, win probability .20 +/- .04
Princess spent 3397044 ms moving, TestBot spent 60428977 ms moving, Princess took 5.6 percent as long to move

BeeRockxs:

I'm shy about mucking around much in the real code, and usable UI isn't really my forte, but I'll give it a try.
Reply
#14
I just added a UI option myself.
Reply
#15
Ok, I put a patch up that gives the option to choose between TestBot and Princess in the ChatLounge.  I figure as the bots become more sophisticated, that dialog will also offer options to tune bot performance.
Reply
#16
Is the faster bot going to be part of the next release?

Davout
Reply
#17
Yes.
Reply
#18
Thanks!

Davout
Reply
#19
Is there any use for a bot that can control naval or air units?  These units don't seem to be used much in scenarios.
Reply
#20
Yes, there is a definite need for the bot to handle aerospace units. Whether or not they are used in a scenario is irrelevant. You don't need to be running a scenario to use the bot.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)