AI help?

How do you put AI in a game? I am trying to make a game where you see a castle from above and move around and I already have the movement from room to room etc, but I need to insert enemies that go towards me if they see me and patrol/move at random if they don’t. Can anyone help?