1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use crate::game::breakthrough::{Breakthrough, BreakthroughBuilder, Color, Move};
use crate::game::{Base, Game, GameBuilder, Playable};
use async_trait::async_trait;
use std::fmt;
#[derive(Clone, PartialEq, Eq)]
pub struct MisereBreakthrough {
game: Breakthrough,
}
impl fmt::Debug for MisereBreakthrough {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.game.fmt(f)
}
}
#[derive(Clone)]
struct Misere(BreakthroughBuilder);
#[async_trait]
impl GameBuilder for Misere {
type G = MisereBreakthrough;
async fn create(&self, turn: Color) -> MisereBreakthrough {
MisereBreakthrough {
game: self.0.create(turn).await,
}
}
}
impl Base for MisereBreakthrough {
type Move = Move;
fn possible_moves(&self) -> Vec<Move> {
self.game.possible_moves()
}
}
#[async_trait]
impl Playable for MisereBreakthrough {
async fn play(&mut self, m: &Move) -> f32 {
-self.game.play(m).await
}
}
impl Game for MisereBreakthrough {
type Player = Color;
fn players() -> Vec<Color> {
Breakthrough::players()
}
fn turn(&self) -> Color {
self.game.turn()
}
fn player_after(player: Self::Player) -> Self::Player {
Breakthrough::player_after(player)
}
}
impl MisereBreakthrough {
pub fn show(&self) {
self.game.show()
}
}