Alice Community  

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

Reply
 
Thread Tools Display Modes
computer controlled characters
Old
z3px
Guest
 
Status:
Posts: n/a
Default computer controlled characters - 11-23-2008, 04:55 PM

hello,
I'm looking at making "computer controlled" objects move around in an arena automatically. What would be the best way to make this happen? basically the arena is a circle with some objects in the center. The moving objects would have to move around the objects in the center.
thanks in advanced.
   
Reply With Quote
Old
Ch0pStickS
Guest
 
Status:
Posts: n/a
Default 11-23-2008, 10:25 PM

First get the visual in your head. Draw a picture of the circle (on paper), and add blocks of things where your objects are. Then put dots in places where the objects are not there. Connect as many dots as you can without going over the objects. Then have the object start at one of those dots. It would then choose a random dot that it's connected to and move to it. It would do this over and over again.

To do this, go in your alice world, get a top side view, then drag some shapes onto places, like you did with the dots. Then for each dot, you should make a group of the dots it's connected to. You would do this by making a variable, choosing object, then checkmark the make a list thing. THen you put in the dots that it's connected to. You do this for each dot. Then put a bunch of if statements, so that if it's at a certain dot, then it would move to a random dot of the group that it corresponds with.
-----------------------------------------1------------------------





------------------------------2--------------------3---------------
First the method has to determine which dot you're at. You can do this with variables. For example, it determines that you're at dot 3. Then you can make a group called Group 3. which contains 1 and 2 in it. You then have it move to a "random object in group 3" which you can do by telling the object to move to anything at first, then drag variable "group 3" into the place that tells you where to move to. and select, random object from group 3.


I attached a demonstration world.
Attached Files
File Type: a2w Random Movement Demonstration.a2w (595.1 KB, 42 views)
   
Reply With Quote
Old
Ch0pStickS
Guest
 
Status:
Posts: n/a
Default 11-23-2008, 10:52 PM

Well, heres a larger version with more points, and objects turned invisible. Also added obstacles. It almost never goes through it, and when it does, it just skims through, because i calculated it wrong.
Attached Files
File Type: a2w Random Movement Demonstration.a2w (877.0 KB, 44 views)
   
Reply With Quote
Old
z3px
Guest
 
Status:
Posts: n/a
Default 11-24-2008, 07:25 AM

thanks, I actually thought of this same method right after I posted my original message. I was originally thinking of something more complex, but this works just as well in Alice. Thanks for the info.
   
Reply With Quote
Old
Ch0pStickS
Guest
 
Status:
Posts: n/a
Default 11-24-2008, 09:49 PM

Of course if you wanted more complex, (not recommended in alice), you could also just have the object moving around just keep going forward. Then set it so that while it is outside of a center radius (the whole stadium, you could have it choose a random direction (right or left) and make the object that is moving turn that way, making it never hit. You could adjust this so it never hits the wall. Then you could do this with the rest of the objects in the middle, and have it say where if it is within a certain proximity of the object, it starts turning away from it.

Actually while thinking more, you could instead make a good decision on direction. You could put two objects next to the object that is moving( one on right, one on left), then have it determine which of those two is closest, and have it turn the other way. So like if the tester on the left is close, the object would turn right. Same thing with going outside the arena, except testing which object is further from center, left or right, and have it turn the opposite way again.

But like i said, with enough objects, you would have to be constantly testing whether object is close to something, or far from the center, and that would make it big, and annoying to handle. It might also lag the world, or even crash it. If you need me to make an example, ask me.
   
Reply With Quote
Old
Ch0pStickS
Guest
 
Status:
Posts: n/a
Default 11-24-2008, 09:54 PM

But if it started int eh same direction all the time, it would run the same eventually. So, what you could do , is at the beginning, have it turn x degrees, with x between 0 and 360. So then it would take a different path almost every time.
   
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.