Exemple #1
0
    def play(self, rubbers=1):
        self.players = [Player(i, (i+2)%4, x) for i, x in enumerate(self._bots)]        
        dealerID = self.players[0].identifier
        currentHand = 0

        for rubber in range(rubbers):
            newRubber = False 
            hands = 0
            while newRubber == False or hands < 20:
                dealerID = self.players[rubber % 4].identifier
                log.event("Start hand " + str(currentHand))
                game = Game(self.players, self.teamStates, dealerID)
                result = game.play()
                if result is not None:
                    newGame, newRubber = self._update_match_points(result)
                    for i, state in enumerate(self.teamStates):
                        log.event("Current state for Team {0}... {1}".format(i,state))
                    log.event("Hand complete, current score: {0} vs {1}".format(self.teamPoints[0], self.teamPoints[1]))
                    if newGame:
                        log.summary("Game complete, current score: {0} vs {1}".format(self.teamPoints[0], self.teamPoints[1]))
                        matchStatsLog.log(self.teamPoints)
                hands += 1                    
                currentHand += 1
            log.summary("Rubber {0} complete".format(rubber))
        gameStatsLog.dump_log()
        matchStatsLog.dump_log()
        return self.teamPoints
Exemple #2
0
    def play(self, rubbers=1):
        self.players = [
            Player(i, (i + 2) % 4, x) for i, x in enumerate(self._bots)
        ]
        dealerID = self.players[0].identifier
        currentHand = 0

        for rubber in range(rubbers):
            newRubber = False
            hands = 0
            while newRubber == False or hands < 20:
                dealerID = self.players[rubber % 4].identifier
                log.event("Start hand " + str(currentHand))
                game = Game(self.players, self.teamStates, dealerID)
                result = game.play()
                if result is not None:
                    newGame, newRubber = self._update_match_points(result)
                    for i, state in enumerate(self.teamStates):
                        log.event("Current state for Team {0}... {1}".format(
                            i, state))
                    log.event(
                        "Hand complete, current score: {0} vs {1}".format(
                            self.teamPoints[0], self.teamPoints[1]))
                    if newGame:
                        log.summary(
                            "Game complete, current score: {0} vs {1}".format(
                                self.teamPoints[0], self.teamPoints[1]))
                        matchStatsLog.log(self.teamPoints)
                hands += 1
                currentHand += 1
            log.summary("Rubber {0} complete".format(rubber))
        gameStatsLog.dump_log()
        matchStatsLog.dump_log()
        return self.teamPoints
Exemple #3
0
def main(argv):
    args = parse_args()

    d = os.path.dirname('.\logs')
    print(d)
    print(os.getcwd())
    if not os.path.exists(d):
        os.makedirs('logs')

    log.verbose = False

    names = [x[:-3] for x in os.listdir("bots") if x[-3:] == ".py"]
    names.remove("__init__")

    started = time.clock()

    bots = [
        "kerpowski_bot", "kerpowski_conservative_bot", "kerpowski_bot",
        "kerpowski_conservative_bot"
    ]
    sys.path.append("bots")
    battle = Match([__import__(x) for x in bots])
    battle.play(args.rubberCount)

    print("")
    log.summary("Completed in", str(int(time.clock() - started)), "seconds")
    log.dump_log()
Exemple #4
0
def main(argv):
    args = parse_args()
    
    d = os.path.dirname('.\logs')
    print(d)
    print(os.getcwd())
    if not os.path.exists(d):
        os.makedirs('logs')
        
    log.verbose = False
    
    names = [x[:-3] for x in os.listdir("bots") if x[-3:] == ".py"]
    names.remove("__init__")
    
    started = time.clock()
    
    bots = ["kerpowski_bot", "kerpowski_conservative_bot", "kerpowski_bot", "kerpowski_conservative_bot"]
    sys.path.append("bots")
    battle = Match([__import__(x) for x in bots])
    battle.play(args.rubberCount)
    
    print("")
    log.summary("Completed in", str(int(time.clock() - started)), "seconds")
    log.dump_log()