MCPcopy Create free account
hub / github.com/bwapi/bwapi / AIModule

Class AIModule

bwapi/include/BWAPI/AIModule.h:27–208  ·  view source on GitHub ↗

AIModule is a virtual class that is intended to be implemented or inherited by a custom AI class. The Broodwar interface is guaranteed to be initialized if any of these predefined interface functions are invoked by BWAPI. @warning Using BWAPI in any thread other than the thread that invokes these functions can produce unexpected behaviour and possibly crash your bot. Multi-thre

Source from the content-addressed store, hash-verified

25 ///
26 /// @ingroup Interface
27 class AIModule
28 {
29 public:
30 AIModule();
31 virtual ~AIModule();
32
33 /// <summary>Called only once at the beginning of a game.</summary> It is intended that the
34 /// AI module do any data initialization in this function.
35 ///
36 /// @warning
37 /// Using the Broodwar interface before this function is called can produce undefined
38 /// behaviour and crash your bot. (During static initialization of a class for example)
39 virtual void onStart();
40
41 /// <summary>Called once at the end of a game.</summary>
42 ///
43 /// <param name="isWinner">
44 /// A boolean value to determine if the current player has won the match. This value will
45 /// be true if the current player has won, and false if either the player has lost or the
46 /// game is actually a replay.
47 /// </param>
48 virtual void onEnd(bool isWinner);
49
50 /// <summary>Called once for every execution of a logical frame in Broodwar.</summary>
51 /// Users will generally put most of their code in this function.
52 virtual void onFrame();
53
54 /// <summary>Called when the user attempts to send a text message.</summary> This function
55 /// can be used to make the bot execute text commands entered by the user for debugging
56 /// purposes.
57 ///
58 /// <param name="text">
59 /// A string containing the exact text message that was sent by the user.
60 /// </param>
61 ///
62 /// @note
63 /// If Flag::UserInput is disabled, then this function is not called.
64 virtual void onSendText(std::string text);
65
66 /// <summary>Called when the client receives a message from another Player.</summary> This
67 /// function can be used to retrieve information from allies in team games, or just to
68 /// respond to other players.
69 ///
70 /// <param name="player">
71 /// The Player interface object representing the owner of the text message.
72 /// </param>
73 /// <param name="text">
74 /// The text message that the \p player sent.
75 /// </param>
76 ///
77 /// @note
78 /// Messages sent by the current player will never invoke this function.
79 virtual void onReceiveText(Player player, std::string text);
80
81 /// <summary>Called when a Player leaves the game.</summary> All of their units are
82 /// automatically given to the neutral player with their colour and alliance parameters
83 /// preserved.
84 ///

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected