
from player import COOPERATION, BETRAY


class Payoff(object):
    BETRAY = 5
    COOPERATION = 3
    BETRAY_EACH_OTHER = 1
    GET_BETRAYED = 0


class Game(object):

    def __init__(self, player1, player2):
        self.players = [player1, player2]

    def play(self):
        players = self.players
        strategies = [
            players[0].play_against(id(players[1])),
            players[1].play_against(id(players[0]))
        ]
        self.strategies = strategies
        # print strategies

        if strategies[0] == COOPERATION and strategies[1] == COOPERATION:
            for player in self.players:
                player.increase_payoff(Payoff.COOPERATION)
        elif strategies[0] == COOPERATION and strategies[1] == BETRAY:
            players[0].increase_payoff(Payoff.GET_BETRAYED)
            players[1].increase_payoff(Payoff.BETRAY)
        elif strategies[0] == BETRAY and strategies[1] == COOPERATION:
            players[0].increase_payoff(Payoff.BETRAY)
            players[1].increase_payoff(Payoff.GET_BETRAYED)
        else:
            for player in self.players:
                player.increase_payoff(Payoff.BETRAY_EACH_OTHER)

        self._send_record_to_players()

    def _send_record_to_players(self):
       strategies = self.strategies
       self.players[0].save_game_record(
           id(self.players[1]), (strategies[1], strategies[0]))
       self.players[1].save_game_record(
           id(self.players[0]), (strategies[0], strategies[1]))


@@ -1246,24 +1246,25 @@
 lf):%0A       
+ 
 strategies =
@@ -1276,24 +1276,25 @@
 .strategies%0A
+ 
        self.
@@ -1314,32 +1314,33 @@
 ve_game_record(%0A
+ 
            id(se
@@ -1390,24 +1390,25 @@
 0%5D))%0A       
+ 
 self.players
@@ -1421,32 +1421,33 @@
 ve_game_record(%0A
+ 
            id(se
@@ -1494,9 +1494,8 @@
 es%5B1%5D))%0A
-%0A

fix indentation