need help with an enemy ai script

So the story goes like this, i was making a replica of the old classic Super Mario Bros but well with less nicer graphics.I had already make quite a few things like the main menu and the level, but i still cant get to make a proper enemy ai script. So if anyone can tell me the basic idea for an enemy ai script that would be nice ^^

and just for your information i have very little experience in proggraming especially game development so im sorry if this problem is actually a very easy problem ^^

Yes, it is actually a very easy problem. But what specifically is the problem for you? The concept of AI or code itself?

AI in Mario doesn’t require much logic behind. You just move the bot as you would move player. But just bot moves constantly without any inputs. Afterwards, if it collides with a wall or a tube, it must be rotated in opposite direction. That is literally all. Where you put the logic of collision with player depends on you. Some programmers would include it in the player’s scripts, others would put it inside bot’s. I would choose the second option.

Unfortunately, we aren’t able to help you with code, except just giving a ready script. That wouldn’t be good for you in terms of learning. There are tons of tutorials. You should google them. Yeah, mostly they are for 3D and have many things that you won’t need. But you should understand how it works in 3D, and from this figure out what should be done to make it in 2D.

Alright i’ll try to google some stuff out and try to figure it out, thanks for the tips ^^

Finite State Machine (FSM) is a good starting point to be introduced to AI. It can be used to define simple AI behaviour in a rather intuitive way: using states and transition conditions from state to state.

For instance, the AI of a ghost in Pacman could be implemented with the following FSM: