There are many different ways of doing enemy AI but the simple and effect way I handle AI is giving each of your sprites an AI instance variable and set their behaviors to coincide different values.
Enemy AI=0 the enemy does nothing
Enemy AI=1 move up
Enemy AI=2 move down
Enemy AI=3 move towards the player and attack every random(1,3) seconds
Then set the variable based on time or distance or collisions. So if the enemy does not have line of sight to the player every 3 seconds switch between 1 and 2 then if the enemy gets line of sight set the variable to 3. You could also do this by creating invisible checkpoints and mapping out paths for them to walk changing their AI variable based on which checkpoint they collide with. It can get very complex but that is my quick explanation on how I do it.