def run(self): qu_ja = [CardEnum.QU.value, CardEnum.JA.value] comm_bomb = list( map(lambda x: x[0], filter(lambda x: x[1] == 4, enumerate(self.hand_card_status)))) master_bomb = list( map( lambda x: x[0], filter(lambda x: x[0] in qu_ja and x[1] == 1, enumerate(self.hand_card_status)))) if self.primary_item: comm_bomb = list(filter(lambda x: x > self.primary_item, comm_bomb)) if len(comm_bomb) == 0 and len(master_bomb) < 2: logger.debug('Can not accept the card') return None, None, None comm_bomb.append('master') rnd = random.randint(0, len(comm_bomb) - 1) one_card = comm_bomb[rnd] if one_card == 'master': put_card = qu_ja score = HandCardUtils.value_map(put_card[-1], CardTypeEnum.CT_BOMB, 2) return put_card, score, put_card[-1] put_card = [one_card] * 4 score = HandCardUtils.value_map(put_card[-1], CardTypeEnum.CT_BOMB, 4) return put_card, score, put_card[-1]
def run(self): k = self.kwargs.pop('k', 1) exist_card = HandCardUtils.find_even_three(self.hand_card_status, k=k) if self.primary_item is not None: exist_card = list( filter(lambda x: x > self.primary_item, exist_card)) if len(exist_card) == 0: logger.debug('Can not accept the card') return None, None, None rnd = random.randint(0, len(exist_card) - 1) one_card = exist_card[rnd] exist_card = [one_card - ix for ix in reversed(range(k))] remain_card = self.__flat_card(self.hand_card_status, exist_card) if len(remain_card) < k: logger.debug('Can not accept the card') return None, None, None other_card = sorted(random.sample(remain_card, k)) score = HandCardUtils.value_map(exist_card[-1], CardTypeEnum.CT_THREE_DOU, 3 * k + 2 * k) put_card = list(map(lambda x: [x] * 3, exist_card)) put_card = np.reshape(put_card, (1, -1)).tolist()[0] other_card = list(map(lambda x: [x] * 2, other_card)) other_card = np.reshape(other_card, (1, -1)).tolist()[0] put_card.extend(other_card) return put_card, score, exist_card[-1]
def run(self): k = self.kwargs.pop('k', 5) exist_card = HandCardUtils.find_continues(self.hand_card_status, k=k) if self.primary_item is not None: exist_card = list(filter(lambda x:x > self.primary_item,exist_card)) if len(exist_card) == 0: logger.debug('Can not accept the card') return None, None, None rnd = random.randint(0,len(exist_card)-1) one_card = exist_card[rnd] put_card = [one_card - ix for ix in reversed(range(k))] score = HandCardUtils.value_map(put_card[-1], CardTypeEnum.CT_CONTINUE, k) return put_card, score, put_card[-1]
def run(self): k = self.kwargs.pop('k', 1) exist_card = HandCardUtils.find_even_three(self.hand_card_status, k=k) if self.primary_item is not None: exist_card = list(filter(lambda x:x > self.primary_item,exist_card)) if len(exist_card) == 0: logger.debug('Can not accept the card') return None, None, None rnd = random.randint(0,len(exist_card)-1) one_card = exist_card[rnd] exist_card = [one_card - ix for ix in reversed(range(k))] score = HandCardUtils.value_map(exist_card[-1], CardTypeEnum.CT_THREE, 6) put_card = list(map(lambda x:[x]*3, exist_card)) put_card = np.reshape(put_card, (1, -1)).tolist()[0] return put_card, score, exist_card[-1]
def run(self): exist_card = list( map(lambda x: x[0], filter(lambda x: x[1] >= 1, enumerate(self.hand_card_status)))) if self.primary_item is not None: exist_card = list( filter(lambda x: x > self.primary_item, exist_card)) if len(exist_card) == 0: logger.debug('Can not accept the card') return None, None, None rnd = random.randint(0, len(exist_card) - 1) put_card = exist_card[rnd] score = HandCardUtils.value_map(put_card, CardTypeEnum.CT_ONE, 1) return [put_card], score, put_card
def run(self): exist_card = list(map(lambda x:x[0], filter(lambda x: x[1] == 4, enumerate(self.hand_card_status)))) if self.primary_item is not None: exist_card = list(filter(lambda x:x > self.primary_item,exist_card)) if len(exist_card) == 0: logger.debug('Can not accept the card') return None, None, None rnd = random.randint(0,len(exist_card)-1) one_card = exist_card[rnd] remain_card = self.__flat_card(self.hand_card_status, [one_card]) if len(remain_card) <= 1: logger.debug('Can not accept the card') return None, None, None other_card = sorted(random.sample(remain_card, 2)) score = HandCardUtils.value_map(one_card, CardTypeEnum.CT_FOUR_ONE, 6) put_card = [one_card]*4 put_card.extend(other_card) return put_card, score, one_card