Gamasutra is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Designing AI Algorithms For Turn-Based Strategy Games
January 16, 2021
January 16, 2021
Press Releases
January 16, 2021
Games Press

If you enjoy reading this site, you might also want to check out these UBM Tech sites:

# Designing AI Algorithms For Turn-Based Strategy Games

July 27, 2007 Page 2 of 3

# The Solution: The Resource Assignment Algorithm

### Assignment Scoring

In order to solve the problems detailed above, firstly we design a scoring system. Each task is assigned a general priority as follows:

Defending our colonies: 1
Attacking enemy colonies: 2
colonizing planets: 3
Attacking enemy ships: 4
Repairing damaged ships: 5
Exploring uncharted territory: 6

Each task also has a priority modifier, for instance the defense task gets a modifier for the value of the colony (colonies with production queues get very high modifier). Likewise, the repair task gets a modifier depending on the amount of damage and the colonize task gets a modifier depending on the "habitability" of the planet.

Finally the distance of the assigned ship is taken into account, as follows:

assignment score = (6 - general priority + modifier) / distance to ship that is assigned

Therefore, in the previous scenario destroyer C would get a higher score for attacking the enemy colony, even though the defense task has a higher priority, just because it was so close to the enemy planet.

Also, the priority modifier of the repair task for Destroyer A is quite high because it's so badly damaged. Coupled with that it is close to a repair queue, and that means that it scores higher than the defense task.

### Algorithm Outline

The overall algorithm is broken into 4 parts:

The AI has a list of enemy ships and planets within sensor range, as well as a list of its own assets. Tasks that need to be done are generated as follows:

### Possible Assignments

The other part of the problem is that if we assign tasks in the wrong order the resource utilization will not be optimal. This can be resolved by assigning the tasks in phases. We use two special classes to help us: PossibleAssignment and Task. PossibleAssignment links a potential "task doer" (e.g. a ship) with a task and stores the "assignment score". Task stores the priority, priority modifier and objective.

Page 2 of 3

### Related Jobs

Square Enix, Inc. — El Segundo, California, United States
[01.15.21]

Senior Web Developer
Gunfire Games — Austin, Texas, United States
[01.15.21]

Senior Boss Designer
innogames — Hamburg, Germany
[01.15.21]

Game Designer - Forge of Empires
Airship Syndicate — Austin, Texas, United States
[01.13.21]

Mid to Senior Worldbuilder - Unreal Engine