1 | <?php |
||
20 | class Engine |
||
21 | { |
||
22 | private $objectivePlayer; |
||
23 | |||
24 | private $maxDepth; |
||
25 | |||
26 | /** |
||
27 | * @var Analytics|null Only available after run, contains statistics about the |
||
28 | * execution. |
||
29 | */ |
||
30 | private $analytics; |
||
31 | |||
32 | /** |
||
33 | * @param Player $objectivePlayer The player to play as. The engine will try |
||
34 | * to maximize this player's score. |
||
35 | * @param int $maxDepth How many turns ahead should the engine look? |
||
36 | */ |
||
37 | 17 | public function __construct(Player $objectivePlayer, int $maxDepth = 3) |
|
42 | |||
43 | /** |
||
44 | * Evaluate possible decisions and take the best one |
||
45 | * |
||
46 | * @param GameState $state Current state of the game for which there needs |
||
47 | * to be made a decision. This implicitly means that the objective player |
||
48 | * currently must have its turn in the GameState. |
||
49 | * @return GameState The state resulting after the engine made its decision. |
||
50 | */ |
||
51 | 16 | public function decide(GameState $state): GameState |
|
75 | |||
76 | 2 | public function getAnalytics(): Analytics |
|
83 | } |
||
84 |