On this page:
Version: 4.1.1

1 Common Definitions

 (require (planet "common.ss" ("murphy" "rpg-utils.plt" 1 0)))

The common module contains support for dice rolls, functions useful when computing statistics and some structure definitions.

(make-dice sides cumulative?)



(->* ()



  sides : exact-positive-integer?

  cumulative? : any/c

Creates a dice with the specified number of sides and optionally with accumulating behaviour, if cumulative? is not #f.

A cumulative dice is rerolled whenever the result of a roll was equal to the number of its sides. The results of multiple (re-)rolls are summed up.

Returns a procedure of one optional argument that simulates a dice roll. If present, the argument to the die procedure specifies the PRNG to use. By default the value of (current-pseudo-random-generator) is used.

(fact n)  exact-positive-integer?

  n : exact-nonnegative-integer?

Computes the factorial of a natural number n. The result of this procedure is an exact number. If (eqv? n 0), the procedure returns 1.





(successful? critical? value))

  successful? : boolean?

  critical? : boolean?

  value : any/c

Represents the result of a simulated test in a role playing game. The flags successful? and critical? determine the obvious properties of the outcome.

The meaning of the value depends on the rule system and potentially on the type of the test.





(successful critical expectation))

  successful : (real-in 0 1)

  critical : (real-in 0 1)

  expectation : any/c

Represents the result of a statistical analysis for a test in a role playing game. The fields successful and critical correspond to the similarly named flags in a test-result and contain the probabilities that these flags would be set in a simulated result.

The expectation field contains the expected most likely value of the value in a simulated test result.