Maze AI (PART 3 DONE!)

Here’s the tutorials:

Part 1: http://mediachicken.com/devforums/phpbb3/viewtopic.php?f=37&t=16
Part 2: http://mediachicken.com/devforums/phpbb3/viewtopic.php?f=37&t=17
Part 3: http://mediachicken.com/devforums/phpbb3/viewtopic.php?f=37&t=21
You don’t need to register to view tutorials anymore.

I finished the Maze AI tutorial set! If you want anymore maze ai tutorials suggest them, if not I’ll continue with the rest of the AI library.

Enjoy =D

Attachments

AI.blend (153 KB)

Great idea.

It’s good to see Python AI tutorials. The old Logic Brick one is nice but it’s a bit arduous for the result. My only suggestion is that you swap out the d-loc for a servo actuator. It will give nicer collisions should something without the “wall” property get in the way.

there is no collisions… the wall prop and sensor are rays, you don’t hit the wall before turning do you? nah, it turns before hitting the wall, ergo: no collisions =D

I see someone didn’t follow along =P

Oh and here’s the file, notice how he doesn’t go into the cells because he doesn’t know they exist! he only sees the walls infront of him. This is what tutorial 2 will cover, making him have peripheral vision. If you want to follow tutorial 2 with this file be my guest, it will increase simplicity and make you understand better. If you followed the tutorial right it should be exactly the same, just with a different maze.

Attachments

AI.blend (145 KB)

I figured this part out my self about a week ago, but I really look forward to the more advanced tuts. thanks for doing this!!

Ok, you caught me! but I was really just talking about further down the line when you make it more complex.

I was about to write about the weird bouncing etc you can get with d-loc some more and decided to whip up an example. That said, when I tried one using d-loc and one with a servo they both slid at a curved corner where there was collision but no ray intercept.

My apologies good sir, I was very wrong!

[What I was about to say]
I noticed that when the guard turns it’s not exactly 90 deg. So if you have a level with more complex geometry and a bunch of random props the guard may clip the edge. With d-loc and dynamic objects you tend to get weird bounce back but if he clips the edge with lin-v instead he will just slide arround.

what would be cool would be to use the getHitNormal of the ray and turn that 90 degree in a random direction. That way you can have AI follow diagonal walls too. The tricky part is that getHitNormal returns a vector and setOrientation requires a matrix so there is some conversion needed.

I’d say it’s do-able. I’ve never looked at the orientation matrix before but I have done some study of matrices in college. A vector is basically a small matrix and there are a tonne of mathematical methods for inter-converting and adding and subtracting values.

If the matrix works the way I would assume it does then to do this you would be required to find the object’s orientation and replace the z-values with those obtained from the getHitNormal command.

I have to say that’s a great idea and is far more accurate than the turning method.

As a python n00b I’m glad these tutorials are being made. I’ve dabbled before but a whitespace language that you don’t compile confuses the hell out of me. I’m learning a lot from these already!

By the way, logic bricks are written in C++ and are therefore more computationally efficient than python (python is written in C, so you are going a few extra steps than you should have to). They may be inefficient to create, organise and control but they don’t slow down computers as fast as the equivalent in python (most of the time). Although you do have more flexibility with python so you may not need as much logic to do the same thing… Anyway, there are advantages and disadvantages but the statement

BRICKS SLOW YOUR COMPUTER!!
is not automatically true.

It’s possible to not use the ray sensors and collisions to move an object around, you can use pathfinding.
I posted a thread with some links to help people create pathfinding:
http://blenderartists.org/forum/showthread.php?t=142297
I’ve successfully made pathfinding twice, once in 3D and the other using tile based terrain. With out too much fret it would be possible for you to choose a random location and plug that into a pathfinding script to produce your random movement. Allthough you might have to use your ray sensors to dodge other moving objects.
You should try to implement some pathfinding as its fundamental to AI, because your AI’s not going to look very smart when it walks head on into walls.

It’s defiantly doable, no question about it. I’ve read some vector and matrices maths, it’s not that hard once you understand how to think. Social wrote an excellent tutorial on the orientation matrix. The matrix works by organizing the x,y,z point to which and each axis is pointing in local space, I guess (will sturdy it more) that the vector outputs three angles, for x,y,z. If so, then it shouldn’t be harder than to add/subtract 90 degrees on the z-axis, convert each angel to the base circle and put the coordinates in the matrix.

own.alignAxisToVect()

Completely ignoring the need, in this instance, for the orientation matrix.

I’m glad you all enjoy! I plan to touch bases with matrices whenever I get around to the more advanced section. This next part is really long and I’m going to be really busy, but I plan to release it in the next 2 days!

Dude, you’re so funny XD!!!
Thanks alot man, for reducing the amount of n00bs with headaches.
Edit: What are you gonna do to “increase the view range”? Are you gonna use nodes?

No nodes, I will add rays on both sides of it. I’m trying to do a no-node AI for a game so you can drop it in any level.

And that’s why I need to take a proper look at a command list of relevant python commands. I had no idea this even existed!

And I had totally forgot about it.

Ok guys get back on topic!

Killer how do I find out how to find what to put in drot for a 90 degree turn for my bot?

Not really sure, I just kept tweaking till he turned 90 degrees. Didn’t my values work for you?