Skip to content

Commit 7594728

Browse files
committed
修复双ai时ai手牌更新
1 parent b4cbb3b commit 7594728

3 files changed

Lines changed: 14 additions & 50 deletions

File tree

douzero/env/game.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,16 +295,15 @@ def get_acting_player_position(self):
295295

296296
return self.acting_player_position
297297

298-
# 更新手牌
299298
def update_acting_player_hand_cards(self, action):
300299
if action != []:
301-
# 更新玩家手牌,删除对应的牌
302-
if self.acting_player_position == list(self.players.keys())[0]:
300+
# 更新AI手牌,删除对应的牌
301+
if self.acting_player_position in list(self.players.keys()):
303302
for card in action:
304303
self.info_sets[
305304
self.acting_player_position
306305
].player_hand_cards.remove(card)
307-
# 更新另外两个玩家手牌,删除相同数量的牌
306+
# 更新玩家手牌,删除相同数量的牌
308307
else:
309308
del self.info_sets[self.acting_player_position].player_hand_cards[
310309
0 : len(action)

douzero/evaluation/simulation.py

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,17 @@ def init(data):
180180

181181
res_data = {
182182
"pid": pid,
183-
"cards": cards,
184-
"confidence": confidence,
185183
"game_over": res_game_over,
184+
"play": [
185+
{
186+
"cards": cards,
187+
"confidence": confidence,
188+
},
189+
{
190+
"cards": None,
191+
"confidence": None,
192+
},
193+
],
186194
}
187195
res_action = "play"
188196
else:
@@ -223,49 +231,6 @@ def init(data):
223231
player_position_code
224232
]
225233

226-
"""# 玩家手牌
227-
user_hand_cards_real = data["player_data"][0]["hand_cards"]
228-
ai0_use_hand_cards_env = [
229-
RealCard2EnvCard[c] for c in list(user_hand_cards_real)
230-
]
231-
user_hand_cards_real = data["player_data"][1]["hand_cards"]
232-
ai1_use_hand_cards_env = [
233-
RealCard2EnvCard[c] for c in list(user_hand_cards_real)
234-
]
235-
# 角色位号
236-
ai0_user_position_code = data["player_data"][0]["position_code"]
237-
ai0_user_position = ["landlord_up", "landlord", "landlord_down"][
238-
ai0_user_position_code
239-
]
240-
ai1_user_position_code = data["player_data"][1]["position_code"]
241-
ai1_user_position = ["landlord_up", "landlord", "landlord_down"][
242-
ai1_user_position_code
243-
]
244-
player_position_code = 3 - ai0_user_position_code - ai1_user_position_code
245-
player_position = ["landlord_up", "landlord", "landlord_down"][
246-
player_position_code
247-
]
248-
# 三张底牌
249-
three_landlord_cards_real = data["three_landlord_cards"]
250-
three_landlord_cards_env = [
251-
RealCard2EnvCard[c] for c in list(three_landlord_cards_real)
252-
]
253-
# AI模型
254-
ai0_model_name = data["player_data"][0]["model"]
255-
ai0_model_list = check_model(ai0_model_name)
256-
if ai0_model_list == None:
257-
error = Exception(f"找不到此模型:{ai0_model_name}")
258-
raise error
259-
else:
260-
ai0_model = ai0_model_list[ai0_user_position_code]
261-
ai1_model_name = data["player_data"][1]["model"]
262-
ai1_model_list = check_model(ai1_model_name)
263-
if ai1_model_list == None:
264-
error = Exception(f"找不到此模型:{ai1_model_name}")
265-
raise error
266-
else:
267-
ai1_model = ai1_model_list[ai1_user_position_code]"""
268-
269234
# 减去两位AI的牌,剩下的牌就是玩家的手牌
270235
other_hand_cards = []
271236
for i in set(AllEnvCard):

start.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
port = 24813
22
###############################################################################################
3-
version = 0.8
3+
version = 1.0
44
###############################################################################################
55
import os
66
import time

0 commit comments

Comments
 (0)