AI in a 4X Game Combat (see prototype video)

Started by
19 comments, last by Orymus3 10 years, 7 months ago

An alternative to the Fleet Commander solution is to use a system of contracts. First unit sees a target to kill, estimates the firepower necessary, and puts up a 'contract' to kill the target. Next unit checks the contracts list, and makes a bid, offering his firepower and time-to-target. Same thing with all units.

On the next pass, the first unit sorts the bidders according to ability, and selects the top guys who can make it happen. He then messages them that they have been selected for the job (making it a binding contract), and marks the contract closed.

On each pass, units check first if they are in a contract, then if the contract needs to be re-evaluated (like if a team member can't make it), and then either work on executing their contract, bidding on another contract, or making a new one.

Interesting, but I'm assuming that all ships are subject to come in range of an enemy. What would be more important: fulfilling a contract, or creating a new one?

What if the issuing ship has moved in range of a distant ship, and that the ship that needs to take on that contract is at the other end of the battlefield, and needs to 'move through' a bunch of enemies to get there. Would it still fulfill its contract while briefly moving through enemies? It feels like an inefficient way to wage war?

Damage delivery includes time to target as part of the bid; for example, a given ship proposes that it can deliver 150 dps to a given target, beginning 6 seconds from now. Choosing which contract to fulfill is an optimization problem. For more details on the implementation of this method, see the book Multi-Agent Systems:A Modern Approach.


AI "Personality" would be how much risk of failure the commander is willing to gamble, when estimating firepower to destroy enemy assets. For example, AI fleet commander George might be willing to be wrong one time in five. But AI commander Ricktor insists on being wrong only one time in twenty. So Ricktor's estimate of necessary firepower to do the job is going to be much higher than George. Ricktor will frequently allocate lots of overkill, wasting some damage potential. But George will allocate lots of underkill, and fail to kill ships as quickly as possible.

That sounded like a great idea, but I feel its a bit out of scope. It wouldn't 'fit' well in my game if I allowed the player to choose their AI general, and it would be even less appealing if it was automatically determined, say, based on the species they are playing, especially if it turns out that one general is simply inferior than another in some situations and the player has realized that. Great idea nonetheless, in a different implementation.

If your game doesn't use random numbers -- no ToHit or random damage range -- then yes, that's probably true. For that system it is possible to simply know a ship with 100 hp requires 100 damage applied to destroy it. Massive Assault was a strategy game like that.

But if the game involves some chance of failure to hit, or some variance in the amount of damage dealt by weapons, then estimating the firepower necessary to eliminate a target requires a decision on how "sure" you wish to be about killing a ship. It's no longer possible to simply say 100 dmg is enough to kill a 100 hp ship. Sometimes that will fail, because of the chance of missing or low damage output. It then becomes a question of how much overkill should be assigned to be "sure" of a kill. Maybe you decide to add 10% extra firepower just to be sure. And that's the "personality" aspect I was mentioning, the definition of "sure," also called confidence.

--"I'm not at home right now, but" = lights on, but no ones home
Advertisement

Because of the way my game is engineered I can't have phases. However I have a timer. Any ship that survives the timer gets to act on their turn as normal (escape). Then fight resumes on the next turn if its still relevant.
That part has yet to be implemented however...

So in a way my system is similar... a bit. But I dont like introducing gamey mechanics (cards).

I didn't mean "look at Space Empires because it's so great and you should steal ideas from them", more like "look, they made this sucky combat system and it still works, so don't worry so much".

Personally, I find your video more attractive than their combat system. In yours there is a hope I can make heads and tails at what shoot and what and why it blew when it blew. I know, majority would not agree and prefer the high cinematic sequence of SE, no doubt. But as a player I see more tastiness in your video :)

