card game stuff

This commit is contained in:
2026-05-15 06:53:18 -07:00
parent 09edadc822
commit 77b38608d9
5 changed files with 428 additions and 4 deletions
+16
View File
@@ -1,3 +1,5 @@
use crate::Rng;
// TODO: pub struct ValidInstruction<I>(I);
pub trait Game {
type Instruction;
@@ -61,12 +63,26 @@ impl Stack {
}
Stack(stack)
}
pub fn shuffle<R: rand::Rng>(&mut self, rng: &mut R) {
use rand::seq::SliceRandom;
self.0.shuffle(rng);
}
}
pub struct Session<G: Game> {
seed: Rng,
state: G,
history: Vec<G::Instruction>,
}
impl<G: Game> Session<G> {
pub fn new(seed: Rng, state: G) -> Self {
Self {
seed,
state,
history: Vec::new(),
}
}
}
impl<G: Game> Game for Session<G>
where
G::Instruction: Clone,