Alice Community  

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

Reply
 
Thread Tools Display Modes
create random function without using a variable
Old
bellap
Guest
 
Status:
Posts: n/a
Default create random function without using a variable - 03-15-2009, 05:47 PM

Hi
Does anyone know how to create a random function without using a variable. For example the scenario is for a net to catch three butterflies on 3 flowers. Each time the net misses the butterflies fly to the next flower in a random fashion. If someone could get back to me asap that would be much appreciated.
   
Reply With Quote
Old
DrJim
Guest
 
Status:
Posts: n/a
Default 03-16-2009, 05:01 AM

Doesn't sound possible. If you don't use a variable, what's going to be random that you can use?
   
Reply With Quote
create random function with an if statement without the use of a variable
Old
bellap
Guest
 
Status:
Posts: n/a
Default create random function with an if statement without the use of a variable - 03-16-2009, 06:34 PM

I know it seems silly but we have been asked to do this for an assignment. We are not allowed to use variables and have been told to use the if statement in order to achieve the fandom affect. I have tried to do this to o avail.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 03-16-2009, 08:59 PM

Well, you could SIMULATE randomness by having the if/else if staements compare the butterflies positions in an unpredictable way, such as by having the butterflies compare their positions to the net itself, which since it would move around based on the user's whims, wouldn't follow a set pattern.

However, if you cannot use variable AT ALL, then maybe your tracher is trying to teach you their importance by showing that you can't do certain things without them.


(')>
   
Reply With Quote
Old
rich0e0rick
Senior Member
 
rich0e0rick's Avatar
 
Status: Offline
Posts: 141
Join Date: Jan 2008
Location: Sturgeon Falls
Default 03-17-2009, 12:59 PM

simply vehicle a cube(1) to a side of another cube(2), and make the second cube spin, VERY fast,
put a object in the middle to act as the object that doensnt move (vehicle this to world, not to cubes)
then for true false kinda things, use the ,( if cube1 is to the left of middle), then do (method)....

rick


im back!!! FINNALY!!! got windows working on my mac again!!!
   
Reply With Quote
Old
DrJim
Guest
 
Status:
Posts: n/a
Default 03-18-2009, 05:57 PM

Quote:
Originally Posted by bellap View Post
I know it seems silly ...
Silly - it seems impossible. If you can't use variables at all, what do you test in the if statement? The only possibilities are to either have it always true or always false. The spinning cube thing will work - but the position is still a variable, even if it wasn't explicitly declared.

Maybe it is just to emphasize the importance of variables - but it seems a strange way to do it.
   
Reply With Quote
Old
DogSoldier
Guest
 
Status:
Posts: n/a
Default 04-01-2009, 11:40 PM

Hi

I had one butterfly having to fly randomly between three flowers. This is what I have used:

Nested IF Statements for each flower, to ensure the butterfly did not try to fly to flower 1 when it was sitting on flower 1.

To create the random affect I used a "probability of true for 50% of the time" to pick between the two remaining flowers.

Unfortunately I ended up with a spare "else" listed as "do nothing". To rectify this I repeated one of the statements for flower 3.

Works like a charm

Not sure if this is correct, but closest I could come to making random movements without using variables.

Last edited by DogSoldier; 04-01-2009 at 11:44 PM.
   
Reply With Quote
Old
Scott300
Senior Member
 
Status: Offline
Posts: 80
Join Date: Feb 2009
Location: Ohio
Default 04-02-2009, 09:11 AM

Couldent you use like a cube as the varable I mean you could set green = 1 red = 2

if (cube color = green)
{
print "this = 1"
}
if (cube color = red)
{
print "this = 2"
}

Sorry if I totaly missed the point of this XDDDD
  Send a message via AIM to Scott300 Send a message via MSN to Scott300  
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 ©2022, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.