Difference between revisions of "How to AI your bot"

From RA2Wiki
Jump to navigation Jump to search
(Wikified)
Line 1: Line 1:
 
Here is a getting started guide to AIing.  
 
Here is a getting started guide to AIing.  
  
===================
 
  
The quick way to dive into AIing your bots is as follows:
+
== Get a Starcore Pack equivalent ==
  
1) Find a bot in the Starcore V3 AI pack that is similar in fighting style to your bot. There are 210 of them to choose from. Look for same type of Spinner, Rammer, Pusher, Invertible or not, etc.
+
Find a bot in the Starcore V3 AI pack that is similar in fighting style to your bot. There are 210 of them to choose from. Look for same type of Spinner, Rammer, Pusher, Invertible or not, etc.
  
2) You will need to tune your bot for AI. Note proper capitalization and spelling is important.
+
== Tune your bot for AI ==
 +
 
 +
You will need to tune your bot for AI. Note proper capitalization and spelling is important.
  
 
Name your Analog control that goes forward and backward: Forward  
 
Name your Analog control that goes forward and backward: Forward  
 +
 
Name your Analog control that goes Left and Right: LeftRight  
 
Name your Analog control that goes Left and Right: LeftRight  
 +
 
Name your button that spins your spinners: Spin  
 
Name your button that spins your spinners: Spin  
 +
 
Name your button that fires your weapons: Fire  
 
Name your button that fires your weapons: Fire  
 +
 
If you are using my Omni or OmniRam AI naming your weapon control Fire is all you need  
 
If you are using my Omni or OmniRam AI naming your weapon control Fire is all you need  
 +
 
If you are using the Flipper AI for a Flipper bot name the button that flips: Flip  
 
If you are using the Flipper AI for a Flipper bot name the button that flips: Flip  
 +
 
If you have a button for flipping your bot when inverted, name it: Srimech  
 
If you have a button for flipping your bot when inverted, name it: Srimech  
If you have a spinner, rammer or pusher that does not need to know when to activate its weapons, you are done with this part of AIing  
+
 
If you have a Poker, Hammer, Flipper, Popup or Hybrid that has these elements you will need to get the Smartzone.cfz that RFS unlocked (or similar) and put it in your Robot Arena 2 main folder to unlock the Smartzone feature. Then you will need to size and place the Smartzone. When you add the Smartzone.cfz and restart RA2 you will find the Smartzone as an option in the Power Catagory. It is a bit tricky to place because it is invisible when being positioned. It does weigh 2Kg so you may or may not want to plan for it in your staying in your weight class (I required all LW, MW and HW Starcore AI bots to stay within wieght class so they would look right on the displays). You will want to size and position the Smartzone to be where your weapons hit or where you want the opponent to be before you activate your attack systems.  
+
If you have a spinner, rammer or pusher that does not need to know when to activate its weapons, you are done with this part of AIing
 +
 +
If you have a Poker, Hammer, Flipper, Popup or Hybrid that has these elements you will need to get the Smartzone.cfz that RFS unlocked (or similar) and put it in your Robot Arena 2 main folder to unlock the Smartzone feature. Then you will need to size and place the Smartzone. When you add the Smartzone.cfz and restart RA2 you will find the Smartzone as an option in the Power Catagory.  
 +
 
 +
It is a bit tricky to place because it is invisible when being positioned. It does weigh 2Kg so you may or may not want to plan for it in your staying in your weight class (I required all LW, MW and HW Starcore AI bots to stay within wieght class so they would look right on the displays). You will want to size and position the Smartzone to be where your weapons hit or where you want the opponent to be before you activate your attack systems.  
 +
 
 
If you put in a Smartzone name it: weapon (Note: All lower case)
 
If you put in a Smartzone name it: weapon (Note: All lower case)
3) When done (and this is a shortcut) In the Bot Lab name your bot the exact same name as the bot you are wanting to replace for AI testing. Doing this will let you test your bot as an AI without getting deep into writing your own AI for now.
 
  
3 alternate) The other choice would be to keep your bot name and edit the Bindings.py file (make a backup first). Copy and paste the AI line you are wanting to use to a blank line in the Bindings.py file. Then change the name of the bot listed in the new AI line to the exact same name as your bot.
+
== Preparing your bot's name ==
 +
 
 +