The direction I advise is take the combat from MoO2 and make it auto combat, add rewind/pause feature of some sort (or do it some other way, so I can see clearly what's happening), also you could reduce the number of ships total in a battle (like 15 is max for me, alt least for capital ships, you can make a swarm of small chaff, no problem). And overall, let me watch the battle at MY PACE, and give me tools to analyse it over and over again why the combat turned out the way it turned.

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

I think I fleet commander would be a good idea. As it looks now each ship is acting independently attacking the the nearest target and ganging up only by chance. From the video it looks like one ship is clearly superior to the rest in terms of damage dealing and yet it is barely targeted by the other side allowing it decimate the lefts fleet. Which would frustrate players since if they were in command they would probably try and take it down first before mopping up the rest.

With a fleet commander approach you coordinate the fleet as a whole moving them to deal with the threats as appropriate. They way I would work it is to have a series of slots in that make up the commander AI where you place simple ai tactics that alter how it handles the outcome of battle.

For instance you might have a choice of three weapon tactics:

  • Fire Main Guns - Ships will try and remain within range of using their main guns on a target advancing and retreating as necessary.
  • Optimal Firing Range - Ships will stay close enough the enemy to use the bulk of their weapons.
  • Bring all guns to bear - Ships will get as close as possible to the enemy ensuring maximum fire power and accuracy.

Firing policy tactics might be as follows:

  • Target Nearest
  • Target Weakest
  • Target Strongest
  • Group Attack

I would also have user defined classes that you can put a ship in for grouping purposes so I might have a number of small fast short range ships that group as harasser and then I can add a tactic that would be harassers target artillery ships. That will cause them to target ships with powerful long range weapons first before going after any other ship.

In this way you still have the auto resolve calculations but you give the player the ability to feel more in control of the outcome. Later on you could always add more depth like firing arcs and movement. Or come up with elaborate ways for the ships to work together and play with hidden information.

The AI ideas are interesting, but the main problem with "scope of work" here is that I don't have any design space to prepare for these fights.

The logic of the game assumes that combats will be generated automatically as a turn is processed. Since ships might not be aware they'll jump in a fight on the next turn (ambushed by cloaking ships for example) I can't force players to have an AI readied at all times. It also complexifies gameplay tremendously, and I'm not sure the added toll really brings more fun to the table.

However, I do agree that the default AI is fairly weak.

I've already fixed some of it (mainly helm and rotation) and will keep working on an algorithm that is better to acquire targets.

I came to the conclusion I needed to reassess the AI after running a few simulations and noticing an unwanted behavior:

If a ship acquires a target, its possible it will shift to a different target before eliminating it if that other ship comes CLOSER.

An easy check I could make before assigning a new target is to check if the current target is null (that would literally be one line of code because I've already defined the parameters to determine whether the target is currently null).

However, spreaded attacks don't feel very logical.

Then again, having both sides focus on destroying a single ship on the other side at once would feel bad too and I'm not sure where the balance really is.

So, I haven't really delved 'deep' into the AI just yet, but I really wanted to get the movement pattern defined beforehand.

I went ahead and created 3 different approaches:

(Put in HD to actually see the ships...)

[media]https:

[/media]

1 - Stop-n-Go

*Ships are allowed to stop moving when in firing range.

Pros

+ Allows ships to control their 'ideal range' and stick to it (ship speed and rotation is used mostly to close on enemy artillery or attempt to move away from big ships).

+ Intuitive and simple. Ships tend to stay in their 'half' of the battlefield.

Cons

- Feels a bit odd. Perhaps Acceleration/Deceleration could smooth the way it looks.

2 - Continuous Chase

*Ships are not allowed to stop. Thus, they 'orbit around' their enemies in an attempt to reacquire firing range

Pros

+ The Fly-bys look a lot more like space combat from other games and mimic air strikes much more efficiently.

+ Ship Speed and Turn Speed are extremely relevant to combat outcomes

Cons

- Ship with small rotation arcs tend to go out of the battlefield unnecessarily (could be balanced).

- Without collision detection and path-finding that goes along with it, it could look like a cluster of ships on top of one another and lead to confusion

3 - Helm-Centric Shooting

*Essentially an option that can be added to either of the above

*Ships only get to fire if their helm points at their target

Pros

+ Ship rotation is crucial to acquire targets and becomes an interesting variable (no artificial cooldown to reacquire a new target).

Cons

- A bit restrictive, and certainly won't work well with Continuous chase unless the arc is more permissive

Feel free to add/comment on it as feedback will undeniably help here.

I think you should decide if you are making it cinamatic great looking or not. If you are worried about "Feels a bit odd. Perhaps Acceleration/Deceleration could smooth the way it looks." then you should first worry about the graphics (make it full 3D with sparks and everything). With current pixelated ships, well, it will feel odd no matter what you do in terms of mechanic...

I say, if you are to stick to low res 2D, also do it "odd" in terms of movement. People who can withstand that kind of graphics will be able(don't care) to withstand units stopping abruptly as well. Those people will be hardcore strategies fans and they will simply care about other things... Let's face it, I don't care about any issue you posted in this topic, I care about what my strategic options are, what technologies are available, why I built that kind of fleet and not other one, how damaged ships are dealt with after battle, how supply system works, if I can assign officers/admirals to ships/fleets, etc. From my point of view you are worrying about the wrong thing.

In short, I vote for 1) :)

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

I was expecting no less from you Acharis ;)

