Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Maze AI
Old
HorusLupercal
Junior Member
 
Status: Offline
Posts: 7
Join Date: Apr 2012
Location: Mwhahaha right.
Default Maze AI - 05-01-2012, 09:17 PM

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.
Attached Files
File Type: a2w Maze.a2w (1.01 MB, 24 views)
   
Reply With Quote
Old
sfunk
Senior Member
 
sfunk's Avatar
 
Status: Offline
Posts: 1,112
Join Date: Mar 2011
Location: I don't know
Default 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.


If you are stuck on a project, check out the tutorials I made here at this link:

http://alice.org/community/showthread.php?p=36778#post36778

There are lots of tutorials on it so far, including some youtube videos, check it out

Or..

Go to my youtube channel to check out my alice 2.2 tutorials I have there..

http://www.youtube.com/user/sfunk1992?feature=mhsn
   
Reply With Quote
Old
HorusLupercal
Junior Member
 
Status: Offline
Posts: 7
Join Date: Apr 2012
Location: Mwhahaha right.
Default 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?
   
Reply With Quote
Old
sfunk
Senior Member
 
sfunk's Avatar
 
Status: Offline
Posts: 1,112
Join Date: Mar 2011
Location: I don't know
Default 05-03-2012, 01:05 AM

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

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.


If you are stuck on a project, check out the tutorials I made here at this link:

http://alice.org/community/showthread.php?p=36778#post36778

There are lots of tutorials on it so far, including some youtube videos, check it out

Or..

Go to my youtube channel to check out my alice 2.2 tutorials I have there..

http://www.youtube.com/user/sfunk1992?feature=mhsn
   
Reply With Quote
Old
HorusLupercal
Junior Member
 
Status: Offline
Posts: 7
Join Date: Apr 2012
Location: Mwhahaha right.
Default 05-03-2012, 09:08 PM

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!
Attached Files
File Type: a2w Maze.a2w (2.00 MB, 7 views)
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



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