Ok, domanda finale e avrò finito il mio gioco di indovinelli in Common Lisp! : D Ogni volta che il gioco inizia (o una nuova partita inizia dopo il primo gioco), viene chiamata la seguente funzione.(casuale) in comune Lisp non così casuale?
;;; Play the game
(defun play()
;; If it's their first time playing this session,
;; make sure to greet the user.
(unless (> *number-of-guesses* 0)
(welcome-user))
;; Reset their remaining guesses
(setq *number-of-guesses* 0)
;; Set the target value
(setq *target*
;; Random can return float values,
;; so we must round the result to get
;; an integer value.
(round
;; Add one to the result, because
;; (random 100) yields a number between
;; 0 and 99, whereas we want a number
;; from 1 to 100 inclusive.
(+ (random 100) 1)))
(if (eql (prompt-for-guess) t)
(play)
(quit)))
Quindi presumibilmente, ogni volta che il giocatore inizia un gioco, *target*
deve essere impostato per un nuovo intero casuale compreso tra 1-100. Tuttavia, ogni volta, *target*
imposta automaticamente su 82. Come faccio a fare (random)
... in modo casuale?
Il commento non è necessariamente corretto. La specifica CL non impone l'utilizzo dell'ora corrente, dice semplicemente "inizializzata casualmente con qualche mezzo". – Svante
@Svante: Sì hai ragione. Aggiornato. – kennytm