예제 #1
0
    def choose(self, befores, afters):
        cheat = (random.random() > 0.5)
        cardsWIdx = [(i, self.state.hand[i])
                     for i in range(len(self.state.hand))]
        cards = sorted(cardsWIdx, key=lambda x: x[1], cmp=TraitCard.compare)
        maxCardIdx = len(cards) - 1
        newSpecIdx = len(self.state.species)
        curCardIdx = 3

        if cheat:
            print "cheating with double-spending and card replacement!"
            gp = [GainPopulation(newSpecIdx, maxCardIdx)]
            gb = [GainBodySize(newSpecIdx, maxCardIdx)]  # double-spend
            rt = [
                ReplaceTrait(newSpecIdx, 1, curCardIdx)
            ]  # try to place on a non-placed trait card with a legal card
        else:
            gp = [GainPopulation(newSpecIdx, cards[curCardIdx][0])
                  ] if curCardIdx <= maxCardIdx else []
            curCardIdx += 1
            gb = [GainBodySize(newSpecIdx, cards[curCardIdx][0])
                  ] if curCardIdx <= maxCardIdx else []
            curCardIdx += 1
            rt = [ReplaceTrait(newSpecIdx, 0, cards[curCardIdx][0])
                  ] if curCardIdx <= maxCardIdx else []

        return Action4(cards[0][0], gp, gb,
                       [BuySpeciesBoard(cards[1][0], [cards[2][0]])], rt)
예제 #2
0
 def setUp(self):
     self.t1 = TraitCard("horns", 3)
     self.t2 = TraitCard("ambush", 1)
     self.t3 = TraitCard("carnivore", 2)
     self.t4 = TraitCard("fat-tissue", 0)
     self.t5 = TraitCard("foraging", 3)
     self.t6 = TraitCard("herding", 0)
     self.defSpec = Species(0, 0, 1, [], 0)
     self.specWGrownBody = Species(0, 1, 1, [], 0)
     self.specW3t = Species(0, 0, 1, [self.t3, self.t4, self.t5], 0)
     self.specWAll = Species(0, 1, 2, [self.t4], 0)
     self.playerWithManyCards = PlayerState(
         1, 0, [], [self.t1, self.t2, self.t3, self.t4, self.t5, self.t6])
     self.playerForAll = PlayerState(1, 0, [self.specWAll], [])
     self.playerFor3t = PlayerState(1, 0, [self.specW3t], [self.t6])
     self.playerForDefSpec = PlayerState(1, 0, [self.defSpec],
                                         [self.t5, self.t6])
     self.playerForBodyNewspec = PlayerState(
         1, 0, [self.specWGrownBody], [self.t3, self.t4, self.t5, self.t6])
     self.noAct = Action4(0, [], [], [], [])
     self.actGP = Action4(0, [GainPopulation(0, 1)], [], [], [])
     self.actGB = Action4(0, [], [GainBodySize(0, 1)], [], [])
     self.actRT = Action4(0, [], [], [ReplaceTrait(0, 1, 1)], [])
     self.actBT0t = Action4(0, [], [], [], [BuySpeciesBoard(1, [])])
     self.actBT1t = Action4(0, [], [], [], [BuySpeciesBoard(1, [2])])
     self.actBT2t = Action4(0, [], [], [], [BuySpeciesBoard(1, [2, 3])])
     self.actBT3t = Action4(0, [], [], [], [BuySpeciesBoard(1, [2, 3, 4])])
     self.actBT4t = Action4(0, [], [], [],
                            [BuySpeciesBoard(1, [2, 3, 4, 5])])
     self.addBodyToNewSpec = Action4(0, [GainPopulation(1, 1)], [], [],
                                     [BuySpeciesBoard(2, [3])])
     self.actAll = Action4(0, [GainPopulation(0, 1)], [GainBodySize(0, 2)],
                           [ReplaceTrait(0, 0, 3)],
                           [BuySpeciesBoard(4, [5])])
예제 #3
0
	def choose(self, befores, afters):
		cardsWIdx = [(i, self.state.hand[i]) for i in range(len(self.state.hand))]
		cards = sorted(cardsWIdx, key=lambda x: x[1], cmp=TraitCard.compare) 
		maxCardIdx = len(cards) - 1
		newSpecIdx = len(self.state.species)
		curCardIdx = 3
		
		gp = [GainPopulation(newSpecIdx, cards[curCardIdx][0])] if curCardIdx <= maxCardIdx else []
		curCardIdx += 1
		gb = [GainBodySize(newSpecIdx, cards[curCardIdx][0])] if curCardIdx <= maxCardIdx else []
		curCardIdx += 1
		rt = [ReplaceTrait(newSpecIdx, 0, cards[curCardIdx][0])] if curCardIdx <= maxCardIdx else []

		return Action4(cards[0][0], gp, gb, [BuySpeciesBoard(cards[1][0], [cards[2][0]])], rt) 
