예제 #1
0
    def __init__(self,
                 players,
                 use_gui,
                 iterations=1,
                 switch_order=True,
                 replay_deck=True,
                 replay_destinations=True,
                 print_debug=False,
                 exception_on_bad_action=True,
                 pause_between_turns=0,
                 maximum_rounds=1000):
        Driver.__init__(self, players, use_gui, print_debug,
                        exception_on_bad_action, pause_between_turns,
                        maximum_rounds)

        self.iterations = iterations
        self.switch_order = switch_order
        self.replay_deck = replay_deck
        self.replay_destinations = replay_destinations
        self.original_players = deepcopy(self.players)

        self.wins = Counter({player.name: 0 for player in self.players})

        # Create a list to use in the header of the CSV file, with Player 1, Player 2, etc.\.
        header_list = []

        self.add_line_for_players(header_list,
                                  lambda player, idx: "Player %d" % (idx + 1))
        self.add_line_for_players(header_list,
                                  lambda player, idx: "P%d Score" % (idx + 1))
        self.add_line_for_players(header_list,
                                  lambda player, idx: "P%d Draws" % (idx + 1))
        self.add_line_for_players(
            header_list, lambda player, idx: "P%d Connections" % (idx + 1))
        self.add_line_for_players(
            header_list, lambda player, idx: "P%d Cars at End" % (idx + 1))
        self.add_line_for_players(
            header_list, lambda player, idx: "P%d Points from Routes" %
            (idx + 1))
        self.add_line_for_players(
            header_list, lambda player, idx: "P%d Points from Destinations" %
            (idx + 1))
        self.add_line_for_players(
            header_list,
            lambda player, idx: "P%d Points lost from Destinations" %
            (idx + 1))
        self.add_line_for_players(
            header_list, lambda player, idx: "P%d Win Rate" % (idx + 1))

        header_list.append("Winner")

        # Create a name for the log file created.
        name = "i%d_s%s_deck%s_dest%s" % (iterations, "T" if switch_order else
                                          "F", "T" if replay_deck else "F",
                                          "T" if replay_destinations else "F")

        self.csv_log = CSVLog(name, *header_list)
예제 #2
0
    def __init__(self, parameters,logger ):
        '''
        Constructor
        '''
        Driver.__init__(self, parameters,logger )

        self.last_write_count= 0
        self.last_bytes_used_eth0= 0
        self.last_bytes_used_wlan0= 0