Post by Majo on Sept 15, 2020 19:13:42 GMT
Hello,
some things that I think are easy to programm but would improve the AI that it becomes a better match for a human player:
Best Regards
Majo
some things that I think are easy to programm but would improve the AI that it becomes a better match for a human player:
- First handle all movement, then all attacks.
Currently the code look in my imagination:
FOR current_warrior=0 to NUMBER_OF_WARRIORS
IF warrior[current_warrior].still_alive
IF NOT warrior[current_warrior].attack_possible()
{walk toward enemy}
IF warrior[current_warrior].attack_pssoble()
{attack random target in range}
NEXT
Better this block should be split in 2:
FOR current_warrior=0 to NUMBER_OF_WARRIORS
IF warrior[current_warrior].still_alive
&& NOT warrior[current_warrior].attack_possible()
{walk toward enemy}
NEXT
FOR current_warrior=0 to NUMBER_OF_WARRIORS
IF warrior[current_warrior].still_alive
&& warrior[current_warrior].attack_possible()
{attackrandom target in range}
// see below
NEXT
additional:
FOR current_warrior=0 to NUMBER_OF_WARRIORS
IF warrior[current_warrior].still_alive
&& NOT warrior[current_warrior].enemy_next_square // if enemy was killed during attack phase
{walk to next target}
NEXT
if done like that, the AI would benefit more from flanking, which is quite important in the current game
FOR current_warrior=0 to NUMBER_OF_WARRIORS
IF warrior[current_warrior].still_alive
IF NOT warrior[current_warrior].attack_possible()
{walk toward enemy}
IF warrior[current_warrior].attack_pssoble()
{attack random target in range}
NEXT
Better this block should be split in 2:
FOR current_warrior=0 to NUMBER_OF_WARRIORS
IF warrior[current_warrior].still_alive
&& NOT warrior[current_warrior].attack_possible()
{walk toward enemy}
NEXT
FOR current_warrior=0 to NUMBER_OF_WARRIORS
IF warrior[current_warrior].still_alive
&& warrior[current_warrior].attack_possible()
{attack
// see below
NEXT
additional:
FOR current_warrior=0 to NUMBER_OF_WARRIORS
IF warrior[current_warrior].still_alive
&& NOT warrior[current_warrior].enemy_next_square // if enemy was killed during attack phase
{walk to next target}
NEXT
if done like that, the AI would benefit more from flanking, which is quite important in the current game
- concentrate attacks on certain targets (weak, cannot block, remove flanking, ...), currently it seems random, who is attacked if a flanked enemy counterattacks/ a ranged enemy does not use his shots effective. Best you calculate a priority for every enemy (attackable);
FOR current_enemy=0 TO NUMBER_OF_ENEMIES
priority[current_enemy]=0
IF enemy[current_enemy].still_alive && enemy[current_enemy].can_be_attacked
select case enemy[current_enemy].health_state
slighly_wounded:priority[current_enemy]+=1
injured:priority[current_enemy]+=2
heavyly_injured:priority[current_enemy]+=4
close_to_defeat:priority[current_enemy]+=8
IF NOT enemy[current_enemy].can_block
priority[current_enemy]+=10
...{more reasons, why to attack a certain enemy}
NEXT
if attacking, the possible target with the highest priority should be attacked
- Move enemy-groups with the speed of the slowest member, this will keep cohesion within the enemy warband, if wanted, the enemy warband can be split in 3 sub-groups (infantry, cavalery, ranged), but then making this sub-groups effectively work together will be more complex ...
Best Regards
Majo