Coin Toss

Discussion in 'Computer Science & Culture' started by Spectrum, Mar 15, 2011.

Thread Status:
Not open for further replies.
  1. Spectrum Registered Senior Member

    Messages:
    459
    Code:
    'RESETCLOCK
     a$=time$
     b$=time$
      while (b$=a$)
       b$=time
      wend
    'RESETCOUNTER
     a$=time$
     c&=0 
      while (b$=a$)
       b$=time$
       c&=c&+1
      wend
    'SIGNIFICANCECALCULATIONS
     d&=(c&-1)/2
     e&=(c&-1)-d&
    'RESULTS
    print d&;"-";e&
    
    This code counts as high as it can in a second. The result is different everytime (sometimes the same result occurs twice, but if it didn't then it wouldn't be different , would it?)

    However, you must remove one from the result (because zero is the first position, one the second etc.):

    0123456789
    123456789A

    So, the result must be divided by two to find an average (d&), but to find if the results are significant you must minus d& from (c&-1) to find the true average. Sometimes the results are equal, but there is a maximum difference of one (2), therefore the results are significant.

    This code can be used for all types of computer games, providing the minimum rate of change for the program is one second (actually two seconds if you reset the seconds to '00' (as the first part of the code does.)
     
Thread Status:
Not open for further replies.

Share This Page