Jump to content

"division by 0" issue


testgenord1
 Share

You are about to reply to a thread that has been inactive for 1000 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

6 hours ago, testgenord1 said:

endless loop

mathproblem()
{
   if (somerandomthing == someotherrandomthing)
   {
      mathproblem();
   }
}

 

to address this then we need to change  to a 'conditional random' algorithm that breaks ties. Is a number of ways to do this. The most straightforward method to break ties is additive. Example:

[hmm! wrong example deleted]

this one  

quotient = (integer)llFrand(range);
   divisor = (integer)llFrand(range - 1) + 1;
   dividend = quotient / divisor;

   // calculate 'random' distractors that conditionally break ties
   // dividend == (0) -> (0)
   // distractor1 == (0) -> (1)
   // distractor2 == (0) -> (1) ... (1) -> (2)
 
   distractor1 = llFrand(range);
   distractor2 = llFrand(range);

   if (distractor1 == dividend)
   {   // add some
       distractor1 += 1.0;
   }   
   while ((distractor2 == dividend) || (distractor2 == distractor1))
   {   // add some. while loop will run max. 2 times
       distractor2 += 1.0;
   }

    

 

Edited by Mollymews
simplify
  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1000 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...