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

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -