   Simple Platform Game AI
  Hey guys.I'm sure that this question has been asked a million times before (I did do a search through this section of the forum but had no luck) so I'm sorry if I'm showing my ignorance here.I'd like to create some extremely simple AI for a platform game that I'm writing; I'd like the enemies to be in the style of the original Mario games enemies (wander left until collision, wander right until collision etc.) but I have no idea how to implement this.If anyone has any ideas on this then let me know :DAnother point that I might aswell mention while I'm here is that I don't really know how's best to actually initialise the enemies, should I have them in a vector and read their locations from a file or how is this normally done?Cheers guysHeh.   
  Breaking it down, you are looking at three things:1) A way to find out if something interesting happened. This means either polling the game world (each object asks amIColliding() each frame) or getting notified about an event (CollisionResolver checks for collisions and creates an event for each collision, which is somehow dispatched, either right then or later, to the AI. Observer pattern can help here - make your entities register themselves as listeners for the events they want to receive)2) A way to decide what to do each frame, and how to react to "interesting" events. I think one of the most straightforward ways of implementing that is a finite state machine. This FSM stores the current state, and executes it when you call update(). The state can then react to interesting events, determine what action should be taken right now, or transition to another state (for instance, if the "attack" state notices that hp<20%, it might transition to the "flee" state). 3) A way to turn your AI's decisions into concrete actions. One way you might do this is to store the currently requested action, let's say in your case GoLeft, and then turn it into output when processing the entity (something like currentAction.apply(myEntity), which does myEntity.move(-5,0)About initializing the enemies: Normally you'd have initial level data in a file somewhere, although nothing stops you from hard coding it. I usually use XML for all level data, but that's just a personal preference - you can store it however is most convenient for you for both editing it and loading it.   ;  Awesome, that's cleared a few things up thankyou.I just need to motivate myself to do it now! :PCheers for the helpheh.   