I don't understand what make ennemy decide where to move?

Hello ! I watched again and again the video, i totally understand the AI system, by using the best action based on the actionValue.

Hoewever, i don’t understand at wich point the unit decide " Ok, i’ll move to that specific gridPosition "

Maybe i missed something ? i’m pretty confused

2 Likes

You say that you understand that the enemy picks the best action based on the best actionValue. It is exactly at this point that the enemy takes that selected action and calls the TakeAction method, which causes the enemy to perform the chosen action. If the best action is to move to that specific grid position, that will be the action it performs

2 Likes

In the MovementAction, the test on each tile for determining if this is a good movement location is to test to see how many opposing units it can attack from that position. If position a would give the unit 3 targets to attack, but position b would only give the unit 1 target to attack, then position a would have a higher score, and be a preferable move position to b.

4 Likes

Oops. I think I misunderstood the question. @Brian_Trotter is right. The MoveAction asks the ShootAction how many targets there are at a specific location. The location with the most targets is considered the best move action. If no player units are nearby it will simply pick whichever location is returned first from the sort. This could, of course, be discarded if a player unit is within ‘sword-distance’ because that action is worth a whole lot

2 Likes

Basically how the logic works is it goes through all the Actions, for each Action it goes through all valid grid positions and calculates a certain ActionValue for taking that Action on that GridPosition
Then the AI simply selects the Action + GridPosition that has the highest ActionValue and takes that action.

As to specifically how it decides where to move, in the course I decided to base that ActionValue on testing how many Units are Shootable from that GridPosition.

For example, if you have a GridPosition where there are no Shootable targets, and another GridPosition where there is one Shootable target, the AI will go to the second Grid Position since the ActionValue is based on the number of Shootable targets.

4 Likes

This logic could easily accomodate other factors… for example, if the unit’s health is less than 20%, the unit may wish to consider moving to a tile that does NOT have shootable targets.
You could assign extra weight to tiles with shootable targets that have lower health than tiles with shootable targets with higher health…

There are a lot of possiblities here, remembering, of course, that adding such logic could increase the amount of time it takes for the enemies to calculate the best actions.

2 Likes

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms