示例#1
0
    def act(self):
        """Overriding base class act."""
        if self.pNum==self.gs.active_player:
            if self.gs.game_mode == 1: # Play
                log.info("{0} is playing...".format(self.label))
                #Play first legal card
                for c in self.hand:
                    if self.is_legal_play(c):
                        self.play(c)
                        break

            elif self.gs.game_mode == 2: # Bid
                log.info("{0} is bidding...".format(self.label))
                
                if self.gs.high_bid < 4:
                    bid = random.randint(self.gs.high_bid+1,4) # Never cinch
                else:
                    bid = 0
                log.info("{0} considers bidding {1}...".format(self.label, bid))

                r = random.random()
                if ((bid > 0) and (r < 0.75)):
                    self.bid(bid)
                else:
                    self.bid(0)
示例#2
0
    def act(self):
        """Overriding base class act."""
        if self.pNum==self.gs.active_player:

            if self.gs.game_mode == 1: # Play
                log.info("{0} is playing...".format(self.label))
                legal_cards = []
                for c in self.hand:
                    if self.is_legal_play(c):
                        legal_cards.append(c)
                chosen_card_pos = random.randint(0,len(legal_cards)-1)
                chosen_card = legal_cards[chosen_card_pos]
                self.play(chosen_card)

            elif self.gs.game_mode == 2: # Bid
                log.info("{0} is bidding...".format(self.label))
                r = random.random()
                if self.is_legal_bid(self.gs.high_bid+1) and (r < 0.5):
                    bid = self.gs.high_bid+1
                    self.bid(bid)
                else:
                    self.bid(0)
示例#3
0
    def act(self):
        """Overriding base class act."""
        if self.pNum==self.gs.active_player:
            if self.gs.game_mode == 1: # Play
                log.info("{0} is playing...".format(self.label))
                # Play last legal card (opposite of Dave)
                for c in reversed(self.hand):
                    if self.is_legal_play(c):
                        self.play(c)
                        break

            elif self.gs.game_mode == 2: # Bid
                log.info("{0} is bidding...".format(self.label))
                
                try:
                    bid = random.randint(self.gs.high_bid+1,5)
                except ValueError: # Because randint(6,5) fails.
                    bid = 5
                log.info("{0} considers bidding {1}...".format(self.label, bid))
                r = random.random()
                if self.is_legal_bid(bid) and (r < 0.6):
                    self.bid(bid)
                else:
                    self.bid(0)