def __init__(self, numPlayers): self.sizeDrawPile = 5 self.maxWilds = 3 self.numTicketsDealt = 3 self.sizeStartingHand = 4 self.endingTrainCount = 3 # ending condition to trigger final round self.pointsForLongestRoute = 10 self.startingNumOfTrains = 45 self.deck = TTRCards.Cards(self.sizeDrawPile, self.maxWilds) self.board = TTRBoard.Board() self.numPlayers = numPlayers self.players = [] self.posToMove = 0 #point values for tracks of different lengths self.routeValues = {1: 1, 2: 2, 3: 4, 4: 7, 5: 10, 6: 15} for position in range(numPlayers): startingHand = self.deck.dealCards(self.sizeStartingHand) startingTickets = [] #self.deck.dealTickets(self.numTicketsDealt) #this is now done in initialize method below #occurs before first player's first move playerBoard = TTRBoard.PlayerBoard() player = TTRPlayer.Player(startingHand, startingTickets, playerBoard, position, self.startingNumOfTrains) self.players.append(player)
def create_all_players(self): for position in range(self.numPlayers): startingHand = self.deck.dealCards(self.sizeStartingHand) startingTickets = [] playerBoard = TTRBoard.PlayerBoard() player = TTRPlayer.Player(startingHand, startingTickets, playerBoard, position, self.startingNumOfTrains) self.players.append(player)
def __init__(self, numAIPlayers, numHumanPlayers, aiStrategies): self.sizeDrawPile = 5 self.maxWilds = 3 self.numTicketsDealt = 3 self.sizeStartingHand = 4 self.endingTrainCount = 3 # ending condition to trigger final round self.pointsForLongestRoute = 10 self.startingNumOfTrains = 45 self.deck = TTRCards.Cards(self.sizeDrawPile, self.maxWilds) self.board = TTRBoard.Board() self.fullBoard = TTRBoard.Board() self.numAIPlayers = numAIPlayers self.numHumanPlayers = numHumanPlayers self.numPlayers = numAIPlayers + numHumanPlayers self.players = [] self.gameBoard = TTRBoard.Board() self.posToMove = 0 #point values for tracks of different lengths self.routeValues = {1: 1, 2: 2, 3: 4, 4: 7, 5: 10, 6: 15} for position in range(numHumanPlayers): type = 'Human' startingHand = self.deck.dealCards(self.sizeStartingHand) startingTickets = [] #self.deck.dealTickets(self.numTicketsDealt) #this is now done in initialize method below #occurs before first player's first move playerBoard = TTRBoard.PlayerBoard() player = TTRPlayer.Player(startingHand, startingTickets, playerBoard, position, self.startingNumOfTrains, type) self.players.append(player) for position in range(numAIPlayers): type_ = 'AI' strategy = aiStrategies[position] startingHand = self.deck.dealCards(self.sizeStartingHand) startingTickets = [] # self.deck.dealTickets(self.numTicketsDealt) # this is now done in initialize method below # occurs before first player's first move playerBoard = TTRBoard.PlayerBoard() if strategy == 'tickets': player = ticketAIPlayer.ticketAIPlayer( startingHand, startingTickets, playerBoard, position, self.startingNumOfTrains, type_) elif strategy == 'route': player = routeAIPlayer.routeAIPlayer(startingHand, startingTickets, playerBoard, position, self.startingNumOfTrains, type_) elif strategy == 'random': player = randomAIPlayer.randomAIPlayer( startingHand, startingTickets, playerBoard, position, self.startingNumOfTrains, type_) elif strategy == 'mixed': player = mixedAIPlayer.mixedAIPlayer(startingHand, startingTickets, playerBoard, position, self.startingNumOfTrains, type_) self.players.append(player)