Winbots | |||||||||||
|
Here are the steps to write your own bot and run it. Of course, you must have downloaded the winpackage.zip file and unzipped it to a directory, say winpackage. Writing and Compiling: 1. First set the classpath to the winbots.jar file in the winpackage directory. This guide is written with Windows users in mind. Other platform users simply substitute the shell prompt with your own. For eg. C:\>cd winpackage C:\winpackage>set classpath=%classpath%;winbots.jar;2. In your source file, import the winbots package as import winbots.*;3. Write a Java class to extend BaseBot and start by writing your code in the start method. It should look like this
import winbots.*; public class MyFirstBot extends BaseBot { public void start() { init("My First Bot"); fire(10,20); ... } }4. Compile the source file. If it says winbots package is not found, or BaseBot is missing, ensure you've set the classpath correctly. 5. Run the combat server, giving the map and your bot as arguments as C:\winpackage>java winbots.BotRunner samplemap.txt MyFirstBotThat's it. A window should now open up, showing the map graphically. Your bot should get loaded in one of the load locations and should start doing whatever you've programmed it to do. The game runs to 100 seconds, and at the end, the battleground screen is closed and a new window reporting the result opens up. Important Details:
The syntax is C:\winpackage>java winbots.BotRunner [mapname] [botname1] [botname2] ..where [mapname] is the filename of the map file. [botname] is the CLASS file of the bot (without the .class extension.) You're not restricted to one or two bots. You can give as many bots as there are load locations in the map. For eg, C:\winpackage>java winbots.BotRunner samplemap.txt FirstBot SecondBotThis will load samplemap.txt as the map file and bots FirstBot and SecondBot as the competing bots. You can also run a single bot as C:\winpackage>java winbots.BotRunner samplemap.txt FirstBot |