+
+class Solution:
+ """
+ A representation of the solution of a linear game. It should contain
+ the value of the game, and both players' strategies.
+ """
+ def __init__(self, game_value, p1_optimal, p2_optimal):
+ self._game_value = game_value
+ self._player1_optimal = p1_optimal
+ self._player2_optimal = p2_optimal
+
+ def __str__(self):
+ """
+ Return a string describing the solution of a linear game.
+
+ The three data that are described are,
+
+ * The value of the game.
+ * The optimal strategy of player one.
+ * The optimal strategy of player two.
+
+ """
+
+ tpl = 'Game value: {:.7f}\n' \
+ 'Player 1 optimal:{:s}\n' \
+ 'Player 2 optimal:{:s}\n'
+
+ p1 = '\n{!s}'.format(self.player1_optimal())
+ p1 = '\n '.join(p1.splitlines())
+ p2 = '\n{!s}'.format(self.player2_optimal())
+ p2 = '\n '.join(p2.splitlines())
+
+ return tpl.format(self.game_value(), p1, p2)
+
+
+ def game_value(self):
+ return self._game_value
+
+
+ def player1_optimal(self):
+ return self._player1_optimal
+
+
+ def player2_optimal(self):
+ return self._player2_optimal
+
+