Are there Campaign-AIs required

Are there Campaign-AIs required

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
PauloMorfeo
Posts: 2004
Joined: 15 Dec 2004, 20:53

Are there Campaign-AIs required

Post by PauloMorfeo »

I'm looking to get back into AI coding and I want to build a proper AI.

The most obvious thing to do is a skirmishing AI, for 1v1s. However, it popped to mind that an AI agent to play campaigns is also a very cool thing to do, and maybe something that's very lacking in the world of SpringRTS (at least to my knowledge when I last been involved).
  • Are there already existing "Campaign AIs"?
  • Is it reasonable to do it? (can't think of a reason why not, but maybe there's issues I I'm not thinking of)
  • Are there any mods/games/campaigns that would require such a thing?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Are there Campaign-AIs required

Post by gajop »

Making an AI play missions would be completely useless, self-serving and a really cool thing to do.

If you're willing to put effort in it, I'll make the Scened mission data (triggers and initial units) available through GameRules in JSON format so you could access it in an AI written in arbitrary programming languages. You should probably focus on small, well-defined problems first before going to a general-purpose mission solver.
User avatar
PauloMorfeo
Posts: 2004
Joined: 15 Dec 2004, 20:53

Re: Are there Campaign-AIs required

Post by PauloMorfeo »

This is what I infer from your reply:
- No, there's no AIs specialized on Compaigns;
- No, there's no one actively requiring them (either because no one is interested in creating campaigns or because no one is expecting such an AI to exist / come to exist) (*);
- You're proposing the idea of a change to the engine where the engine feeds the AI with a JSON specifying the behaviour? (**)


* No one wanting to create a campaign makes creating suitable AIs an exercise of futility. No Campaign-AIs makes creating campaigns an exercise of futility. We appear to have an egg-chicken problem...


** I'm not sure that would be the best idea (or maybe I haven't understood well what you meant), since that would be somewhat inflexible and rely too much on the low level AI.

