Log In  

Cart #tentropy-0 | 2020-01-07 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

do YOU have what it takes to be random?

P#71807 2020-01-07 05:10

Are you doing something like this:

d=0 e=0 g=""
repeat
cls()
?d/e*200
?g
flip()
a=btnp(4)b=btnp(5)
c=rnd()
if a or b then
  f="-"
  if (a and c<.5) d+=1 f="*"
  if (b and c>=.5) d+=1 f="*"
  g=g..f
  if (e%32==31) g=g.."\n"
  e+=1
end
until forever

My take on this cart.

Where "*" means you guessed the same as the computer. Number is score. Over 75 is good.

P#71825 2020-01-07 20:15 ( Edited 2020-01-07 21:57)

i actually simplified a couple randomness tests and used the results from those to calculate a simple score in the range of 0-1.

had fun learning about all the different ways to test randomness, but what i went with was simplified entropy (which for coin flips is essentially the distance between 0.5 and the ratio of 0's to 1's), and maximum run test (which says for a certain number of trials, the maximum run is expected to be a certain length, so i subtracted the distance from that from the score). and lastly, i just punished the player for holding down both keys and typing 10101010..., because doing that gave a pretty good score :)

P#71828 2020-01-07 22:32

... ???

Ah I hadn't considered both buttons.

I can fix that though ... Smaller code:

d=0 e=0g=""h=btnp repeat cls()
?d/e*200
?g
flip()a=h(4)b=h(5)c=rnd()
if(a or b)and not(a and b)then f="-"
if((a and c<.5)or(b and c>=.5))f="*"d+=1
g=g..f if(e%32==31)g=g.."\n"
e+=1end
until z

191-chars.

P#71832 2020-01-08 03:38 ( Edited 2020-01-08 03:49)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 22:38:06 | 0.013s | Q:20