That being said, here's #1 with added feedbacks as per what mippy mentioned.

[media]http:

[/media]

Added a Life Gauge and damage indicators.

This is all placeholder art, but the functionality appear to be ok so far.

I'm a bit disappointed by how the numbers stack together, but nothing that can't be modified through balancing.

Do you feel the information is clear enough?

I was expecting no less from you Acharis ;)

It's funny how you start to know who will say what on forums, even before you read their post :D

Do you feel the information is clear enough?

No, it's the same as before. It showed me that ships deal some damage and it reduces their HP and after a while thewy blow up. Nothing I don't know already :)

I need to know:

- if my shots were penetrating the armour

- if my ion cannon was doing more damage or if it was the anti matter missile that's better vs that enemy

- when the shield went down (at what point of the battle) so I know if there is enough of these or if I should invest in shields more

Personally, I think it's way too early to do this battle animation thing, first you need the core combat system...

Generally, go and play MoO2 (you can use auto battle to get similar feel). Notice what richness of information is presented to you. And I mean valuable information, not just some fluff.

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube


- if my shots were penetrating the armour

I plan on using color-coded numbers (blue means you're still hitting shields, whereas red means you're digging into the hull). Would that be clear enough? Based this on Gratuitous Space Battles...


- if my ion cannon was doing more damage or if it was the anti matter missile that's better vs that enemy

The number on display shows how much damage you're dealing (did you put the video in HD?). So you can see which weapon deals the most damage. Or is it because its still confusing because its hard to know which projectile resulted in which hit?


- when the shield went down (at what point of the battle) so I know if there is enough of these or if I should invest in shields more

I'll have an overlay shield and an anim for it 'taking a hit' so that, the first hit you take without shields, the shield image is removed with a small fx (visual feedback). That's actually just a small tweak in my current implementation as its just 'visual' stuff based on variables that already exist.


Personally, I think it's way too early to do this battle animation thing, first you need the core combat system...

I have most of these already implemented. They just 'don't show' yet.


Generally, go and play MoO2 (you can use auto battle to get similar feel). Notice what richness of information is presented to you. And I mean valuable information, not just some fluff.

MoO2 uses a tactics-based approach to combat, which is essentially turn-based. The combat playback I'm building is 'real-time' (without player input). The information, as a result, can't be sequenced as efficiently, but it runs a bit faster and battles take less time.

I've looked it up, because I hadn't played in years, but I'm not sure which 'valuable information' you're referring to specifically.

Can you give me clearer idea of what's missing here?

Also, animated GIF with more ships:

BattleFDB.gif

I plan on using color-coded numbers (blue means you're still hitting shields, whereas red means you're digging into the hull). Would that be clear enough? Based this on Gratuitous Space Battles...

Sounds like a good idea. Althrough some visual "shield" would be better.

MoO2 uses a tactics-based approach to combat, which is essentially turn-based. The combat playback I'm building is 'real-time' (without player input). The information, as a result, can't be sequenced as efficiently, but it runs a bit faster and battles take less time.

I've looked it up, because I hadn't played in years, but I'm not sure which 'valuable information' you're referring to specifically.

Can you give me clearer idea of what's missing here?

Yes and no :) Indeed, MOO2 had turn based tactical battle, BUT I used it mostly like an automatic battle :)

The rich information was like this: I was disabling all weapons except heavy lasers then fire at enemy, then disable all weapons except ion cannons and fired, then compared which one did more damage :) Also I was able to count in which turn my ships lost their shields, how many structure points were lest after battle, etc.

But I suspect most players haven't used it that way :D

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

This topic is closed to new replies.

Advertisement