提速降费
This commit is contained in:
parent
66b432f52c
commit
84775d52e6
|
@ -26,6 +26,16 @@ NumOnes2Array = {0: np.array([0, 0, 0, 0, 0, 0, 0, 0]),
|
||||||
7: np.array([1, 1, 1, 1, 1, 1, 1, 0]),
|
7: np.array([1, 1, 1, 1, 1, 1, 1, 0]),
|
||||||
8: np.array([1, 1, 1, 1, 1, 1, 1, 1])}
|
8: np.array([1, 1, 1, 1, 1, 1, 1, 1])}
|
||||||
|
|
||||||
|
NumOnesJoker2Array = {0: np.array([0, 0, 0, 0, 0, 0, 0, 0]),
|
||||||
|
1: np.array([1, 0, 0, 0, 0, 0, 0, 0]),
|
||||||
|
3: np.array([1, 1, 0, 0, 0, 0, 0, 0]),
|
||||||
|
4: np.array([0, 0, 1, 0, 0, 0, 0, 0]),
|
||||||
|
5: np.array([1, 0, 1, 0, 0, 0, 0, 0]),
|
||||||
|
7: np.array([1, 1, 1, 0, 0, 0, 0, 0]),
|
||||||
|
12: np.array([0, 0, 1, 1, 0, 0, 0, 0]),
|
||||||
|
13: np.array([1, 0, 1, 1, 0, 0, 0, 0]),
|
||||||
|
15: np.array([1, 1, 1, 1, 0, 0, 0, 0])}
|
||||||
|
|
||||||
shandle = logging.StreamHandler()
|
shandle = logging.StreamHandler()
|
||||||
shandle.setFormatter(
|
shandle.setFormatter(
|
||||||
logging.Formatter(
|
logging.Formatter(
|
||||||
|
@ -195,20 +205,23 @@ def _cards2tensor(list_cards):
|
||||||
if len(list_cards) == 0:
|
if len(list_cards) == 0:
|
||||||
return torch.zeros(108, dtype=torch.int8)
|
return torch.zeros(108, dtype=torch.int8)
|
||||||
|
|
||||||
matrix = np.zeros([8, 13], dtype=np.int8)
|
matrix = np.zeros([8, 14], dtype=np.int8)
|
||||||
jokers = np.zeros(4, dtype=np.int8)
|
|
||||||
counter = Counter(list_cards)
|
counter = Counter(list_cards)
|
||||||
|
joker_cnt = 0
|
||||||
for card, num_times in counter.items():
|
for card, num_times in counter.items():
|
||||||
if card < 20:
|
if card < 20:
|
||||||
matrix[:, Card2Column[card]] = NumOnes2Array[num_times]
|
matrix[:, Card2Column[card]] = NumOnes2Array[num_times]
|
||||||
elif card == 20:
|
elif card == 20:
|
||||||
jokers[0] = 1
|
|
||||||
if num_times == 2:
|
if num_times == 2:
|
||||||
jokers[1] = 1
|
joker_cnt |= 0b11
|
||||||
|
else:
|
||||||
|
joker_cnt |= 0b01
|
||||||
elif card == 30:
|
elif card == 30:
|
||||||
jokers[2] = 1
|
|
||||||
if num_times == 2:
|
if num_times == 2:
|
||||||
jokers[3] = 1
|
joker_cnt |= 0b1100
|
||||||
matrix = np.concatenate((matrix.flatten('F'), jokers))
|
else:
|
||||||
|
joker_cnt |= 0b0100
|
||||||
|
matrix[:, 13] = NumOnesJoker2Array[joker_cnt]
|
||||||
|
matrix = matrix.flatten('F')[:-4]
|
||||||
matrix = torch.from_numpy(matrix)
|
matrix = torch.from_numpy(matrix)
|
||||||
return matrix
|
return matrix
|
||||||
|
|
|
@ -20,6 +20,16 @@ NumOnes2Array = {0: np.array([0, 0, 0, 0, 0, 0, 0, 0]),
|
||||||
7: np.array([1, 1, 1, 1, 1, 1, 1, 0]),
|
7: np.array([1, 1, 1, 1, 1, 1, 1, 0]),
|
||||||
8: np.array([1, 1, 1, 1, 1, 1, 1, 1])}
|
8: np.array([1, 1, 1, 1, 1, 1, 1, 1])}
|
||||||
|
|
||||||
|
NumOnesJoker2Array = {0: np.array([0, 0, 0, 0, 0, 0, 0, 0]),
|
||||||
|
1: np.array([1, 0, 0, 0, 0, 0, 0, 0]),
|
||||||
|
3: np.array([1, 1, 0, 0, 0, 0, 0, 0]),
|
||||||
|
4: np.array([0, 0, 1, 0, 0, 0, 0, 0]),
|
||||||
|
5: np.array([1, 0, 1, 0, 0, 0, 0, 0]),
|
||||||
|
7: np.array([1, 1, 1, 0, 0, 0, 0, 0]),
|
||||||
|
12: np.array([0, 0, 1, 1, 0, 0, 0, 0]),
|
||||||
|
13: np.array([1, 0, 1, 1, 0, 0, 0, 0]),
|
||||||
|
15: np.array([1, 1, 1, 1, 0, 0, 0, 0])}
|
||||||
|
|
||||||
|
|
||||||
deck = []
|
deck = []
|
||||||
for i in range(3, 15):
|
for i in range(3, 15):
|
||||||
|
@ -296,21 +306,24 @@ def _cards2array(list_cards):
|
||||||
if len(list_cards) == 0:
|
if len(list_cards) == 0:
|
||||||
return np.zeros(108, dtype=np.int8)
|
return np.zeros(108, dtype=np.int8)
|
||||||
|
|
||||||
matrix = np.zeros([8, 13], dtype=np.int8)
|
matrix = np.zeros([8, 14], dtype=np.int8)
|
||||||
jokers = np.zeros(4, dtype=np.int8)
|
|
||||||
counter = Counter(list_cards)
|
counter = Counter(list_cards)
|
||||||
|
joker_cnt = 0
|
||||||
for card, num_times in counter.items():
|
for card, num_times in counter.items():
|
||||||
if card < 20:
|
if card < 20:
|
||||||
matrix[:, Card2Column[card]] = NumOnes2Array[num_times]
|
matrix[:, Card2Column[card]] = NumOnes2Array[num_times]
|
||||||
elif card == 20:
|
elif card == 20:
|
||||||
jokers[0] = 1
|
|
||||||
if num_times == 2:
|
if num_times == 2:
|
||||||
jokers[1] = 1
|
joker_cnt |= 0b11
|
||||||
|
else:
|
||||||
|
joker_cnt |= 0b01
|
||||||
elif card == 30:
|
elif card == 30:
|
||||||
jokers[2] = 1
|
|
||||||
if num_times == 2:
|
if num_times == 2:
|
||||||
jokers[3] = 1
|
joker_cnt |= 0b1100
|
||||||
return np.concatenate((matrix.flatten('F'), jokers))
|
else:
|
||||||
|
joker_cnt |= 0b0100
|
||||||
|
matrix[:, 13] = NumOnesJoker2Array[joker_cnt]
|
||||||
|
return matrix.flatten('F')[:-4]
|
||||||
|
|
||||||
|
|
||||||
# def _action_seq_list2array(action_seq_list):
|
# def _action_seq_list2array(action_seq_list):
|
||||||
|
|
Loading…
Reference in New Issue