The methods for creating game AI depends on the difficulty and the type of game. These methods can for the most part apply to genres like platform, action, action RPG, adventure and fighting games.
For easy mode, the code that dictates the AI's behaviour is simpler. One common way is to use a pathfinding algorithm. An enemy AI could be moving or just in an idle position. Once a character that the player is controlling moves close enough to the enemy AI, it will trigger the AI to follow that character until the character is outside of the range that triggers the pathfinding algorithm. Another way is to program the AI's actions to be pattern based and repetitive. As long as the AI's actions can be a potential hindrance or obstacle for the player to circumvent, it should be fine to have the AI simply repeat that specific action. To add versatility a random set of patterns can be chosen from after the action is completed.
For hard mode, the methodology and code can still be simple or more complex depending on how intelligent you want the AI to act. The same methods used to create an AI in easy mode can be used for hard mode except the AI would just have higher stats(E.g. attack, defense, HP, speed etc...). Otherwise, if you want the AI to act more intelligently, you can program it to react appropriately to the players actions in addition to using a variety of safe actions when there is no need to react to anything. It should also be taken to account how easy it is to make an unbeatable AI by just having them instantly react to whatever the player does to counter the player or defend themselves. Because of that, the AI should be programmed to occasionally not react to the player's actions and rather than only executing safe actions, occasionally do things that would make itself vulnerable so that it is not too difficult to overcome.
Turn based games like RPG's, card games, Chess etc... can be simple or very complex depending on the circumstances. Every decision the AI makes would be based on a short or potentially long list of conditions pertaining to the current situation. This type of AI can become very intricate over time because as more situations are discovered, it would have to be programmed to adapt to those situations.