ffzeroHua commited on
Commit
1a1396f
·
verified ·
1 Parent(s): 2174b85

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -120,6 +120,7 @@ class DAggerEncoder:
120
  })
121
  self.outputs.append(label)
122
  worker_status["records_extracted"] += 1
 
123
 
124
  if len(self.inputs) >= self.chunk_size:
125
  self.save_and_upload()
@@ -205,6 +206,19 @@ def play_dagger_game(encoder: DAggerEncoder, student_bots: dict, teacher_bots: d
205
  if student_final_action is None:
206
  student_final_action = env_obs.select_action_from_mjai('{"type": "none"}')
207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  actions_to_env[pid] = student_final_action
209
 
210
  # 环境步进
 
120
  })
121
  self.outputs.append(label)
122
  worker_status["records_extracted"] += 1
123
+ print(worker_status["records_extracted"])
124
 
125
  if len(self.inputs) >= self.chunk_size:
126
  self.save_and_upload()
 
206
  if student_final_action is None:
207
  student_final_action = env_obs.select_action_from_mjai('{"type": "none"}')
208
 
209
+ # 兜底 2: 如果不能 Pass(比如自己摸牌后必须切牌),强制选取合法动作
210
+ if student_final_action is None:
211
+ try:
212
+ # 获取当前环境允许的所有合法动作
213
+ legal_actions = env_obs.legal_actions
214
+ if callable(legal_actions):
215
+ legal_actions = legal_actions()
216
+
217
+ if legal_actions and len(legal_actions) > 0:
218
+ student_final_action = legal_actions[0] # 强行拿第一个合法动作兜底
219
+ except Exception as e:
220
+ pass
221
+
222
  actions_to_env[pid] = student_final_action
223
 
224
  # 环境步进