forked from Axelrod-Python/Axelrod
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase_match.py
More file actions
73 lines (60 loc) · 2.22 KB
/
base_match.py
File metadata and controls
73 lines (60 loc) · 2.22 KB
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
70
71
72
73
from typing import Dict, List, Tuple, Union
import axelrod as axl
from axelrod.base_game import BaseGame
from axelrod.base_player import BasePlayer
Score = Union[int, float]
class BaseMatch(object):
"""The BaseMatch class conducts matches between two players."""
def __init__(
self,
players: Tuple[BasePlayer],
turns: int = None,
prob_end: float = None,
game: BaseGame = None,
noise: float = 0,
match_attributes: Dict = None,
reset: bool = True,
):
"""
Needs to be overwritten in derived class.
Parameters
----------
players : tuple
A pair of axelrodPlayer objects
turns : integer
The number of turns per match
prob_end : float
The probability of a given turn ending a match
game : axelrod.BaseGame
The game object used to score the match
noise : float
The probability that a player's intended action should be flipped
match_attributes : dict
Mapping attribute names to values which should be passed to players.
The default is to use the correct values for turns, game and noise
but these can be overridden if desired.
reset : bool
Whether to reset players or not
"""
pass
@property
def players(self) -> Tuple[BasePlayer]:
raise NotImplementedError()
def play(self) -> List[Tuple[axl.Action]]:
"""The resulting list of actions from a match between two players."""
raise NotImplementedError()
def scores(self) -> List[Score]:
"""Returns the scores of the previous BaseMatch plays."""
raise NotImplementedError()
def final_score(self) -> Score:
"""Returns the final score for a BaseMatch."""
raise NotImplementedError()
def final_score_per_turn(self) -> Score:
"""Returns the mean score per round for a BaseMatch."""
raise NotImplementedError()
def winner(self) -> BasePlayer:
"""Returns the winner of the IpdMatch."""
raise NotImplementedError()
def __len__(self) -> int:
"""Number of turns in the match"""
raise NotImplementedError()