Type Definition m_ipd::Strategy [−][src]
type Strategy = fn() -> Box<dyn FnMut(Round) -> Choice>;
Represents a playing strategy
This function will be invoked one time every time two players play the IPD. The closure that is
returned by the function will be repeatedly invoked with values of the Round
enum; each
invocation of the closure corresponds to one round of gameplay. The closure is told the
other player’s choice in the previous round, and asked to return the next round’s choice.
A very simple strategy might be to always Cooperate
. It could be written like this:
use m_ipd::*; fn always_cooperate() -> Box<dyn FnMut(Round) -> Choice> { Box::new(|_| Cooperate) } let s: Strategy = always_cooperate;