Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Maze AI (http://www.alice.org/community/showthread.php?t=8449)

HorusLupercal 05-01-2012 09:17 PM

Maze AI
 
1 Attachment(s)
I'm trying to create an AI that a player can race against to finish a maze. I'm having a couple of issues:

First, I have built the maze and am wondering if there is a way to put all the separate walls of the maze under a single object so that when running the collision detection it can look for a single object instead of 30 separate functions?

Second, I've watched sfunk's collision tutorial, and I have made a small function to test it on one wall and it's not working for me. I'm using simple squares instead of cube objects, is that my problem?

My code is the same as sfunk's for the collision:
if knight is within 1m of object;
turn left 1/4 revolution.

For some reason the knight object just keeps moving forward through the wall when I set up a
while knight is 1m away from EndPoint;
move 1m forward.

I would think that with these two sets of code the knight should move forward toward the wall then turn left and keep going. Unfortunately he just keeps moving forward.

I have about 2 weeks experience with Alice, so if these are n00b questions I apologize. Thanks for any assistance.

sfunk 05-01-2012 10:28 PM

Well you cant use that type of collision for what you are doing,you could use the functions left of, right of, in front of, behind, above and below to make it so it detects all sides(which you'll need, but there is a certain way you have to set it up, there is an example of it somewhere, I can't remember where though.

HorusLupercal 05-02-2012 12:54 PM

I was trying to use the in front of function, but for some reason Alice does not allow for that function to be placed in a If/Else true statement. I'll have to play around with it some more this evening I guess.

Also, will I need the left/right/behind collision detection as what I'm trying to set up will have the object turn left if something is in front of it?

sfunk 05-03-2012 01:05 AM

[url]http://www.youtube.com/watch?v=2gstaiVGqkk[/url]

Check out this guy's video on collision, this is one of the main ways that most members do collision. it's easy to implement and works for cubes rectangles and squares pretty well. of course if the object was to be circular it would work much better since it is based of the objects center point and of course a rectangle and cube/square do not have a perfect radius.

HorusLupercal 05-03-2012 09:08 PM

1 Attachment(s)
That helped, but I'm having a couple of issues to get the collision while event to work.

When I do an event of when event becomes true, do collision; for some reason it will not allow me to drop the function for IsNearObject into the event. Similar to this, in the IsNearObject variable it will not allow me to set the Return to Near. I've attached the program I have in case that helps...everything is build around the camera object.

Thanks for the help so far!


All times are GMT -5. The time now is 10:50 AM.

Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.