Random help needed
stanimation
Member Posts: 406
I'm trying to figure out a random rule. Here is an example:
(ceil(random(-.99,.99))*180)+90
The problem is I don't think the ceil is working with the negative number. I need to generate random 0 and 1. Any help would be appreciated!! Thanks!!
(ceil(random(-.99,.99))*180)+90
The problem is I don't think the ceil is working with the negative number. I need to generate random 0 and 1. Any help would be appreciated!! Thanks!!
Comments
What is final range of numbers that you are looking for?
Change Attribute
self.myRandomNumber To: random(1,4)
Rule
When all conditions are valid:
self.myRandomNumber = 1
Change Attribute: self.chosenNumber To: 180
Rule
When all conditions are valid:
self.myRandomNumber = 2
Change Attribute: self.chosenNumber To: 90
etc...
However, since those two numbers are mathematically related nicely, you could do this:
Change Attribute
self.myRandomNumber To: (random(0,1) * 90) + 90
That will give you EITHER 90 or 180.
What are the other two numbers? Maybe they can easily work as well.
self.myRandomDirection To: (random(0,3) * 90) + 90
That will give you either 90,180, 270, or 360(0)
Is that sort of what you were thinking?
I haven't tested it, but you MIGHT need to wrap the whole thing in a modulus function to make sure it wraps back to zero, like this:
Change Attribute
self.myRandomDirection To: ((random(0,3) * 90) + 90)%360
Which will give you either 90,180, 270, or 0
(the 360 will be forced back to zero)