use rand::{seq::IteratorRandom, SeedableRng}; use rand_pcg::Pcg64Mcg; use crate::game::Game; pub struct RandomPlayer { rng: Pcg64Mcg, } impl RandomPlayer { pub fn new(seed: u64) -> RandomPlayer { RandomPlayer { rng: Pcg64Mcg::seed_from_u64(seed), } } pub fn act<G: Game>(&mut self, game: &G) -> <G as Game>::Action { game.actions() .as_ref() .into_iter() .choose(&mut self.rng) .unwrap() .clone() } }