1use crate::{Move, Past, PlayerIndex, Transcript};
2
3#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
6pub struct Ply<M, const P: usize> {
7 pub player: Option<PlayerIndex<P>>,
9 pub the_move: M,
11}
12
13impl<M: Move, const P: usize> Ply<M, P> {
14 pub fn new(player: Option<PlayerIndex<P>>, the_move: M) -> Self {
16 Ply { player, the_move }
17 }
18
19 pub fn player(player: PlayerIndex<P>, the_move: M) -> Self {
21 Ply::new(Some(player), the_move)
22 }
23
24 pub fn chance(the_move: M) -> Self {
26 Ply::new(None, the_move)
27 }
28
29 pub fn is_player(&self) -> bool {
31 self.player.is_some()
32 }
33
34 pub fn is_chance(&self) -> bool {
36 self.player.is_none()
37 }
38}
39
40pub type Plies<'a, M, const P: usize> = Past<'a, Ply<M, P>>;
42
43impl<'a, M: Move, const P: usize> Plies<'a, M, P> {
44 pub fn into_transcript(self) -> Transcript<M, P> {
46 Transcript::from_plies(self)
47 }
48}