When trying to make AI, think what you would do in a position.
For example, if your x position is less than the enemy x position and you're pretty far away, do you increase your x position?
Offline
Try to think about how you want to design your enemies. For example, if you have a foot soldier, you would want to program him so he does little damage, misses frequently, and has an easily predictable attack and defense method. An elite soldier would have a variety of techniques used randomly and quickly that deal a lot of damage to the player. Also, in AI scripting, you want to think of an enemy as a person. Is he cautious, staying back and striking occasionally, or is he ferocious, attacking the player head-on and dealing many moves at once? Think about it.
Offline