How do you make enemy humanoids have good AI?

If you want you can take a look at neural networks.

Here is a module that might help