An AI class is a special kind of class that contains the logic for controlling a bot.
Tip: The walk-through topics in this guide take you step by step through the process of
creating your solution, adding an AI class and code, and testing/debugging.
An AI class must be in a project that outputs a class library assembly (.dll file), because this is the
type of file that is processed by the Game Viewer when setting up a game. You can add any
number of these classes to a project, and the resulting assembly will contain all those programs.
Therefore, each assembly is effectively a collection of AI programs.
To create an AI program, in the AI project you create a class that derives from
Omega.Bots.AI.BotAIBase and implement the Init and Run methods.
The Init method is called when a game is being prepared, before it starts, so you can perform
one-time initialization there, such as subscribing to events. Adding code to the Init method is
optional, depending on the needs of your program. If you do, you should only include code that will
be quickly processed, and it should not attempt to physically control the bot. (Otherwise the results
are unpredictable and your program might terminate with an error.)
The Run method is called when the game is started, so that method should contain the logic that
drives the bot's actions during the game. What you can do there is almost boundless. You can
use all the facilities of the programming language you're using and make full use of the Microsoft®
.NET Framework (with a few exceptions for security purposes, see Security Notes).
The Run method should typically have a loop that indefinitely repeats a series of instructions,
because the program will end if the Run method completes. (Although infinite loops are generally
something to be avoided in structured programming, it is appropriate in the case of our Run
method since it allows the program to stay alive until the game ends.)
Recommended Topics