2d flipbook AI

I am trying to make a 2d platformer flipbook game. I have no idea how to make a flipbook AI to either walk back and forth like the snails from Mario, or even chase/fight back.