When done (and this is a shortcut) In the Bot Lab name your bot the exact same name as the bot you are wanting to replace for AI testing. Doing this will let you test your bot as an AI without getting deep into writing your own AI for now.
 +
 
 +
 
 +
ALTERNATIVELY
 +
 
 +
 
 +
The other choice would be to keep your bot name and edit the Bindings.py file (make a backup first). Copy and paste the AI line you are wanting to use to a blank line in the Bindings.py file. Then change the name of the bot listed in the new AI line to the exact same name as your bot.
  
4) Export the bot naming it Bot0, Bot1, Bot2, Bot3, Bot4 or Bot5 depending on the position of the bot it is replacing in Starcore AI pack. For example if you wanted to replace Maelstrom in the Spin Doctors, it is in the 3rd position that team and since the game counts up from Zero you would name your bot, Bot2
+
== Exporting ==
 +
Export the bot naming it Bot0, Bot1, Bot2, Bot3, Bot4 or Bot5 depending on the position of the bot it is replacing in Starcore AI pack. For example if you wanted to replace Maelstrom in the Spin Doctors, it is in the 3rd position that team and since the game counts up from Zero you would name your bot, Bot2
  
5) Exit the game and go to your \Robot Arena 2\Robot Designs folder and copy the Bot2 you saved in step 4 and change to the \Robot Arena 2\AI folder and go to the team you wanted to replace a bot of (again the game starts counting at Zero). So in this example for replacing Maelstrom of the Spin Doctors you would go to Team 0 and rename the existing Bot2.bot to something like Bot2.bot.Maelstrom and Paste in your Bot2.bot
+
== Backuping old AI ==
 +
Exit the game and go to your \Robot Arena 2\Robot Designs folder and copy the Bot2 you saved in step 4 and change to the \Robot Arena 2\AI folder and go to the team you wanted to replace a bot of (again the game starts counting at Zero). So in this example for replacing Maelstrom of the Spin Doctors you would go to Team 0 and rename the existing Bot2.bot to something like Bot2.bot.Maelstrom and Paste in your Bot2.bot
  
6) If you are lucky that your bot faces the same way as the bot you are replacing you are done here and your bot should start fighting with the AI of the bot you replaced. If you didn't make your bot facing the same way as the bot you are replacing you can you will need to edit the Bindings.py file to tell the game which way your bot should face.  
+
== Fixing orientation ==
 +
If you are lucky that your bot faces the same way as the bot you are replacing you are done here and your bot should start fighting with the AI of the bot you replaced. If you didn't make your bot facing the same way as the bot you are replacing you can you will need to edit the Bindings.py file to tell the game which way your bot should face.  
  
 
To edit Bindings.py to correct facing of an AI bot go to the \Robot Arena 2\AI folder and back up the existing Bindings.py (This is very important. It is easy to induce typos in this file and the game is very unforgiving if you do.)  
 
To edit Bindings.py to correct facing of an AI bot go to the \Robot Arena 2\AI folder and back up the existing Bindings.py (This is very important. It is easy to induce typos in this file and the game is very unforgiving if you do.)  

Revision as of 14:18, 5 November 2007

Here is a getting started guide to AIing.


Get a Starcore Pack equivalent

Find a bot in the Starcore V3 AI pack that is similar in fighting style to your bot. There are 210 of them to choose from. Look for same type of Spinner, Rammer, Pusher, Invertible or not, etc.

Tune your bot for AI

You will need to tune your bot for AI. Note proper capitalization and spelling is important.

Name your Analog control that goes forward and backward: Forward

Name your Analog control that goes Left and Right: LeftRight

Name your button that spins your spinners: Spin

Name your button that fires your weapons: Fire

If you are using my Omni or OmniRam AI naming your weapon control Fire is all you need

If you are using the Flipper AI for a Flipper bot name the button that flips: Flip

If you have a button for flipping your bot when inverted, name it: Srimech

