
Klingon Academy AI Trainer Tutorial
KA AI Trainer...
Introduction:
Undoubtedly, we’ve all cursed at Klingon Academy’s AI ships at one time or another for being so apparently stupid. We all just want the enemy to fire that Pakled captain out of a torpedo tube and put someone in there that will give a meaningful fight – and not just resort to ramming.
When a new ship is loaded up in KA it’s AI starts learning from it’s environment, other AI ships, the Player, etc., but whenever the simulation is reset, it looses whatever it’s learned during that session. What the KA Developers did to overcome this with the stock ships was a little script called the AI Trainer. Running ships under the Trainer allows the script to write .mem files into the ship’s folder that basically records a list of standard tactics used against a particular ship, and how effective these tactics were against this ship. So when the AI ship is confronted with a ship it has a .mem file associated with it, it consults that file and knows what works well, and what doesn’t.
The difference between fighting trained and untrained ships can be rather dramatic: trained ships know how to better evade incoming fire, withdraw when they’re overwhelmed, and manage to avoid ramming far better than untrained ships, just to name a few improvements.
The game comes with a set of .mem files for each major ship included with the ship folder of the game’s ships, however if you’re using a modded ship these are of no use. An .mem file is needed for each pairing, so even if you have an .mem file under the stock Constitution’s folder for use against a stock K’T’Inga, this won’t be of any use against a modded K’T’Inga, regardless of how similar the two ships are. The two ships must be set up under the AI Training script and run for .mem files to be generated. Once generated, these two ships will fight each other more intelligently when meeting in a Quick Battle or scripted environment.
Setting Up The Script:
Unzip the contents of the Zip file:
Place the “kaaix.int” file into your KA scripts folder.
Place the “ai_que.txt” and the “ka_ai_trainer.exe” file into your main KA folder.
You will need to add the following line to your missions.txt file:
kaaix.int:AI Trainer Script
Setting Up Battles:
The ships to be trained are set up in the “ai_que.txt” file. Simply open it with notepad, and you will be presented with slots for 20 ships, for a total of 10 battles. This allows you to train ships in batches: you can train a variety of ships at once, train one ship against a variety of enemies, or train only two ships under multiple battles to speed up the training of just the one set. Slots cannot be added or subtracted to the file, although a #NULL# entry can be placed in slots to reduce the number of battles if necessary. The contents of the “ai_que.txt” file will typically look like this:
PlaceThisTextOnTheFirstLineOfThisFileToNotUseBatchAITraining
g01|#KECC Bird Of Prey#
g02|#KECC Bird Of Prey#
g03|#KECC Bird Of Prey#
g04|#KECC Bird Of Prey#
g05|#KECC Bird Of Prey#
g06|#KECC Bird Of Prey#
g07|#KECC Bird Of Prey#
g08|#KECC Bird Of Prey#
g09|#KECC Bird Of Prey#
g10|#KECC Bird Of Prey#
e01|#FEC USS Grissom#
e02|#FFF USS Okinawa#
e03|#FDD USS Akula#
e04|#FCL USS Reliant#
e05|#FCA USS Enterprise#
e06|#FCC USS Lexington#
e07|#FBCH USS Excelsior#
e08|#FDN USS Ulysses#
e09|#FBB1 USS Missouri#
e10|#FBB2 USS Yamato NX#
>> EOF <<
In this example the stock Bird of Prey is being trained simultaneously against a variety of stock Starfleet ships. While the script is running, this will generate individual .mem files in each of the listed Starfleet ships’ folders with information on the Bird of Prey, and also will generate 10 .mem files in the Bird of Prey’s folder, one for each ship that it’s being trained against.
Each entry is just the latter half of a ships QBShips.txt line, or everything that occurs after the “=”. This is also the “Name” entry in the ship’s shp file.
Another example is simply a one-on-one training session:
PlaceThisTextOnTheFirstLineOfThisFileToNotUseBatchAITraining
g01|#KECC Bird Of Prey#
g02|#KECC Bird Of Prey#
g03|#KECC Bird Of Prey#
g04|#KECC Bird Of Prey#
g05|#KECC Bird Of Prey#
g06|#NULL#
g07|#NULL#
g08|#NULL#
g09|#NULL#
g10|#NULL#
e01|#FCA USS Enterprise#
e02|#FCA USS Enterprise#
e03|#FCA USS Enterprise#
e04|#FCA USS Enterprise#
e05|#FCA USS Enterprise#
e06|#NULL#
e07|#NULL#
e08|#NULL#
e09|#NULL#
e10|#NULL#
>> EOF <<
This example sets up 5 individual battles between the stock Bird of Prey and the stock Constitution. The remaining 5 slots will be left empty due to the #NULL# entry in them. This will allow the .mem files generated in the KECC and FCA folders to accumulate their information much faster: when running the same ships in multiple simultaneous battles the information seems to be written to the same .mem, regardless of what battle the information comes from. More simultaneous battles can be set up in this way, to the maximum of ten, or 9 of the battles can be left #NULL# for a single battle to improve game performance.
Running the AI Training Script:
You will have to run “ka_ai_trainer.exe” from your KA folder to use the AI Training script. Launching the game normally through the Launch Screen or via “KA.exe” won’t allow the trainer to load properly. Once loaded, KA will appear to operating normally. Simply select the “Simulator” button, then select the “AI Training Script”. You will be loaded into a Point Camera ship, capable of movement and targeting, but the AI ships will disregard you.
From here you can observe the battles as they progress. In place of the HUD’s usual Multidispaly on the left will be a list of battles. Listed in each battle will be the condition of each ship (g/e), and the accumulated “battles” that have been written to the .mem file. Pressing “.” or “,” will allow you to jump from one battle to the next to observe, or hitting “m” will allow you to type in a number to skip to that battle. Pressing “u” will force the battle list to update, of which will tell you how many victories have accumulated in each battle, so you can gage how much experience the .mem files are gathering.
The following is a list of hotkeys that can be used in the script:
/ or ? = help list
e = terminate the current battle you're viewing
t = learn toggle (turns off that battles influence on the .mem file)
r = reset the ships (deletes the ships and has them start the battle over)
u = forces the stats on the HUD to be updated (normally updates whenever a battle round starts)
m = This will ask you for a number. Press 0 through 9 and enter to go to that battle
, = Move to previous system/battle
. = move to next system/battle
Script Operation:
It’s important to have your game set up for maximum performance while running the AI Training script. The faster the game runs the script the faster it accumulates experience for the ships that are training. Since visual/audio quality is unimportant, you can turn these down, plus any other tweaks to help smooth out performance. The script automatically turns the game speed up to maximum, so you won’t need to worry about that.
When making the game, the Developers would leave the Trainer running overnight to accumulate about 100 battles for most ships, and around 75 for the heavier ships. With today’s faster computers the same amount of battles can be accomplished in just an hour or two, depending on how fast your computer is and how the training ships are set up. You also have the option of training the ships for longer or shorter periods, personal preference will let you strike a balance between the AI’s performance vs. training time. The script can be run indefinitely, so it will only stop when you exit the training script.
Note that if a ship’s stats or surfaces are changed, this can throw off the information collected in the .mem file. If you’ve trained a ship then modified it, you will likely have to re-train it.
Special Thanks to:
Briareus, RedHotChiliDog, Uwe, John Addison and Jburrows
Main Page
If you have any questions or comments about this article, you can reach me at PXS@hotmail.com.
2004/12/23