# Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

### DarkBASIC Discussion / Lost on AI

Message
Posted: 2nd May 2011 19:15
I am building a maze which is done i have an object at each side of the maze but i cannot come up with a way to move the second player to the other side of the maze in a fashion that is AI. If someone could help or atleast point me in the right direction it would be appreicated
Posted: 2nd May 2011 19:50
Forgot to mention the positions are
The Comp is at
position object 2,5,1.51,55
The Target is at
position object 30,85,1.51,5
Posted: 3rd May 2011 00:05
A maze can be tricky depending on how you are building it. You could use A* (a star) path finding to have the computer find the path to the player. Or, depending on how you built the maze, you could use the maze algorithm to find the path to the player.

If the maze is simple - there are a lot of paths through it or there are very few dead ends, you can use some very basic AI where the computer "looks" at where the player is (in terms of X and Z - assuming that they don't move upward or downward).

This is a 2d example. Think of it as an overhead look at a 3d environment. Move the blue square around with the arrow keys. The red square will always try to follow the blue square just by adjusting it's x and y position to match the blue square. In 3d, you might replace the code for adjusting the y direction for code adjusting the Z direction. The principal is the same. In your maze, you would have collision detection to keep objects from moving through walls:

There's even a simpler method in 3d where you use POINT OBJECT to point the computer object at the player, and then use MOVE OBJECT to move the comp towards the player.

Posted: 28th May 2011 21:42
Thanks Latch, did wonders for my 3D enemy AI
Posted: 18th Jun 2011 09:59
Latch, this has nothing at all to do with AI, but I was looking at your example just for kicks, and because I do not have my contact lenses in and when I sit far back from the screen, where the blue and red squares overlap it actually looks purple! It's amazing how the brain combines the colors that overlap because of my poor vision and creates the final result.

Ok, I'm going to go sleep now.

Posted: 23rd Jun 2011 18:48 Edited at: 23rd Jun 2011 18:49
Just think, with this new power of poor vision you've discovered, if the correct colors are combined you might be able to see through walls.