In the modules racket and racket/base (random k)
generates an integer from 0 to k-1 inclusive. (k must be between 1 and 4294967087 inclusive) (random
gives an inexact number between 0 and 1 exclusive. reference guide: random provided by racket and racket/base
Assuming you are using the racket, and not one of the other languages racket supports, from where you started adding a call to exact-round would be closest to what you started with:
(if (eq? 'c (tit-for-tat my-history other-history))
'c
(if (= (random (exact-round (/ 1 niceness-factor))) 0) 'c 'd))
But I find the following to be simpler:
(if (eq? 'c (tit-for-tat my-history other-history))
'c
(if (<= (random) niceness-factor) 'c 'd))