If you have a spinner, rammer or pusher that does not need to know when to activate its weapons, you are done with this part of AIing

If you have a Poker, Hammer, Flipper, Popup or Hybrid that has these elements you will need to get the Smartzone.cfz that RFS unlocked (or similar) and put it in your Robot Arena 2 main folder to unlock the Smartzone feature. Then you will need to size and place the Smartzone. When you add the Smartzone.cfz and restart RA2 you will find the Smartzone as an option in the Power Catagory.

It is a bit tricky to place because it is invisible when being positioned. It does weigh 2Kg so you may or may not want to plan for it in your staying in your weight class (I required all LW, MW and HW Starcore AI bots to stay within wieght class so they would look right on the displays). You will want to size and position the Smartzone to be where your weapons hit or where you want the opponent to be before you activate your attack systems.

If you put in a Smartzone name it: weapon (Note: All lower case)

Preparing your bot's name

When done (and this is a shortcut) In the Bot Lab name your bot the exact same name as the bot you are wanting to replace for AI testing. Doing this will let you test your bot as an AI without getting deep into writing your own AI for now.


ALTERNATIVELY


The other choice would be to keep your bot name and edit the Bindings.py file (make a backup first). Copy and paste the AI line you are wanting to use to a blank line in the Bindings.py file. Then change the name of the bot listed in the new AI line to the exact same name as your bot.

Exporting

Export the bot naming it Bot0, Bot1, Bot2, Bot3, Bot4 or Bot5 depending on the position of the bot it is replacing in Starcore AI pack. For example if you wanted to replace Maelstrom in the Spin Doctors, it is in the 3rd position that team and since the game counts up from Zero you would name your bot, Bot2

Backuping old AI

Exit the game and go to your \Robot Arena 2\Robot Designs folder and copy the Bot2 you saved in step 4 and change to the \Robot Arena 2\AI folder and go to the team you wanted to replace a bot of (again the game starts counting at Zero). So in this example for replacing Maelstrom of the Spin Doctors you would go to Team 0 and rename the existing Bot2.bot to something like Bot2.bot.Maelstrom and Paste in your Bot2.bot

Fixing orientation

If you are lucky that your bot faces the same way as the bot you are replacing you are done here and your bot should start fighting with the AI of the bot you replaced. If you didn't make your bot facing the same way as the bot you are replacing you can you will need to edit the Bindings.py file to tell the game which way your bot should face.

To edit Bindings.py to correct facing of an AI bot go to the \Robot Arena 2\AI folder and back up the existing Bindings.py (This is very important. It is easy to induce typos in this file and the game is very unforgiving if you do.) Open up the Bindings.py with Notepad or your favorite text editor that does not change formatting (i.e. turn off Word Wrap). Go to the line of the bot you are replacing with your bot. In this example it would be the Maelstrom line in Team #0 Maelstrom does not have a 'nose' command because he is facing the default direction. Depending on the facing of your bot (Trial and error here, hard to describe how to tell which setting to use) you would add to the list.append line for the bot you are replacing (Maelstrom in this example) in the same style of many of the other bot lines in the Bindings.py (Note: Position between the {} is your choice but try to do similar to other lines: 'nose':math.pi/2, or 'nose':math.pi, or 'nose':-math.pi/2, If you built your bot on an oblique angle there are more exotic settings to adjust for that, but that is a more advanced tutorial about radians. Basically many computer physics models do not use Degrees, they use Radians where 0 (or PI*2) Radians = 0 (360) Degrees, PI/2 Radians = 90 Degrees, PI Radians = 180 Degrees, PI*3/2 (or -PI/2) Radians = 270 Degrees Save your changes to Bindings.py and if you didn't induce any typos your bot should now start facing the right direction as an AI. If not, you did make the backup of Bindings.py, didn't you? If you need to adjust the nose command again or start over copy the backed up Bindings.py to Bindings.py and try again or edit the one you have been adjusting. This is a good way to get your Bot AIed by using an existing AI line and get it inserted in a pack for testing.

Let me know if there are any questions on these instructions or if there is interest to learn more...

Starcore