add rule fail rate property
This commit is contained in:
parent
ef14cef49b
commit
4d61184edd
2 changed files with 16 additions and 6 deletions
|
@ -36,7 +36,8 @@ pub struct Rule {
|
|||
pub flip_x: bool,
|
||||
pub flip_y: bool,
|
||||
pub rotate: bool,
|
||||
// probability: u8
|
||||
#[serde(default)]
|
||||
pub failrate: u8,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
|
@ -131,6 +132,7 @@ impl Rule {
|
|||
flip_x: false,
|
||||
flip_y: false,
|
||||
rotate: false,
|
||||
failrate: 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -383,6 +385,11 @@ impl Dish {
|
|||
return;
|
||||
}
|
||||
|
||||
let fail: u8 = random();
|
||||
if rule.failrate > fail {
|
||||
return;
|
||||
}
|
||||
|
||||
let width = variant.width;
|
||||
let height = variant.height;
|
||||
let mut old_state = Vec::new();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue