I have a very good understanding of the current state of the Lua AI interface, thought I'd clarify some information because I think some people might be looking for easy answers that don't actually exist. For brevity AI means "Lua AI" unless I specifically say "native AI" (meaning the C++/Java interfaces)
Synced Lua AI
* The current AI interface is synced and gadget-based.
* It runs in the same environment as other gadgets.
* It cheats automatically (can access enemy data), but
* Can fake "unsynced" by filtering out data it "shouldn't know" (eg, ignore unseen units for team X). I think CRAIG does this and I also have some wrapper code based on (trepans?) old work encapsulating each team AI in a closure.
* Can play on a team/alliance
* Runs simultaneous on cpus of all players (like all synced code)
* Can send serialised data to unsynced widgets (insecurely)
* You can select them from the lobby if the game includes a LuaAI.lua file
* Therefore, Lua AI must be known/supported by game and shipped in the game package, unless..
* You write a mutator "game" with your AI and give it to all players, eg. create BA6-MyAI.sd7 that either wholly includes or better yet requires/depends on the main game.
* Cannot read game-specific data (eg, custom resources or rules) unless the game deliberately exposes them.
Unsynced Lua AI
* Provided the game allows user widgets you can have an AI help your units
* AI can only see detailed data for your team. Enemies have limited data based on LOS/radar
* Only runs on your computer and can be installed in system spring path
* Can communicate with gadgets or synced AI when the gadget allows for it.
* Can be blocked if widgets are blocked/disabled.
* Can cheat if cheats are enabled, but all players get cheat
* Can't be selected in lobby but can be enabled/disable at any time (assuming AI widget is written to support "resuming" or mid-game starts)
* Can cheat via a synced gadget and synced<->unsynced communication (insecure)
* Cannot read game-specific data (eg, custom resources or rules) unless the game deliberately exposes them.
AI over TCP/UDP Unsynced
* Can be done in a widget (Unsynced Lua AI) using socket networking library (LuaSocket) which is already available to communicate with an external AI.
* Good knowledge of socket-based networking recommended
* Language of AI would be irrelevant as long as it supported sockets.
* Can be blocked if widgets are blocked/disabled.
* May require some user settings changes (LuaSockets allow/deny list)?
* Not possible or advisable for Synced AI because network issues will desync game.
* Cannot read game-specific data (eg, custom resources or rules) unless the game deliberately exposes them.
Native AI (C++/Java,...)
* Currently required to run a few popular BA/XTA playing AI, but
* Is in a poor state in practically all respects
* Has limited access to Lua state, therefore is problematic with non-*A games. Spring 1944 comes to mind as it uses Lua for much of it's game logic.
* Known to cause crashes and desyncs.
* Known to have old unpatched bugs.
* Can break engine compiling under some setups.
* Cannot read game-specific lua data (eg, custom resources or rules) unless the game deliberately exposes them.
I highlight the note about "game-specific" because it's wholly relevant to the debate on whether an AI should require the support or permission of the game/mod developer. When the debate gets emotional or moralistic it's easy to overlook how many factors relevant to the "state" of the game your AI will NEED to be an effective player and how much work and planning is required to expose and manipulate those factors. A simple case can illustrate this:
Code: Select all
== game logic ==
while not gameover
if team flag is captured then
enemy_has_flag = true
== ai logic ==
if enemy_has_flag then
teleport units to flag
The logic seems correct but the question is how does the AI logic get the state of enemy_has_flag or the current location of the flag to begin with? How does the AI activate the teleport feature if it was implemented in Lua and not the engine? Do we make them global (add to _G), do we receive a callback, perform a callin, send an "event" message, ...?
All of these approaches work in theory so the questions might be asked "which method(s) are best, and for who?" and "should the game and/or engine endorse or enforce particular method(s)?"
Neither question seems to have a simple answer. I'm not even taking into account here what the players and engine devs might want and how much work is involved in each option. What happens when the game interfaces are added and removed over time? What about the broader AI research / bot battle communities who might might to test their "general purpose" RTS AI on your Spring game?
Even a very simple game is going to present these challenges so what it boils down to in reality is that an AI author is going to have a much easier time of things by
working directly and cooperatively with the game author(s). This will remain true regardless of the interface used. There isn't much the Spring engine developers can do about it "generally" other than either restrict/remove options OR provide as many options as can be practically maintained. There's unlikely to be general agreement on that because the needs of all developers - engine, game and AI, will be different in nearly all individual cases.