forked from WuTheFWasThat/hanabi.rs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
strategy.rs
25 lines (22 loc) · 1022 Bytes
/
strategy.rs
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
use crate::game::*;
// Traits to implement for any valid Hanabi strategy
// Represents the strategy of a given player
pub trait PlayerStrategy {
// A function to decide what to do on the player's turn.
// Given a BorrowedGameView, outputs their choice.
fn decide(&mut self, _: &BorrowedGameView) -> TurnChoice;
// A function to update internal state after other players' turns.
// Given what happened last turn, and the new state.
fn update(&mut self, _: &TurnRecord, _: &BorrowedGameView);
}
// Represents the overall strategy for a game
// Shouldn't do much, except store configuration parameters and
// possibility initialize some shared randomness between players
pub trait GameStrategy {
fn initialize(&self, _: Player, _: &BorrowedGameView) -> Box<dyn PlayerStrategy>;
}
// Represents configuration for a strategy.
// Acts as a factory for game strategies, so we can play many rounds
pub trait GameStrategyConfig {
fn initialize(&self, _: &GameOptions) -> Box<dyn GameStrategy>;
}