How it works - Ai priorization

Learn more about how the game is put together
More obscure knowledge and deprecated items
Post Reply
Stratego (dev)
Site Admin
Posts: 11239
Joined: Fri Apr 25, 2014 9:28 pm

How it works - Ai priorization

Post by Stratego (dev) » Sun Nov 15, 2020 6:57 pm

I make this while i am reading tru code how it works - so we have all the knowledge

so AI decides what task to give to a unit based on score if the given task in the given situation.
task can be, few examples: move, attack, use ability, occupy, goheal, mend, build things and such like this.

here are the defined tasks and their priorities so far
public static final int TASK_DO_WATER_CARRY = -1; //a carrier should do this
public static final int TASK_TC_GO_DEFEND = 0;
public static final int TASK_TC_ATTACK = 1;
public static final int TASK_TC_OCCUPY_ENEMY = 2;
public static final int TASK_TC_OCCUPY_NEUTRAL = 3;
public static final int TASK_ATTACK_ENEMY_UNIT = 4;
public static final int TASK_SUMMON_NEW_UNIT = 5; //
public static final int TASK_SPELL_ON_ENEMY_UNIT_OR_CONVERT = 6; //convert or any other enemy targeted spell
public static final int TASK_ATTACK_ENEMY_BUILDING = 7; //wall or tower
public static final int TASK_SAVE_OWN_ASS = 8; //if 40% or less power than do it, under 20%, harder
public static final int TASK_HEAL_UNIT = 9; //heal or mend
public static final int TASK_MEND_UNIT = 10; //mend wall or tower, mendable units
public static final int TASK_SPELL_ON_FRIENDLY_UNIT = 11; //cast buffers onto unit
public static final int TASK_TC_BUILD_DEFENSE = 12;
public static final int TASK_BUILD_FACTORY = 13;
public static final int TASK_WANDERING_AROUND = 19; //neutral annimals


score starts with 0

("i" = unit to set task to)


case TASK_TC_ATTACK, TASK_ATTACK_ENEMY_UNIT, TASK_ATTACK_ENEMY_BUILDING:
score = 0
- if target is one-hit killed: score = +10 + 10 * TargetUnitValue
- else if i can shoot target but that can not walk to me to hit: score = +3 + 2 * TargetUnitValue
- else if i am a mender or healer than: score = -10
- else if i am a transporter (like ship or wagon) having TRANSPORTING_VEIN: score = -100
- else score = 0

- if i have bonus agasisnt it: score = score +2

- if target is neutral than do not urge to kill score = -100
- if target is passive units like "wall"s score = -100

case TASK_SPELL_ON_FRIENDLY_UNIT, TASK_SPELL_ON_ENEMY_UNIT_OR_CONVERT:
score = 0
- score = effectPriority / 100 effect priorities are about 0..1000

case TASK_TC_GO_DEFEND:
score = 0
- if i can mend or heal: score = score -2
- else if i can carry units: score = score -1

- if i can attack: score = score +1

- if unit is already inside TC : score = score +10
- else if unit can go into tc with one move: score = score +5
- else if unit can go into tc with 1.5 move: score = score +1

case TASK_TC_OCCUPY_NEUTRAL, TASK_TC_OCCUPY_ENEMY:
score = 0
- if unit can occupy in one move: score = 50
- else if unit can occupy in 1.5 move: score = 10
- else if i can heal or mend score = -1

if TASK_TC_OCCUPY_NEUTRAL score = score +10

case TASK_SAVE_OWN_ASS:
if i am fatally injured: score = 3
else score = 1


case TASK_HEAL_UNIT, TASK_MEND_UNIT:
- i am nearby and target is underconstruction and is a factory: score = 9
- i am nearby and target is underconstruction and is NOT a factory: score = 7
- i am NOT nearby and target is underconstruction and is a factory: score = 8
- i am NOT nearby and target is underconstruction and is NOT a factory: score = 3

case TASK_BUILD_FACTORY:
- i am nearby score = 6
- else score = 2

case TASK_TC_BUILD_DEFENSE
- i am nearby score = 5
- else score = 1
- if i am close to enemies: score = score + 20

case TASK_DO_WATER_CARRY
score = 20

case TASK_WANDERING_AROUND
score = -1 (neutrals have only this task so scoring does not matter)


Distance modifier:
final score = ((biggest_task_prior(19) - current task prior) + score) / target_distance

User avatar
Maxbirykov2004
Posts: 736
Joined: Mon Mar 30, 2020 12:50 pm
Location: Belarus

Re: How it works - Ai priorization

Post by Maxbirykov2004 » Mon Nov 16, 2020 8:23 pm

AOD team, join now viewforum.php?f=230

Stratego (dev)
Site Admin
Posts: 11239
Joined: Fri Apr 25, 2014 9:28 pm

Re: How it works - Ai priorization

Post by Stratego (dev) » Mon Nov 16, 2020 8:57 pm

you must be kidding, machine learning lol :)

User avatar
Maxbirykov2004
Posts: 736
Joined: Mon Mar 30, 2020 12:50 pm
Location: Belarus

Re: How it works - Ai priorization

Post by Maxbirykov2004 » Mon Nov 16, 2020 9:03 pm

Stratego (dev) wrote:
Mon Nov 16, 2020 8:57 pm
you must be kidding, machine learning lol :)
Why not, it isn't impossible... But its REALLY HARD...
AOD team, join now viewforum.php?f=230

Stratego (dev)
Site Admin
Posts: 11239
Joined: Fri Apr 25, 2014 9:28 pm

Re: How it works - Ai priorization

Post by Stratego (dev) » Mon Nov 16, 2020 9:37 pm

ok, that is a wrong way. there is no processing an storage capacity on a phone to do that, and even i have no that much "free time" to implement.

User avatar
Maxbirykov2004
Posts: 736
Joined: Mon Mar 30, 2020 12:50 pm
Location: Belarus

Re: How it works - Ai priorization

Post by Maxbirykov2004 » Mon Nov 16, 2020 10:00 pm

Stratego (dev) wrote:
Mon Nov 16, 2020 9:37 pm
ok, that is a wrong way. there is no processing an storage capacity on a phone to do that, and even i have no that much "free time" to implement.
Okay :(
AOD team, join now viewforum.php?f=230

Post Reply

Return to “Abstract”