Sarna News: Bad 'Mechs - Clint

Essay: Playing a Better Bot

The below essay was written by poster Taharqa (dead link) and posted on his blog (June 2009), Taharqa's Corner. (dead link) It is consolidated, edited and wikified here with his permission.

We all have had the experience of waiting what seems hours for the bot in MegaMek to move. Many people give up on having games beyond about a lance in size when playing the bot due to the exponentially increasing time that the bot uses to calculate its moves. There are several ways that you can make the bot more efficient without a radical loss of time efficiency. I am going to outline below some of the procedures that I use when I play large games against the bot.

What Not To Do: Opening up a Separate Window[edit]

When you first start up MegaMek, you get a splash screen with several buttons. One of those buttons is “Connect as Computer Player.” This allows you to start up a new instance of MegaMek and connect to an ongoing game as a bot. Never add a bot using this method. Because you have a separate window with a view of the map, the bot will animate every possible path it could take for every possible unit during its turn. This will slow the bot down by at least a magnitude of 10, probably more. Frankly, I think we should get rid of that button to discourage this practice. The better way to add a bot to an existing game is to use the /replacePlayer command in the chat window. I will outline how to do that later.

Individual Initiative[edit]

Probably the simplest approach to speeding up the bot is to turn on the unofficial individual initiative option. This option will force the bot to move a particular unit each time, and so instead of calculating potential movement paths for every unit, it will only calculate them for one unit.

The major drawback is that this method will also force you to use individual initiative. There is however a way around this problem. First you need to find the file called located in the mmconf directory of your MegaMek directory. this file is actually just a simple text file that can be opened with a simple text editor (NotePad in Windows, TextEdit in Mac, lots of stuff in Linux). In this file, you will find a line that looks like this:


Simply change that line to:


Once you set that up, the bot will use individual initiative for its own units, but you do not have to. This speeds up the bot considerably. However, it comes with some tactical loss, because the bot doesn’t have the same options as you. Although many people find this method to be satisfactory, I typically employ a different approach, outlined below.

Splitting the Bot Up[edit]

I find that by splitting the bot up into several bots and putting them all on the same team, I can get the bot to run pretty fast even for large games. On my computer, I have been able to run battalion size games relatively quickly with this approach.

Let me illustrate. I will set up the second scenario from the Kings and Pawns (dead link) scenario pack available for free from the Classic BattleTech download page. (dead link) I will play the Third Dismal Disinherited and the bot will play a force made up of two and a half 'Mech lances from the Stealthy Tigers and a vee lance of the Republican Guard. I will split the bot into three groups. The first group will be the first Stealthy Tigers lance (”Mauler lance”), the second will be the second Stealthy Tigers lance plus the remaining two 'Mechs (”Deep Claw lance”) and the third will be the Republican Guard vee lance. In order to do this, after setting up my own forces with MegaMek, I start up three additional MegaMek clients (the same way you normally would start up MegaMek) and on the splash screen instead of choosing “start new game” choose “connect to game” with localhost as the host name.

Make sure you set up everything just as you want it and most importantly be sure to put all three of the bot’s players on the same team as shown below in my example:

MegaMek multiple bot.png

Once everything is set up, start the game by clicking done for each client. I usually also like to deploy the bot’s units as it will often choose very stupid deployments. Once that is done, the next step is to kick the bot out. You can do this by just quitting the MegaMek clients for the bot players or by using the/kick command. To use the kick command, first use type /who into the chat window. In my case, I see the following reported back.

***Server: Listing all connections...
***Server: [id#] : [name], [address], [pending], [bytes sent], [bytes received]
***Server: 0 : ThirdDismalDisinherited, /, true, 149691, 55526
***Server: 1 : StealthyTigersMaulerLance, /, false, 102835, 17714
***Server: 2 : StealthyTigersDeepClawLance, /, false, 85928, 26210
***Server: 3 : RepublicanGuard, /, false, 58825, 15669
***Server: end list

This gives me the number associated with each player. To kick a player, you need to type “/kick #” where # is the player number, so I type:

/kick 1
kick 2
/kick 3

I get a message saying the player is disconnected and they show up as ghosts. I can now use the /replacePlayer command to replace each of these players with a bot.

/replacePlayer StealthyTigersMaulerLance
/replacePlayer StealthyTigersDeepClawLance
/replacePlayer RepublicanGuard

It takes a second to start up a new bot, so their will be a little delay between issuing the command and getting a response. This will start up a new bot client for each of my opposing players. That’s it!

I find that the combination of kick and /replacePlayer are often useful at later points in the game when I want to take over the bot temporarily to tell it to do something. For example, if the bot had a 'Mech with both legs and an arm missing and a shot-out gyro, I might /kick it momentarily, start up a new MegaMek client, connect to the game, and eject that pilot. Then I would kill that client and use /replacePlayer to start up the bot again.

Why does the Bot Suck?[edit]

BattleTech is a very complex game and it is difficult to build an efficient AI that can really be a challenge for experienced players. That having been said, I have two pieces of advice for getting a better bot experience.

  1. The simpler the terrain and smaller the forces, the “smarter” the bot will be.
  2. The less advanced rules and advanced equipment you use, the “smarter” the bot will be.