def test_GameOver(self): # init data self.dataSetUp() # test to make sure game is not over self.assertEqual(False, Dominion.gameover(self.supply)) # remove all the provinces from the supply del self.supply["Province"] # test to make sure game is over self.assertEqual(True, Dominion.gameover(self.supply)) # make a new supply self.supply = testUtility.GetSupply(self.box, self.nV, self.nC, len(self.player_names), 5) # test to make sure game is not over self.assertEqual(False, Dominion.gameover(self.supply)) # remove 3 supply cards removed = 0 for stack in self.supply: if removed == 3: break if stack != 'Province': self.supply[stack] = [] removed += 1 # test to make sure game is over self.assertEqual(True, Dominion.gameover(self.supply))
def dataSetUp(self): # Data setup self.player_names = ["*Annie", "Ben", "*Carla"] self.nV = testUtility.GetNumVictory(self.player_names) self.nC = testUtility.GetNumCurses(self.player_names) self.box = testUtility.GetBoxes(self.nV) self.supply_order = testUtility.GetSupplyOrder() #Setup supply with 5 cards self.supply = testUtility.GetSupply(self.box, self.nV, self.nC, len(self.player_names), 5) self.trash = [] #set player self.player = Dominion.Player(self.player_names[1]) #Ben
# 2 players is now 10 and > 2 is 14 #I fixed the bug for testing # number of curses and victory cards nV = getVictoryCards(player_names) nC = getCurseCards(player_names) # Define box box = testUtility.GetBoxes(nV) supply_order = testUtility.getSupplyOrder() # Pick 10 cards from box to be in the supply. boxlist = testUtility.GetBoxList(box, nV, nC, player_names) # The supply always has these cards supply = testUtility.GetSupply(nV, nC, player_names, boxlist, box) # initialize the trash trash = [] # Construct the Player objects players = testUtility.buildPlayers(player_names) # Play the game runDomGame = testUtility.runGame(supply,supply_order,players,trash) # Final score dcs = Dominion.cardsummaries(players) vp = dcs.loc['VICTORY POINTS'] vpmax = vp.max() winners = []
#Get player names player_names = ["User","*Computer1","*Computer2"] #number of curses and victory cards nV, nC = testUtility.GetnVnC(player_names) #Define box box = testUtility.GetBoxes(nV) supply_order = testUtility.GetSupplyOrder() #Pick 10 cards from box to be in the supply. boxlist = [k for k in box] random.shuffle(boxlist) random10 = boxlist[:10] supply = defaultdict(list,[(k,box[k]) for k in random10]) supply = testUtility.GetSupply(player_names, supply, nV, nC) #initialize the trash trash = [] #Costruct the Player objects players = testUtility.GetPlayers(player_names) # Bug 2: Workshop behaves like a Village box["Workshop"]=[Dominion.Village()]*10 #Play the game turn = 0 while not Dominion.gameover(supply):
2: ['Estate', 'Cellar', 'Chapel', 'Moat'], 3: ['Silver', 'Chancellor', 'Village', 'Woodcutter', 'Workshop'], 4: [ 'Gardens', 'Bureaucrat', 'Feast', 'Militia', 'Moneylender', 'Remodel', 'Smithy', 'Spy', 'Thief', 'Throne Room' ], 5: [ 'Duchy', 'Market', 'Council Room', 'Festival', 'Laboratory', 'Library', 'Mine', 'Witch' ], 6: ['Gold', 'Adventurer'], 8: ['Province'] } #Initialize supply supply = testUtility.GetSupply(box, len(player_names)) #The supply always has these cards supply["Copper"] = [Dominion.Copper()] * (60 - len(player_names) * 7) supply["Silver"] = [Dominion.Silver()] * 40 supply["Gold"] = [Dominion.Gold()] * 30 supply["Estate"] = [Dominion.Estate()] * nV supply["Duchy"] = [Dominion.Duchy()] * nV supply["Province"] = [Dominion.Province()] * nV supply["Curse"] = [Dominion.Curse()] * nC #Initialize the trash trash = testUtility.GetTrash() #Initialize players players = testUtility.GetPlayers(player_names)
#number of curses and victory cards if len(player_names)>2: nV=12 else: nV=8 nC = -10 + 10 * len(player_names) #Define box box = testUtility.GetBoxes(nV) supply_order = testUtility.GetSupplyOrder() #Pick 10 cards from box to be in the supply. boxlist = testUtility.GetBoxList(box) random10 = boxlist[:10] supply = testUtility.GetSupply(random10, box, player_names, nV, nC) #initialize the trash trash = [] #Costruct the Player objects players = testUtility.GetPlayers(player_names) #Play the game turn = 0 while not Dominion.gameover(supply): turn += 1 print("\r") for value in supply_order: print (value) for stack in supply_order[value]:
nV=8 nC = -10 + 10 * len(player_names) box = testUtility.GetBoxes(nV) supply_order = {0:['Curse','Copper'],2:['Estate','Cellar','Chapel','Moat'], 3:['Silver','Chancellor','Village','Woodcutter','Workshop'], 4:['Gardens','Bureaucrat','Feast','Militia','Moneylender','Remodel','Smithy','Spy','Thief','Throne Room'], 5:['Duchy','Market','Council Room','Festival','Laboratory','Library','Mine','Witch'], 6:['Gold','Adventurer'],8:['Province']} #Pick 10 cards from box to be in the supply. boxlist = [k for k in box] random.shuffle(boxlist) random10 = boxlist[:10] supply = testUtility.GetSupply(nV, nC, player_names, box, random10) #initialize the trash trash = [] players = testUtility.GetPlayer(supply) #Play the game turn = 0 while not Dominion.gameover(supply): turn += 1 print("\r") for value in supply_order: print (value) for stack in supply_order[value]: if stack in supply:
#Define box box = testUtility.GetBoxes(nV) #Initialize cost of cards in supply supply_order = testUtility.GetSupplyOrder() #INTRODUCTION OF BUG FOR ASSIGNMENT-2 supply_order = {0:['Curse'],2:['Estate','Cellar','Chapel','Moat'], 3:['Silver','Chancellor','Village','Woodcutter','Workshop'], 4:['Gardens','Bureaucrat','Feast','Militia','Moneylender','Remodel','Smithy','Spy','Thief','Throne Room'], 5:['Duchy','Copper','Market','Council Room','Festival','Laboratory','Library','Mine','Witch'], 6:['Gold','Adventurer'],8:['Province']} #Pick 10 cards from box to be in the supply. supply = testUtility.GetSupply(box) #The supply always has these cards supply = testUtility.GetStandardSupply(supply, player_names, nV, nC) #initialize the trash trash = [] #Costruct the Player objects players = testUtility.GetPlayers(player_names) #Play the game turn = 0 while not Dominion.gameover(supply): turn += 1 print("\r")
#Get player names player_names = testUtility.GetPlayernames() #Get victory cards nV = testUtility.GetVictory(player_names) #force the number of victory cards to be 8, even if there are more than 2 players nV = 8 #Get number of curses nC = testUtility.GetCurses(player_names) #Define box box = testUtility.GetBoxes(nV) #Get supply order supply_order = testUtility.GetSupply() #Pick 10 cards from box to be in the supply. supply = testUtility.GetSupplyBox(box) #Load Supply testUtility.LoadSupply(supply, player_names, nV, nC) #initialize the trash trash = [] #Create Players players = testUtility.CreatePlayers(player_names) #Play the game turn = 0