AI is much like any other part of programming. Once it's familiar you'll have less trouble. But as with any problem, you need to break it down into actions, even put yourself in the AI's position, think about how you do things yourself then reduce it to its most basic form.
The best approach to AI I can think of is to look at it like an old LOGO problem. I don't know if anyone remembers that, it was a useful language back in the days of the BBC Master, Acorn and other classic machines. Where you used commands such as Forward 10, Right 20, Forward 10, Left 20, Backwards 10, etc. We used to use it in electronics and computer class to guide a robot around the room.
Programming is the same. You don't think of the final goal, you think of the actions it takes to arrive at that final goal. We do things automatically without thinking. If we walk across the room to shake someones hand, we'll automatically walk around the table and chairs using very sophisticated sensors. Eyes, ears, touch, etc. But when you think of all the little actions it takes, you'll start to see how AI works.
The trick is working out how you represent the room to the AI, clearly you can't just say "look" for the table. But what you can do is pass the radius of the table and position of the table to the AI. A little basic pseudo code
Move AI forward
Get AI Position
If AI Position = Table Position + Table Radius then move back 2 and turn right 5 degrees
Loop
That will prevent the AI from moving through the table, in a very basic way.
An alternative method of course, is to use a graphic file to represent paths for the AI to follow. 1 or 10 units of game space, can = 1 pixel on a BMP file, just get the AI to follow the green line, when it hits a red pixel, the AI turns right, then follows the green line, until it hits a blue pixel and turns left, then follows the green line, etc. This method is useful because it allows YOU to make all the smart decisions prior to the AI ever starting.
However this bit ONLY takes care of object detection and basic avoidance, you also need the AI to attack or approach the player. So you add in a detection zone.
If AI Position = Player Position + Radius of 50 Then trigger Function AI2
While your enemies are carrying on, happily following their way points. The enemy you are closest too can be triggered into an alternative set of instructions.
First check if AI is alive, with a flag of 1 or 0
If AI flag = 1
If AI Position = Player Position + Radius 50
Get angle between AI and Player
Turn AI towards player until angle = plus 5 or minus 5
Get distance between AI and Player
Move AI forward
If AI within 10 Radius of Player, damage player health every 2 seconds until player health < 1 or until AI Health < 1
If AI Health < 1 Set Active flag to 0
If Player Health < 1 Game End Function
Clearly this isn't DarkBASIC Professional code. But Pseudo code is a great way of organizing your thoughts, and the actions you need to take. Allowing you to break down any problem into parts. It is epically useful with AI because it helps you map out the general steps you need to take in order to make your AI work.
Obviously what I've typed here shouldn't be taken as gospel, I've put almost no thought into AI, and I've not tackled how to move around objects in the second set of pseudo code so that needs to be addressed. But once you think of all general steps you need to take, then you can break them down into darkBASIC source code. Without having to keep it all in your head. There's nothing worse then jumping into coding without some forward thought and planning, espeically if the code has any kind of complexity to it.
As with all things, it's only complicated until you break it down into manageable steps.