To my understanding (I don't know the Lua side of things well), I believe that whatever solution is implemented to control campaigns there should be 2 controllers: the low-level AI controller and the high level campaign/mod control. The low-level should be coded at a lower level (C++ or Java) but most definitely the higher level control should be done by some form of higher level scripting (Lua, most likely).

That is, the AI (low-level) would be kind of an API responding to instructions from the high-level control and execute the behaviour in detail, like how/when to become aggressive (supported by some rules), how to grow the economy (again supported by rules, like: "don't exceed +200E and only use solar panels"), etc.

On the higher-level control, Lua(?) would control things like when/how to trigger victory/loss conditions, send the AI notifications of change in aggressiveness (ex: user has crossed the river - start attacking it), what point of the map it should focus its defence attention on, when/which pauses+cut-scenes to trigger, etc, all things that would be either hard, impossible or just unsuitable to be controlled/decided/changed by the low-level AI during development of a campaign.

I reckon the best option would be to exist some kind of interface with which a Lua script could communicate with an AI to send it instructions?
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Are there Campaign-AIs required

Post by zwzsg »

For Spring missions, I once made an AI whose goal was to rebuild lost units and give them back their order queues. Maybe this doesn't count since usually people think of AI RTS as one that can play just like a human in multiplayer match, starting with a lone commander and from there building sprawnling base and attack forces. But I believe for single player, it's more enjoyable to have a defensive AI, that gives you all the time you want to build, and lets you try as many times as you want to attack it, than one that would bulldoze you if you didn't quell its expansion in the first minutes.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Are there Campaign-AIs required

Post by FLOZi »

I thought Paulo was meaning an AI to control the opponent in the campaign, not as the protagonist.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Are there Campaign-AIs required

Post by Silentwings »

In case its useful, a while ago I made one to control enemy constructors during missions (and it does nothing intelligent, just stops them being idle), because in my missions each (other) enemy unit is controlled by very simple preset AI all of its own. http://imolarpg.dyndns.org/trac/balates ... tor_AI.lua

I think there are definately use case for mission AIs, but they have to be quite closely tied to the missions. With the ability to specify what/when units are controlled by the AI and what such units can/can't do in general terms, it could work.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Are there Campaign-AIs required

Post by gajop »

Now I have a feeling I misunderstood on what you meant by "Campaign AIs". If you're talking about an AI that would play _against_ the player in campaigns/missions (as FLOZI mentions), that would probably be your average Null AI or Skirmish AI with some special rules that would define it's attack behavior. Imo, there's no need to spend much time on this.

I was thinking about the protagonist role, but that's really an exercise in building human-like AIs just for competition purposes or research.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Are there Campaign-AIs required

Post by AF »

What would a mission AI need to do? Perhaps:

- Maintain a quota/inventory of units with an upper limit
- Constrain building within a certain area
- Maintain an economy at a certain level, building towards it but never passing it
- Favour certain units and not build others ( e.g. if a mission introduces a new unit type, an AI might build units vulnerable to that type, or be introduced their own type )

Shard should be able to do these things with small modifications, but I don't see this being super useful until a lua AI version of its interface is finished so the native components can be discarded
User avatar
PauloMorfeo
Posts: 2004
Joined: 15 Dec 2004, 20:53

Re: Are there Campaign-AIs required

Post by PauloMorfeo »

zwzsg wrote:For Spring missions, I once made an AI whose goal was to rebuild lost units and give them back their order queues. Maybe this doesn't count since ...
No, no! That's exactly what I meant. I agree with you - that's what a proper Campaigns AI is like.
FLOZi wrote:I thought Paulo was meaning an AI to control the opponent in the campaign, not as the protagonist.
Ditto
Silentwings wrote:... I think there are definately use case for mission AIs, but they have to be quite closely tied to the missions. With the ability to specify what/when units are controlled by the AI and what such units can/can't do in general terms, it could work.
AF wrote:What would a mission AI need to do? Perhaps:

- Maintain a quota/inventory of units with an upper limit
- Constrain building within a certain area
- Maintain an economy at a certain level, building towards it but never passing it
- Favour certain units and not build others ( e.g. if a mission introduces a new unit type, an AI might build units vulnerable to that type, or be introduced their own type )
...
Exactly - a campaign focused AI can/should be .. less competent (easier to code) but on the other hand more complex: it needs strong specification of behaviour from an external source instead of having hard-coded one single major override - Explore->Expand->Exterminate. That is, if the AI is to guard the bridge on Mission#1 and attack lightly on Mission#2, it is unreasonable to hard-code that behaviour in the AI (one AI per mission!? Sucks. Recompile the Java AI for each configs change!? Sucks).

So, those behaviour specifications need to come from an external source for it to be feasible. I can think of 2 sources of behaviour specification (and I don't know where any of these is doable in Spring):
#1- configuration files;
#2- instructions from the mission's scripting.

#1
Something like loading a JSON file or Lua config file or whatever, with some variables describing the behaviour, like:

Code: Select all

MaxEnergyProd=200;
Expand=no;
GuardAreaX=123;
GuardAreaZ=456;
This, however, is very limiting as it would be hard to make variable behaviours throughout the mission (like the AI getting "angry" at you stealing their sacred gas - aka: some deity's fart). Is it possible for an AI to load variable config files according to mission?

#2
As far as I know, the mods/content packs are controlled by Lua scripts and that's how the missions are controlled to. Those Lua scripts will trigger victory/lose conditions and what not (player has sniffed the sacred gas) and could then give instructions to the AI:

Code: Select all

SetAttackingMode (true);
I seem to remember that there is no way to communicate with the AIs, right? I reckon that if everything was done in Lua then Lua could exchange whatever variables between itself, though not with the missions being controlled in Lua and the AIs controlled in C++/Java, correct?
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Are there Campaign-AIs required

Post by Silentwings »

Is it possible for an AI to load variable config files according to mission?
Yes - each mission can include its own lua files, so you'd just need to agree a filename + format and read from e.g. /luarules/config/mission/config.lua

Even better, if the AI functioned as part of luarules, it would be able to communicate inside GG, which would allow it to expose functions that the mission could call. (That's how mine works, although it doesn't expose functions, just reads a few config vars.)
User avatar
code_man
Posts: 260
Joined: 19 Jan 2014, 13:10

Re: Are there Campaign-AIs required

Post by code_man »

This sounds rather iffy.

From my experience with missions and campaigns, which admitingly is quite dated but no less valid i hope, missions are or should be very specific rather than general skirmish engagements.
In these cases scripting is unavoidable and i think simple trigger based script "ai" will be utilized in these cases, despite being stupid i think it can be very effective.

Besides, i dont think anyone will be making campaigns anytime soon.
If youre looking for something to do, maybe improve the skirmish ais we already have.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Are there Campaign-AIs required

Post by Silentwings »

i dont think anyone will be making campaigns anytime soon.
I will be.
User avatar
code_man
Posts: 260
Joined: 19 Jan 2014, 13:10

Re: Are there Campaign-AIs required

Post by code_man »

Silentwings wrote: I will be.
Nice, i knew spring was capable of missions using gadgets, but i didnt expect anyone yet to be willing to make full fledged campaigns.
Post Reply

Return to “Game Development”