def start_games(amount_of_games): player_a_wins = 0 player_b_wins = 0 games_played = 0 logging.info( "Starting Open MTG. Playing {0} games".format(amount_of_games)) for i in range(amount_of_games): gold_deck = deck.get_8ed_core_gold_deck() silver_deck = deck.get_8ed_core_silver_deck() current_game = game.Game( [player.Player(gold_deck), player.Player(silver_deck)]) current_game.start_game() if current_game.active_player.index == 0: logging.info("Gold player starts game") else: logging.info("Silver player starts game") while not current_game.is_over(): if current_game.player_with_priority.index is 1: move = current_game.player_with_priority.determine_move( method="random", game=current_game) else: # move = game.player_with_priority.determine_move(method="random", game=game) if len(current_game.get_moves()) == 1: move = current_game.get_moves()[0] else: move = mcts.uct(current_game, itermax=5) current_game.make_move(move, False) if current_game.players[1].has_lost: player_a_wins += 1 elif current_game.players[0].has_lost: player_b_wins += 1 games_played += 1 logging.info("Game {0} is over! current standings: " "{1} - {2}".format(games_played, player_a_wins, player_b_wins)) logging.info("Player A won {0} out of {1}".format(player_a_wins, games_played)) logging.info("Player B won {0} out of {1}".format(player_b_wins, games_played)) logging.info("Quitting Open MTG{0}{0}".format(os.linesep))
def GameLoop(gameboard, count=0): # Game loop should keep track of whose turn it is # using the turn flag. We can then use this flag to # set up the functions in the Gamemanager file to # condense the fuctions that are currently seperated # like player and opp prize setups. At the begining of # the game we can have a random number generator acting # as a coin to select who goes first and sets the flag. # Then all the setups will take place for that player then # change the flag and setup the next player and so on. # We just need to make sure we setup the boardstate before hand, # ie have prizes layed out and determine mulligans. #Start a new game #0 - Player #1 - Opponent print("___________________Start of Next ACTION______________________________") counter = count if gameboard.turn == 'p': turn = 'player' elif gameboard.turn == 'o': turn = 'opponent' counter -= 1 winner = False #Control game go = True while go == True: ## Check for win condition gameOver = gameboard.checkWinCon(gameboard.turn) displayBoard(gameboard) counter += 1 with open('gamelog.txt', 'a') as file: file.write("Turn: " + str(count) + " of " + turn + "\n") if gameOver != 1 and gameOver != 0: selectedMove = str(mcts.uct(gameboard,maxIteration)) move = parseMove(selectedMove) print("The suggested move for " + turn + " is " + move) if move == 'play energy': if turn == 'player': for i in range(len(gameboard.playerHand)): if gameboard.playerHand[i].Card_Type == "Energy": gameboard.energyPlayed = False gameboard.playEnergy('p',i) gameboard.energyPlayed = True print("Player actually played energy!") file.write("Player actually played energy!\n") file.write("___________________END OF ACTION______________________________\n") break if turn == 'opponent': for i in range(len(gameboard.oppHand)): if gameboard.oppHand[i].Card_Type == "Energy": gameboard.energyPlayed = False gameboard.playEnergy('o',i) gameboard.energyPlayed = True print("Opponent actually played energy!") file.write("Opponent actually played energy!\n") file.write("___________________END OF ACTION______________________________\n") break elif move == 'attack' and turn == 'player' : if gameboard.checkEnergyCost(gameboard.playerActive[0].Attack_One_Cost, gameboard.playerActive[0].Energies): gameboard.attack(gameboard.turn, gameboard.playerActive[0].Attack_One_Name, gameboard.playerActive[0].Attack_One_Damage, gameboard.playerActive[0].Attack_One_Cost) file.write("Player attacked!\n") file.write("------------------------------END OF TURN-----------------------------\n-") elif move == 'attack' and turn == 'opponent' : if gameboard.checkEnergyCost(gameboard.oppActive[0].Attack_One_Cost, gameboard.oppActive[0].Energies): gameboard.attack(gameboard.turn, gameboard.oppActive[0].Attack_One_Name, gameboard.oppActive[0].Attack_One_Damage, gameboard.oppActive[0].Attack_One_Cost) file.write("Opponent attacked!\n") file.write("------------------------------END OF TURN-----------------------------\n-") elif (move == 'pass turn' or move == 'retreat') and turn == 'player': gameboard.passTurn(gameboard.turn) print(turn + " " + move) file.write(turn + " " + move + "\n") file.write("------------------------------END OF TURN-----------------------------\n-") elif (move == 'pass turn' or move == 'retreat') and turn == 'opponent': gameboard.passTurn(gameboard.turn) print(turn + " " + move) file.write(turn + " " + move + "\n") file.write("------------------------------END OF TURN-----------------------------\n-") elif move == 'play basic' and turn == 'player': if len(gameboard.playerBench) < 5: #print("Attempted to play bench pokemon") for i in range(len(gameboard.playerHand)): if gameboard.playerHand[i].Card_Type == "Pokemon": if gameboard.playerHand[i].Stage == 0 and len(gameboard.playerBench) < 5: print("Player played " + gameboard.playerHand[i].Name + " to the bench") file.write("Player played " + gameboard.playerHand[i].Name + " to the bench\n") gameboard.playBasic(i, gameborad.turn) file.write("___________________END OF ACTION______________________________\n") break elif move == 'play basic' and turn == 'opponent': if len(gameboard.oppBench) < 5: #print("Attempted to play bench pokemon") for i in range(len(gameboard.oppHand)): if gameboard.oppHand[i].Card_Type == "Pokemon": if gameboard.oppHand[i].Stage == 0 and len(gameboard.oppBench) < 5: print("Opponent played " + gameboard.oppHand[i].Name + " to the bench") file.write("Oppenent played " + gameboard.oppHand[i].Name + " to the bench\n") gameboard.playBasic(i, gameboard.turn) file.write("___________________END OF ACTION______________________________\n") break elif gameOver == 1: print("Player has won") file.write("Player has won!\n") del gameboard break elif gameOver == 0: print("Opponent has won") file.write("Opponent has won!\n") del gameboard break #input("Press enter to continue.") #gameboard.energyPlayed = False saveBoard(gameboard) #displayBoard(gameboard) GameLoop(gameboard, counter)
# last todo (also part of article) : log some games, see if everything makes sense player_0_wins = 0 player_1_wins = 0 prev_phase = "" for i in range(1): game = Game(Player(get_8ed_core_gold_deck()), Player(get_8ed_core_silver_deck())) game.start_game() if game.active_player.index == 0: print("Gold player's turn") else: print("Silver player's turn") while not game.is_over(): if game.player_with_priority.index is 1: move = game.player_with_priority.determine_move(method="random", game=game) else: # move = game.player_with_priority.determine_move(method="random", game=game) if len(game.get_moves()) == 1: move = game.get_moves()[0] else: move = mcts.uct(game, itermax=5) game.make_move(move, False) if game.players[1].has_lost: player_0_wins += 1 elif game.players[0].has_lost: player_1_wins += 1 print("game is over! current standings: %i - %i" % (player_0_wins, player_1_wins)) print("player 0 wins: %i, player 1 wins: %i" % (player_0_wins, player_1_wins))
def GameLoop(gameboard, count=0): # Game loop should keep track of whose turn it is # using the turn flag. We can then use this flag to # set up the functions in the Gamemanager file to # condense the fuctions that are currently seperated # like player and opp prize setups. At the begining of # the game we can have a random number generator acting # as a coin to select who goes first and sets the flag. # Then all the setups will take place for that player then # change the flag and setup the next player and so on. # We just need to make sure we setup the boardstate before hand, # ie have prizes layed out and determine mulligans. #Start a new game #0 - Player #1 - Opponent print( "___________________Start of Next ACTION______________________________" ) counter = count #Counter for logging which turn it is #Handles the game turn. #This should be changed in a future iteration of this program #Have one variable called playerTurn and make it a bool. True from player turn and Fasle for opponent #Would make hendling it easier. if gameboard.turn == 'p': turn = 'player' elif gameboard.turn == 'o': turn = 'opponent' counter -= 1 #Control game go = True while go == True: ## Check for win condition gameOver = gameboard.checkWinCon(gameboard.turn) displayBoard( gameboard ) #Displays the gameboard for the user. this is good for debugging counter += 1 #Opens file for logging purposes with open('gamelog.txt', 'a') as file: file.write("Turn: " + str(count) + " of " + turn + "\n") #Checks if there is a game over if gameOver != 1 and gameOver != 0: selectedMove = str( mcts.uct(gameboard, maxIteration) ) #Runs the mcts and saves the result as a string to selected move move = parseMove(selectedMove) print("The suggested move for " + turn + " is " + move) ## Handles the actual gameplay for the AI ## Checks the move and carries out the action associated with the mcts selected move if move == 'play energy': if turn == 'player': for i in range(len(gameboard.playerHand)): if gameboard.playerHand[i].Card_Type == "Energy": gameboard.energyPlayed = False #The mcts is affecting the energyPlayed flag when it runs so it needs to be changed to false before running play energy gameboard.playEnergy('p', i) gameboard.energyPlayed = True print("Player actually played energy!") file.write("Player actually played energy!\n") file.write( "___________________END OF ACTION______________________________\n" ) break if turn == 'opponent': for i in range(len(gameboard.oppHand)): if gameboard.oppHand[i].Card_Type == "Energy": gameboard.energyPlayed = False gameboard.playEnergy('o', i) gameboard.energyPlayed = True print("Opponent actually played energy!") file.write( "Opponent actually played energy!\n") file.write( "___________________END OF ACTION______________________________\n" ) break elif move == 'attack' and turn == 'player': if gameboard.checkEnergyCost( gameboard.playerActive[0].Attack_One_Cost, gameboard.playerActive[0].Energies): #print(gameboard.oppActive[0].Name + "'s HP went down to " + str((gameboard.oppActive[0].Hp - gameboard.playerActive[0].Attack_One_Damage)) + " from " + str(gameboard.oppActive[0].HP)) gameboard.attack( gameboard.turn, gameboard.playerActive[0].Attack_One_Name, gameboard.playerActive[0].Attack_One_Damage, gameboard.playerActive[0].Attack_One_Cost) gameOver = gameboard.checkWinCon( gameboard.turn ) #Checks for a game over after an attack if gameOver == 1: print("Player has won") file.write("Player has won!\n") del gameboard break elif gameOver == 0: print("Opponent has won") file.write("Opponent has won!\n") del gameboard break print(turn + " attacked " + gameboard.oppActive[0].Name + " for " + str(gameboard.playerActive[0].Attack_One_Damage)) #gameboard.turn = 'o' #gameboard.oppDrawCard() file.write("Player attacked!\n") file.write( "------------------------------END OF TURN-----------------------------\n-" ) elif move == 'attack' and turn == 'opponent': if gameboard.checkEnergyCost( gameboard.oppActive[0].Attack_One_Cost, gameboard.oppActive[0].Energies): #print(gameboard.playerActive[0].Name + "'s HP went down to " + str((gameboard.playerActive[0].Hp - gameboard.oppActive[0].Attack_One_Damage)) + " from " + str(gameboard.playerActive[0].HP)) gameboard.attack( gameboard.turn, gameboard.oppActive[0].Attack_One_Name, gameboard.oppActive[0].Attack_One_Damage, gameboard.oppActive[0].Attack_One_Cost) gameOver = gameboard.checkWinCon(gameboard.turn) if gameOver == 1: print("Player has won") file.write("Player has won!\n") go = False del gameboard break elif gameOver == 0: print("Opponent has won") file.write("Opponent has won!\n") go = False break del gameboard print(turn + " attacked " + gameboard.playerActive[0].Name + " for " + str(gameboard.oppActive[0].Attack_One_Damage)) #gameboard.turn = 'p' #gameboard.playerDrawCard() file.write("Opponent attacked!\n") file.write( "------------------------------END OF TURN-----------------------------\n-" ) elif ( move == 'pass turn' or move == 'retreat' ) and turn == 'player': #Retreat isn't implemented yet so we just make it pass turn gameboard.passTurn(gameboard.turn) print(turn + " " + move) gameboard.turn = 'o' gameboard.oppDrawCard() file.write(turn + " " + move + "\n") file.write( "------------------------------END OF TURN-----------------------------\n-" ) elif (move == 'pass turn' or move == 'retreat') and turn == 'opponent': gameboard.passTurn(gameboard.turn) print(turn + " " + move) gameboard.turn = 'p' gameboard.playerDrawCard() file.write(turn + " " + move + "\n") file.write( "------------------------------END OF TURN-----------------------------\n-" ) elif move == 'play basic' and turn == 'player': if len(gameboard.playerBench) < 5: #print("Attempted to play bench pokemon") for i in range(len(gameboard.playerHand)): if gameboard.playerHand[i].Card_Type == "Pokemon": if gameboard.playerHand[i].Stage == 0 and len( gameboard.playerBench) < 5: print("Player played " + gameboard.playerHand[i].Name + " to the bench") file.write("Player played " + gameboard.playerHand[i].Name + " to the bench\n") gameboard.playBasic(i, gameboard.turn) file.write( "___________________END OF ACTION______________________________\n" ) break elif move == 'play basic' and turn == 'opponent': if len(gameboard.oppBench) < 5: #print("Attempted to play bench pokemon") for i in range(len(gameboard.oppHand)): if gameboard.oppHand[i].Card_Type == "Pokemon": if gameboard.oppHand[i].Stage == 0 and len( gameboard.oppBench) < 5: print("Opponent played " + gameboard.oppHand[i].Name + " to the bench") file.write("Oppenent played " + gameboard.oppHand[i].Name + " to the bench\n") gameboard.playBasic(i, gameboard.turn) file.write( "___________________END OF ACTION______________________________\n" ) break elif gameOver == 1: print("Player has won") file.write("Player has won!\n") go = False del gameboard break elif gameOver == 0: print("Opponent has won") file.write("Opponent has won!\n") go = False del gameboard break #input("Press enter to continue.") #gameboard.energyPlayed = False saveBoard(gameboard) #displayBoard(gameboard) GameLoop(gameboard, counter)
def GameLoop(): #Initialize game variables turn = '' winner = False maxIteration = 1000 ## Initialize the gameboard gameboard = GameManager.Gameboard() gameboard.__init__() ## Initialize the decks obj = GameManager.Card(card1) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card1) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card2) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card2) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card3) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card3) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card3) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card4) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card4) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card5) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card5) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card6) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card7) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card7) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card8) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card9) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card10) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card10) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card11) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card11) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card12) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card13) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card13) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card14) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card15) obj.setOwner('p') gameboard.playerDeck.append(obj) obj.setOwner('o') gameboard.oppDeck.append(obj) obj = GameManager.Card(card15) obj.setOwner('p') gameboard.playerDeck.append(obj) obj.setOwner('o') gameboard.oppDeck.append(obj) obj = GameManager.Card(card16) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card17) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) for i in range(3): obj = GameManager.Card(card18) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card19) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card19) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card20) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card20) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card21) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card22) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card22) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card23) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card23) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) for i in range(12): obj = GameManager.Card(card24) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) for i in range(8): obj = GameManager.Card(card25) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) # Set the gameboard to the default state gameboard.setup() #Control game variable go = True while go == True: # Get players board state from the user getPlayerActive(gameboard) # Get players benched pokemon getPlayerBench(gameboard) #Get player's hand getPlayerHand(gameboard) #Get player's discard getPlayerDiscard(gameboard) #Get stadium in play getStadium(gameboard) #get player's prizes getPlayerPrize(gameboard) #find out if energy was played this turn getEnergyPlayed(gameboard) #find out if supporter was played this turn getSupporterPlayed(gameboard) # Get opponents active pokemon getOppActive(gameboard) #Get opponent's benched pokemon getOppBench(gameboard) #Get opponents discard getOppDiscard(gameboard) #Get opponent's hand getOppHand(gameboard) #Get opponents prizes getOppPrize(gameboard) ## Check for win condition gameOver = gameboard.checkWinCon(gameboard.turn) if gameOver != 1 and gameOver != 0: selectedMove, name = mcts.uct(gameboard, maxIteration) move = parseMove(selectedMove, name) print("The suggested move is " + move) print("Ratio: " + mcts.repr()) elif gameOver == 1: print("Player has won") newGame() elif gameOver == 0: print("Opponent has won") newGame() temp = input("Press enter to continue. Enter 'quit' to exit\n") if temp.lower() == 'quit': sys.exit() resetState(gameboard) GameLoop()
def GameLoop(): # Game loop should keep track of whose turn it is # using the turn flag. We can then use this flag to # set up the functions in the Gamemanager file to # condense the fuctions that are currently seperated # like player and opp prize setups. At the begining of # the game we can have a random number generator acting # as a coin to select who goes first and sets the flag. # Then all the setups will take place for that player then # change the flag and setup the next player and so on. # We just need to make sure we setup the boardstate before hand, # ie have prizes layed out and determine mulligans. #Start a new game turn = '' winner = False ## Initialize the gameboard gameboard = GameManager.Gameboard() ## Initialize the decks obj = GameManager.Card(card1) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card1) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card2) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card2) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card3) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card3) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card3) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card4) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card4) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card5) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card5) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card6) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card7) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card7) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card8) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card9) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card10) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card10) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card11) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card11) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card12) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card13) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card13) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card14) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card15) obj.setOwner('p') gameboard.playerDeck.append(obj) obj.setOwner('o') gameboard.oppDeck.append(obj) obj = GameManager.Card(card15) obj.setOwner('p') gameboard.playerDeck.append(obj) obj.setOwner('o') gameboard.oppDeck.append(obj) obj = GameManager.Card(card16) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card17) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) for i in range(3): obj = GameManager.Card(card18) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card19) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card19) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card20) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card20) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card21) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card22) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card22) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card23) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) obj = GameManager.Card(card23) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) for i in range(12): obj = GameManager.Card(card24) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) for i in range(8): obj = GameManager.Card(card25) gameboard.playerDeck.append(obj) gameboard.oppDeck.append(obj) # Set the gameboard to the default state gameboard.setup() #Control game go = True while go == True: # Get players board state from the user getPlayerActive(gameboard) # Get players benched pokemon getPlayerBench(gameboard) #Get player's hand getPlayerHand(gameboard) #Get player's discard getPlayerDiscard(gameboard) #Get stadium in play getStadium(gameboard) #get player's prizes getPlayerPrize(gameboard) # Get opponents active pokemon getOppActive(gameboard) #Get opponent's benched pokemon getOppBench(gameboard) #Get opponents discard getOppDiscard(gameboard) #Get opponent's hand getOppHand(gameboard) #Get opponents prizes getOppPrize(gameboard) ## Check for win condition gameOver = gameboard.checkWinCon(gameboard.turn) if gameOver != 1 and gameOver != 0: selectedMove = str(mcts.uct(gameboard,50)) move = parseMove(selectedMove) print("The suggested move is " + move) elif gameOver == 1: print("Player has won") newGame() elif gameOver == 0: print("Opponent has won") newGame() del gameboard input("Press enter to continue.") GameLoop()