pub trait EntropyRules {
type EntropySeed: Clone + Debug + Send + Serialize + for<'a> Deserialize<'a>;
type EntropyModel;
type EntropyOutput: PartialOrd + Copy + Num + Debug;
// Required methods
fn generate_model(
&self,
seed: &Option<Self::EntropySeed>,
) -> Self::EntropyModel;
fn generate(
&self,
model: &mut Self::EntropyModel,
low: Self::EntropyOutput,
high: Self::EntropyOutput,
) -> Self::EntropyOutput;
}
Expand description
Defines how casuality works inside the battle system.
Entropy must be deterministic. If you use a generator, make sure that by starting from an identical seed the same sequence of random bits will be reproduced.
Required Associated Types§
Sourcetype EntropySeed: Clone + Debug + Send + Serialize + for<'a> Deserialize<'a>
type EntropySeed: Clone + Debug + Send + Serialize + for<'a> Deserialize<'a>
See EntropySeed.
Sourcetype EntropyModel
type EntropyModel
See EntropyModel.
Sourcetype EntropyOutput: PartialOrd + Copy + Num + Debug
type EntropyOutput: PartialOrd + Copy + Num + Debug
See EntropyOutput.
Required Methods§
Sourcefn generate_model(&self, seed: &Option<Self::EntropySeed>) -> Self::EntropyModel
fn generate_model(&self, seed: &Option<Self::EntropySeed>) -> Self::EntropyModel
Generates an EntropyModel
starting from an EntropySeed
.
Sourcefn generate(
&self,
model: &mut Self::EntropyModel,
low: Self::EntropyOutput,
high: Self::EntropyOutput,
) -> Self::EntropyOutput
fn generate( &self, model: &mut Self::EntropyModel, low: Self::EntropyOutput, high: Self::EntropyOutput, ) -> Self::EntropyOutput
Generates a random value within a half-open range [low
, high
).
high
is guaranteed to be greater or equal to low
.