def remod(gameState): gameState = gameState.clone() currentPlayer = gameState.players[gameState.turn] result = currentPlayer.selectInput(InputSets.handCardSet(gameState, 1), gameState, actionSimulator=remodSim1, helpMessage='Choose a card to trash') if result == None: return gameState else: result = result[0] cards = gameState.pcards[gameState.turn] cards.hand[result] -= 1 gameState.trash[result] += 1 costs = range(result.cost + 2 + 1) result = currentPlayer.selectInput(InputSets.stackCardSet(gameState, costs=costs), gameState, actionSimulator=remodSim2) if result == None: return gameState else: result = result[0] gameState.stacks[result] -= 1 cards.gain(result) return gameState
def gainDiscard(gameState): gameState = gameState.clone() gameState.abcs[gameState.turn]['coins'] += 2 currentPlayer = gameState.players[gameState.turn] response = currentPlayer.selectInput(InputSets.tf(), gameState, actionSimulator = actionSim) if response and response[0]: gameState.pcards[gameState.turn].deckToDiscard() return gameState
def gainDiscard(gameState): gameState = gameState.clone() gameState.abcs[gameState.turn]['coins'] += 2 currentPlayer = gameState.players[gameState.turn] response = currentPlayer.selectInput(InputSets.tf(), gameState, actionSimulator=actionSim) if response and response[0]: gameState.pcards[gameState.turn].deckToDiscard() return gameState
def evaluate(self, gameState): abcs = gameState.abcs[gameState.turn] total_coins = abcs['coins'] + sum([card.coins*gameState.pcards[0].hand[card] for card in gameState.pcards[0].hand]) v = [0,0,0,0,0] v[0] = abcs['actions'] * len(list(InputSets.handCardSet(gameState, number=1, filtered = lambda c: (c.action != None)))) v[1] = min(abcs['buys']*8, total_coins) v[2] = total_coins v[3] = sum([c.cost*n for c,n in gameState.pcards[gameState.turn].allCards().items()]) v[4] = (gameState.pcards[gameState.turn].currInPlay.count + gameState.pcards[gameState.turn].hand.count) return sum([v[i]*self.params[i] for i in xrange(len(self.params))])
def lend(gameState): gameState = gameState.clone() currentPlayer = gameState.players[gameState.turn] if gameState.pcards[gameState.turn].hand[Copper()] > 0: result = currentPlayer.selectInput(InputSets.tf(), gameState, actionSimulator = actionSim, helpMessage='Do you want to trash a copper?') if result and result[0]: gameState.pcards[gameState.turn].hand[Copper()] -= 1 gameState.trash[Copper()] += 1 gameState.abcs[gameState.turn]['coins'] += 3 return gameState
def work(gameState): gameState = gameState.clone() currentPlayer = gameState.players[gameState.turn] result = currentPlayer.selectInput(InputSets.stackCardSet(gameState, costs=[0,1,2,3,4]), gameState, actionSimulator = actionSim) if result == None: return gameState else: result = result[0] gameState.stacks[result] -= 1 gameState.pcards[gameState.turn].gain(result) return gameState
def dbl(gameState): gameState = gameState.clone() currentPlayer = gameState.players[gameState.turn] result = currentPlayer.selectInput(InputSets.handCardSet(gameState, 1, filtered = lambda c: (c.action != None)), gameState, actionSimulator=dblSimulator, helpMessage='Choose which card to play twice') if result == None: return gameState else: result = result[0] gameState.pcards[gameState.turn].playFromHand(result) gameState = result.action(gameState) gameState = result.action(gameState) return gameState
def lend(gameState): gameState = gameState.clone() currentPlayer = gameState.players[gameState.turn] if gameState.pcards[gameState.turn].hand[Copper()] > 0: result = currentPlayer.selectInput( InputSets.tf(), gameState, actionSimulator=actionSim, helpMessage='Do you want to trash a copper?') if result and result[0]: gameState.pcards[gameState.turn].hand[Copper()] -= 1 gameState.trash[Copper()] += 1 gameState.abcs[gameState.turn]['coins'] += 3 return gameState
def gainCard(gameState): gameState = gameState.clone() currentPlayer = gameState.players[gameState.turn] result = currentPlayer.selectInput(InputSets.stackCardSet(gameState, costs=xrange(5+1)), gameState, actionSimulator = actionSim) if result == None: return gameState else: result = result[0] gameState.trash[Feast()] += 1 gameState.pcards[gameState.turn].currInPlay[Feast()] -= 1 gameState.stacks[result] -= 1 gameState.pcards[gameState.turn].gain(result) return gameState
def work(gameState): gameState = gameState.clone() currentPlayer = gameState.players[gameState.turn] result = currentPlayer.selectInput(InputSets.stackCardSet( gameState, costs=[0, 1, 2, 3, 4]), gameState, actionSimulator=actionSim) if result == None: return gameState else: result = result[0] gameState.stacks[result] -= 1 gameState.pcards[gameState.turn].gain(result) return gameState
def mine(gameState): gameState = gameState.clone() currentPlayer = gameState.players[gameState.turn] minedCard = currentPlayer.selectInput( InputSets.handCardSet(gameState, 1, filtered=(lambda x: x.coins > 0)), gameState, actionSimulator = mineSim1, helpMessage = 'Which Treasure do you choose to Trash?') if minedCard == None: return gameState else: minedCard = minedCard[0] costs = [minedCard.cost + i for i in xrange(4)] gameState.trash[minedCard] += 1 gameState.pcards[gameState.turn].hand[minedCard] -= 1 newCard = currentPlayer.selectInput( InputSets.stackCardSet(gameState, 1, costs=costs, filtered=(lambda x: x.coins > 0)), gameState, actionSimulator = mineSim2,) if newCard == None: return gameState else: newCard = newCard[0] gameState.stacks[newCard] -= 1 gameState.pcards[gameState.turn].hand[newCard] += 1 return gameState
def remod(gameState): gameState = gameState.clone() currentPlayer = gameState.players[gameState.turn] result = currentPlayer.selectInput( InputSets.handCardSet(gameState, 1), gameState, actionSimulator=remodSim1, helpMessage="Choose a card to trash" ) if result == None: return gameState else: result = result[0] cards = gameState.pcards[gameState.turn] cards.hand[result] -= 1 gameState.trash[result] += 1 costs = range(result.cost + 2 + 1) result = currentPlayer.selectInput( InputSets.stackCardSet(gameState, costs=costs), gameState, actionSimulator=remodSim2 ) if result == None: return gameState else: result = result[0] gameState.stacks[result] -= 1 cards.gain(result) return gameState
def gainCard(gameState): gameState = gameState.clone() currentPlayer = gameState.players[gameState.turn] result = currentPlayer.selectInput(InputSets.stackCardSet(gameState, costs=xrange(5 + 1)), gameState, actionSimulator=actionSim) if result == None: return gameState else: result = result[0] gameState.trash[Feast()] += 1 gameState.pcards[gameState.turn].currInPlay[Feast()] -= 1 gameState.stacks[result] -= 1 gameState.pcards[gameState.turn].gain(result) return gameState
def dbl(gameState): gameState = gameState.clone() currentPlayer = gameState.players[gameState.turn] result = currentPlayer.selectInput( InputSets.handCardSet(gameState, 1, filtered=lambda c: (c.action != None)), gameState, actionSimulator=dblSimulator, helpMessage='Choose which card to play twice') if result == None: return gameState else: result = result[0] gameState.pcards[gameState.turn].playFromHand(result) gameState = result.action(gameState) gameState = result.action(gameState) return gameState
def mineSim1(gameState, minedCard): gameState = gameState.clone() currentPlayer = gameState.players[gameState.turn] if minedCard == None: return gameState else: minedCard = minedCard[0] costs = [minedCard.cost + i for i in xrange(4)] gameState.trash[minedCard] += 1 gameState.pcards[gameState.turn].hand[minedCard] -= 1 newCard = currentPlayer.selectInput( InputSets.stackCardSet(gameState, 1, costs=costs, filtered=(lambda x: x.coins > 0)), gameState) if newCard == None: return gameState else: newCard = newCard[0] gameState.stacks[newCard] -= 1 gameState.pcards[gameState.turn].hand[newCard] += 1 return gameState
def evaluate(self, gameState): abcs = gameState.abcs[gameState.turn] total_coins = abcs['coins'] + sum([ card.coins * gameState.pcards[0].hand[card] for card in gameState.pcards[0].hand ]) v = [0, 0, 0, 0, 0] v[0] = abcs['actions'] * len( list( InputSets.handCardSet( gameState, number=1, filtered=lambda c: (c.action != None)))) v[1] = min(abcs['buys'] * 8, total_coins) v[2] = total_coins v[3] = sum([ c.cost * n for c, n in gameState.pcards[gameState.turn].allCards().items() ]) v[4] = (gameState.pcards[gameState.turn].currInPlay.count + gameState.pcards[gameState.turn].hand.count) return sum([v[i] * self.params[i] for i in xrange(len(self.params))])
def availableBuys(self, gameState, money): if not gameState.abcs[gameState.turn]['buys']: return [] cards = list(InputSets.stackCardSet(gameState, number=1, costs=range(money+1))) return [card[0] for card in cards]
def availableActions(self, gameState): if not gameState.abcs[gameState.turn]['actions']: return [] cards = list(InputSets.handCardSet(gameState, number=1, filtered = lambda c: (c.action != None))) return [card[0] for card in cards]