Skip to main content
GameDev.net gamedev.net
✓ Solved 🔒 Locked

In a turn-based strategy game, how does utility AI take global objectives into account?

Started by Skermesr Aug 2 at 12:05 AM 7 replies 950+ views
Original Post
Skermesr
Skermesr

I'm developing AI for a strategy game in the style of Advance Wars.

When it is AI’s turn, it performs the highest-scoring action (Attack, Capture, etc.) for each unit it controls.
However, if a unit cannot perform any action (that is, if there is nothing within its range to interact with), it either stays where it is or moves to random locations (Movement action).

How can this problem be solved?

For example, advancing toward the enemy's headquarters or advancing toward the current front line, for example

Accepted Answer

How can this problem be solved?

It is solved by the designers building suitable weights for the utility functions.

If the goal is to advance to a line, any motion that advances should have a pretty strong weight. And a move that actually crosses the goal should get an ENORMOUS score, that is game-winning.

If the goal is to defend, then anything past the defensive line should be targeted. The farther past the line, the bigger the utility score.

Actions can, and typically do, get some points from multiple functions.

They can also overlap. An option might get points for targeting something in range, more points because it is also close to the goal box, and more points because there is a bonus objective to target that type of unit.

Scores can be negative. Motion away from the goal can have negative points. Attacking friends or having friends in an area of effect can have negative points. Being negative doesn't mean "don't do it", a game-winning action that happens to have some small friendly fire is still a high-value game-winning action.

If nothing has any score, it's a design issue.

Alberth
Alberth

Not much experience with this, but it sounds to me like you have your logic reversed.

Enemies are those that block your progress to the objective, rather than just being a member of "the other army".

As an example, if two opposing armies are next to each other, the objective is to cross a bridge further north (away from the opposing forces), and the opposing army is not doing anything (no shooting and no movement), then they are not opposing you to reach the objective. There is no need to fire single bullet at all.

That is, high scoring actions should be only those that bring you closer to the objective.

Skermesr
Skermesr

frob wrote:

How can this problem be solved?

It is solved by the designers building suitable weights for the utility functions.

If the goal is to advance to a line, any motion that advances should have a pretty strong weight. And a move that actually crosses the goal should get an ENORMOUS score, that is game-winning.

If the goal is to defend, then anything past the defensive line should be targeted. The farther past the line, the bigger the utility score.

Actions can, and typically do, get some points f...

So how is this done?
In other words, if the AI is sometimes on the left side of the map, sometimes on the right, sometimes at the bottom, and sometimes right in the middle, how can weights be added to the utility functions?

frob
frob

That's the art of game design. Figure out a few simple rules that interact together to make something fun.

The rules that associate "this option is better than that" may be location invariant, or they might have to consider location. They might operate independently, or work together. Usually it only takes a few simple rules for complex gameplay to emerge, like advance towards a target, avoid these things, when you get close to this change the behavior, etc.

Skermesr
Skermesr

Unity Source Code wrote:

A common approach is to combine utility AI for local decisions with a high-level strategic layer. Instead of letting idle units choose random moves, give them strategic objectives such as capture the nearest city, reinforce the front line, escort artillery, or defend key positions. Those objectives can then influence the utility scores of available actions.

You can also generate an influence map (threat, friendly control, objectives) every turn. Units that don't have an immediate attack or capt...


So, if I’m going to use influence maps to guide artificial intelligence, what should I do if the influence map’s weights don’t reach the unit’s movement range?

bvanevery
bvanevery

Skermesr wrote:

So, if I’m going to use influence maps to guide artificial intelligence

"Guide" AI? You're not writing the AI yourself? If I was writing the AI, I'd write algorithms that do searches over multiple turns. There are limits to what you can predict, but there are some things you can know. Like envelopes of maximum movement.

gamedesign-l pre-moderated mailing list. Preventing flames since 2000! All opinions welcome.
frob
frob

Skermesr wrote:

So, if I’m going to use influence maps to guide artificial intelligence, what should I do if the influence map’s weights don’t reach the unit’s movement range?

Exactly the same as before: adjust the design of the weights so they accomplish what you're looking for.

If distance is a contributing factor, then it needs to be considered in the utility functions. "Can't reach the destination" feels like either a zero score or a negative score, depending on the goal.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.