So I'm not have any problems with game play, in fact, it's already pretty much done. I just recently started on the enemy AI and it's making me pull my hair out. I set up a Google Docs flow chart to help ease my headache with some visual organization: https://docs.google....thkey=CPmj9tQC. (yellow boxes are variables affecting the chance, red boxes are random/chance/choose functions, green and blue are just normal.)
I had a very primitve beginning to this when I was testing the engine with one unit vs firing arrows:
alarm[1]=thinkstep//always set alarm
if ((ceil(irandom(100)))>unitorattack_chance)//decide to create unit or attack
{
//chance_repeat=(ceil(irandom(max_actionpoints/peasant_cost)))
if actionpoints>=peasant_cost//create a peasant
//repeat(chance_repeat)
{
instance_create(x+64,y+88,obj_enemy_peasant)
actionpoints-=2
}
else
{exit}
}
else
{
if (actionpoints>=1)
{
if instance_exists(obj_player_parent)
{
tokill=instance_nearest(x,y,obj_player_parent)
range=distance_to_object(tokill)
dir=point_direction(x,y,(tokill.x),(tokill.y))
dir-=(ceil(irandom_range(15,30)))//angle adjust
arrow=instance_create(x+25,y+45,obj_enemy_arrow)
arrow.dir=dir
with (arrow){motion_set(dir,8)}
actionpoints-=1
}
}
else
{exit}
}
Which worked fine, but now it has gotten very complex; 4 units and 4 abilities plus the enemy needs to judge threat levels. For example, if a player unit is very close to the enemy castle, there needs to be more weight (or more of a chance) on shooting an arrow. Also, the enemy should learn to save when it is low on AP and sometimes decide to save for more powerful units, otherwise after reaching low AP, it will always release an arrow or cheap unit because it doesn't have enough for more.
Edited by SHiLLySiT, 19 July 2010 - 08:36 PM.











