class _RandomAgent extends Agent { _RandomAgent(this.name, this.random); final String name; final Random random; Decision decide(List history, GameConfiguration configuration) { return random.nextBool() ? Decision.cooperate : Decision.defect; } } class _GrimTriggerAgent extends Agent { _GrimTriggerAgent(this.name); final String name; Decision decide(List history, GameConfiguration configuration) { if (history.any((Round round) => round.partner == Decision.defect)) { return Decision.defect; } return Decision.cooperate; } } class _TitForTatAgent extends Agent { _TitForTatAgent(this.name); final String name; Decision decide(List history, GameConfiguration configuration) { if (history.isEmpty) { return Decision.cooperate; } switch (history.last.partner) { case Decision.cooperate: return Decision.cooperate; case Decision.defect: return Decision.defect; } } }