random procedure wants exact integers in scheme -


i given real number between 0 , 1. niceness-factor. factor kind of probability. mean if 0.2, means happen probability of 1/5.

i tried use

random  

procedure this. here code piece:

  (if (eq? 'c (tit-for-tat my-history other-history))    'c    (if (= (random (/ 1 niceness-factor)) 0) 'c 'd)) 

however "random" procedure wants me give exact integer number. how can solve problem? there procedure similar random?

thanks in advance...

just convert niceness-factor integer-like value (something comparable result of random). example:

(if (eq? 'c (tit-for-tat my-history other-history))     'c     (if (> (random 100) (* 100 niceness-factor))          'c          'd))) 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -