Home
Project Folders
Teacher Resources
Student Resources
How Do I?
Literacy
MWForum
Site Map
Search
Our Team

MWForum Message [Date Index] [Threads] [Authors] [Attachments] [Subscribe]

[Thread Prev] [Thread Next]

To: <mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Subject: Storing a random value for re-use(?)
From: "Russell, Ken" <krussell@xxxxxxxxxxxxxxx>
Date: Tue, 4 Dec 2007 11:19:06 -0800

How would I solve this problem?

I want to write a simple procedure that chooses a random number and uses it 
two (or more) times in a procedure, then chooses another random number. Here 
is a simple example of what I might want to do., create a simple star pattern 
with randomly long rays extending out from the center.

Here is the wrong way to do it:

to star :length
repeat 36 [fd random :length bk random :length rt 10]
end

What I want to do is have the second random in the repeat procedure to be the 
same value as the first random value (so it would go back an equal distance as 
it went forward.

It seems like the first fd random value would need to be stored and re-used as 
a value for bk.

Is there a way to do this?

Thanks so much!

Ken Russell



  • Previous by thread: RE: Question with graphics
  • Next by thread: Re: Storing a random value for re-use(?)

  • To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.


    © copyright 2001 - 2008