Alice Community  

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

Reply
 
Thread Tools Display Modes
need help
Old
modifiedbears
Guest
 
Status:
Posts: n/a
Default need help - 11-30-2006, 11:20 PM

I have a list of objects. I want an object randomly chosen by alice from the list to perform a function, wait 1 second, then perform another function on the object randomly chosen. How do I do this?
   
Reply With Quote
Old
modifiedbears
Guest
 
Status:
Posts: n/a
Default 12-01-2006, 01:12 AM

*I meant method instead of function. Sorry, it's late.
   
Reply With Quote
Old
modifiedbears
Guest
 
Status:
Posts: n/a
Default 12-01-2006, 03:29 PM

is this just not possible? am i missing something?
   
Reply With Quote
Old
gabe
Administrator
 
gabe's Avatar
 
Status: Offline
Posts: 461
Join Date: Jul 2005
Location: Pittsburgh, PA
Default 12-01-2006, 03:42 PM

If I create a variable (world's details > create new variable) that is a list of objects, I can then make Alice perform an action on a randomly chosen object within that list.

For example, if I want a random object to turn left 1 revolution, drag an object into a method and select <object> turn left 1 revolution. Note that it doesn't matter which object is used -- it is merely a placeholder which you will then drag the variable onto. After dragging said variable onto the placeholder, select "random item from list" from the drop-down menu.
   
Reply With Quote
Old
modifiedbears
Guest
 
Status:
Posts: n/a
Default 12-01-2006, 08:15 PM

Quote:
Originally Posted by gabe View Post
If I create a variable (world's details > create new variable) that is a list of objects, I can then make Alice perform an action on a randomly chosen object within that list.

For example, if I want a random object to turn left 1 revolution, drag an object into a method and select <object> turn left 1 revolution. Note that it doesn't matter which object is used -- it is merely a placeholder which you will then drag the variable onto. After dragging said variable onto the placeholder, select "random item from list" from the drop-down menu.
yea i can do that

the next step is getting alice to recognize which object it randomly chose to then have it perform another method with.
   
Reply With Quote
Old
modifiedbears
Guest
 
Status:
Posts: n/a
Default 12-02-2006, 12:12 AM

I have an assignment due wednesday, and I could use some more help with this. The instructor doesn't know how to progam with Alice anymore than the class does. The book (written by Charles W. Herbert) we are using isn't much help either. We've been doing a lot of really basic stuff then he tells us we have to make a game using Alice.
   
Reply With Quote
Old
gabe
Administrator
 
gabe's Avatar
 
Status: Offline
Posts: 461
Join Date: Jul 2005
Location: Pittsburgh, PA
Default 12-02-2006, 11:57 AM

What you are asking is not so much an Alice question as it is a general programming question. If you have a list of objects, and you want a to select a random one to do something, how would you capture that random object, in Alice or another programming language, regardless of the action? I would want to assign its value to something I can then manipulate. What are some things you can manipulate? Hint: you have already created one of them.
   
Reply With Quote
Old
modifiedbears
Guest
 
Status:
Posts: n/a
Default 12-02-2006, 12:59 PM

Quote:
Originally Posted by gabe View Post
What you are asking is not so much an Alice question as it is a general programming question. If you have a list of objects, and you want a to select a random one to do something, how would you capture that random object, in Alice or another programming language, regardless of the action? I would want to assign its value to something I can then manipulate. What are some things you can manipulate? Hint: you have already created one of them.
This is my first programming class. My instructor didn't know how to do this either. To me there should be a way to have the random object chosen become a variable, but I don't know if that's even right or possible.
   
Reply With Quote
Old
gabe
Administrator
 
gabe's Avatar
 
Status: Offline
Posts: 461
Join Date: Jul 2005
Location: Pittsburgh, PA
Default 12-02-2006, 01:09 PM

Quote:
Originally Posted by modifiedbears View Post
To me there should be a way to have the random object chosen become a variable, but I don't know if that's even right or possible.
*Exactly.* I have shown you how to create a variable that is a list of objects. I have shown you how to select a random object. You have stated what you want to do next -- assign that random object to a variable. So do that. Create an object variable and assign its value to a random object from the list.
   
Reply With Quote
Old
modifiedbears
Guest
 
Status:
Posts: n/a
Default 12-02-2006, 10:04 PM

Quote:
Originally Posted by gabe View Post
*Exactly.* I have shown you how to create a variable that is a list of objects. I have shown you how to select a random object. You have stated what you want to do next -- assign that random object to a variable. So do that. Create an object variable and assign its value to a random object from the list.
Ok I got it working. Thank you. How would I go about setting up a time limit for a game in Alice? The book I have only shows how to loop a certain amount of times. I see the function for time elapsed under the world, but I have no clue how I would work that into a method properly. Do I use the time elapsed function with a loop?
   
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.