| Lingo Tutorial: Randomness File "go_nuts.dir" This example shows the use of function random(max_choices) which returns a number between 1 and max_choices. The example is in terms of the game "go nuts": You try to click the smiley face. Every time you do, you hear a beep. (You can extend it to show you how many times you have succeeded in beeping, if you want. It
        looks like an impossible game, but you can actually score
        high easily. (Why?) 
on hideAndSeek
   repeat with x = 1 to 5
     chances = random(4) 
     if (chances = 1) then -- give 25% chances of appearing
        sprite(x).member = "smile"
     else
        sprite(x).member = "black"
     end if
   end repeat
end                                                            File "hide_seek.dir"   Can you see why it is impossible? Suggest a way of making it a bit more fair (e.g., by giving the user a chance of actually hitting the face from time to time). 
if rollover(currentOne) then
   sprite(currentOne).member = "black"
   -- find another
   nextOne = random(5)
   if nextOne = currentOne then 
      nextOne = 1 + (currentOne + 1) mod 5
   end if
   sprite(nextOne).member = "smile"
   currentOne = nextOne
end if                                   
 | |
| 
 Maintained By: Takis Metaxas 
 | |