예제 #4
0
    def setUp(self):
        self.t1 = TraitCard("horns", 3)
        self.t2 = TraitCard("ambush", 1)
        self.t3 = TraitCard("carnivore", 2)
        self.t4 = TraitCard("fat-tissue", 0)
        self.t5 = TraitCard("foraging", 3)
        self.vegHorns = Species(1, 2, 3, [TraitCard("horns")], 0)
        self.vegCoop = Species(1, 2, 3, [TraitCard("cooperation")], 0)
        self.fat = Species(4, 3, 4, [TraitCard("fat-tissue")], 3)
        self.fatScav = Species(
            2, 3, 4, [TraitCard("fat-tissue"),
                      TraitCard("scavenger")], 1)
        self.fatFor = Species(4, 3, 4,
                              [TraitCard("fat-tissue"),
                               TraitCard("foraging")], 1)
        self.carnCoop = Species(
            3, 4, 5, [TraitCard("carnivore"),
                      TraitCard("cooperation")], 0)
        self.carnForage = Species(
            3, 4, 5, [TraitCard("carnivore"),
                      TraitCard("foraging")], 0)
        self.carnForage1 = Species(
            3, 4, 5, [TraitCard("carnivore"),
                      TraitCard("foraging")], 0)
        self.extinct = Species(0, 0, 0, [], 0)
        self.p1 = PlayerState(1, 0, [self.vegCoop, self.fat, self.carnForage],
                              [])
        self.p2 = PlayerState(2, 0,
                              [self.vegHorns, self.fatScav, self.carnCoop], [])
        self.p3 = PlayerState(3, 0,
                              [self.vegCoop, self.carnCoop, self.carnForage1],
                              [])
        self.p4 = PlayerState(4, 0, [self.vegCoop], [])
        self.p5 = PlayerState(5, 0, [self.vegHorns], [])
        self.p6 = PlayerState(6, 0, [self.carnCoop], [])
        self.p7 = PlayerState(7, 0, [self.fatScav], [])
        self.p8 = PlayerState(8, 0, [self.fatFor, self.extinct], [])
        self.dealer = Dealer([self.p1, self.p2, self.p3], 3,
                             [self.t1, self.t2, self.t3, self.t4, self.t5])
        self.p2dealer = Dealer([self.p6, self.p5], 3, [])
        self.p3dealer = Dealer([self.p8], 3,
                               [self.t1, self.t2, self.t3, self.t4, self.t5])

        self.xstep3spec = Species(0, 5, 2, [TraitCard("foraging")], 0)
        self.xstep3p = PlayerState(1, 0, [self.xstep3spec], [])
        self.xstep3deal = Dealer([self.xstep3p], 5, [])

        # 8949-0357-4
        self.pCFS1 = PlayerState(1, 3, [
            Species(4, 2, 5,
                    [TraitCard("carnivore"),
                     TraitCard("cooperation")], 0),
            Species(1, 3, 4, [
                TraitCard("foraging"),
                TraitCard("carnivore"),
                TraitCard("scavenger")
            ], 0)
        ], [])
        self.pCFS2 = PlayerState(
            2, 4, [Species(2, 3, 3, [TraitCard("burrowing")], 0)], [])
        self.pCFS3 = PlayerState(3, 5, [], [])
        self.dCFS = Dealer([self.pCFS1, self.pCFS2, self.pCFS3], 10, [])

        # for step4
        self.t6 = TraitCard("herding", 0)
        self.defSpec = Species(0, 0, 1, [], 0)
        self.specWGrownBody = Species(0, 1, 1, [], 0)
        self.specW3t = Species(0, 0, 1, [self.t3, self.t4, self.t5], 0)
        self.specWAll = Species(2, 1, 2, [self.t4], 1)
        self.playerWithManyCards = PlayerState(
            1, 0, [], [self.t1, self.t2, self.t3, self.t4, self.t5, self.t6])
        self.playerForAll = PlayerState(1, 0, [self.specWAll], [])
        self.playerFor3t = PlayerState(1, 0, [self.specW3t], [self.t6])
        self.playerForDefSpec = PlayerState(1, 0, [self.defSpec],
                                            [self.t5, self.t6])
        self.playerForBodyNewSpec = PlayerState(
            1, 0, [self.specWGrownBody], [self.t3, self.t4, self.t5, self.t6])
        self.noAct = Action4(0, [], [], [], [])
        self.actGP = Action4(0, [GainPopulation(0, 0)], [], [], [])
        self.actGB = Action4(0, [], [GainBodySize(0, 1)], [], [])
        self.actRT = Action4(0, [], [], [], [ReplaceTrait(0, 1, 1)])
        self.actBT0t = Action4(0, [], [], [BuySpeciesBoard(1, [])], [])
        self.actBT1t = Action4(0, [], [], [BuySpeciesBoard(1, [2])], [])
        self.actBT2t = Action4(0, [], [], [BuySpeciesBoard(1, [2, 3])], [])
        self.actBT3t = Action4(0, [], [], [BuySpeciesBoard(1, [2, 3, 4])], [])
        self.actBT4t = Action4(0, [], [], [BuySpeciesBoard(1, [2, 3, 4, 5])],
                               [])
        self.addBodyToNewSpec = Action4(0, [GainPopulation(1, 1)], [],
                                        [BuySpeciesBoard(2, [3])], [])
        self.actAll = Action4(0, [GainPopulation(0, 1)], [GainBodySize(0, 2)],
                              [BuySpeciesBoard(4, [5])],
                              [ReplaceTrait(0, 0, 3)])
        self.simpleDealerForStep4 = Dealer([self.playerWithManyCards], 0, [])
        self.dealerForRevokingCards = Dealer([
            PlayerState(1, 0, [], [self.t1, self.t2]),
            PlayerState(2, 0, [], [self.t3, self.t4, self.t5]),
            PlayerState(3, 0, [], [self.t6])
        ], 0, [])

        self.dealerManyActions = Dealer([
            PlayerState(1, 0, [self.defSpec], [self.t1, self.t2]),
            PlayerState(2, 0, [self.vegHorns, self.fatScav, self.carnCoop],
                        [self.t3, self.t4, self.t5, self.t6, self.t1]),
            PlayerState(3, 0, [self.vegCoop, self.carnCoop, self.carnForage1],
                        [self.t6])
        ], 0, [])