質問内容
強化学習用にOpenAI Gymのカスタム環境を自作で作ろうとしているのですが
変数の数が多いとエラーメッセージが出力されます。しかし変数の数はあっています。
どうしたらよいかわかりません。もしよろしければ教えていただきたいです。
よろしくお願いいたします。
プログラムが長いので該当すると思われる部分だけピックアップして掲載いたします。
ご了承ください。
発生している問題・エラーメッセージ
エラーメッセージ next_observation, reward, done, _ = env.step(action,i) TypeError: step() takes 2 positional arguments but 3 were given #iの部分をなくした場合 observation, reward, done, info = env.step(action) TypeError: step() missing 1 required positional argument: 'drone_number'
該当のソースコード
Python
1ソースコード 2def step(self,action,drone_number): 3 self._updateAndStoreKinematicInformation(drone_number) 4 #### Step the simulation using the desired physics update ## 5 #for i in range (1): 6 if self.PHYSICS == Physics.PYB: 7 self._physics(clipped_action,drone_number) 8 elif self.PHYSICS == Physics.DYN: 9 self._dynamics(clipped_action[i, :], i) 10 elif self.PHYSICS == Physics.PYB_GND: 11 self._physics(clipped_action[i, :], i) 12 self._groundEffect(clipped_action[i, :], i) 13 elif self.PHYSICS == Physics.PYB_DRAG: 14 self._physics(clipped_action[i, :], i) 15 self._drag(self.last_clipped_action[i, :], i) 16 elif self.PHYSICS == Physics.PYB_DW: 17 self._physics(clipped_action[i, :], i) 18 self._downwash(i) 19 elif self.PHYSICS == Physics.PYB_GND_DRAG_DW: 20 self._physics(clipped_action[i, :], i) 21 self._groundEffect(clipped_action[i, :], i) 22 self._drag(self.last_clipped_action[i, :], i) 23 self._downwash(i) 24 #### PyBullet computes the new state, unless Physics.DYN ### 25 if self.PHYSICS != Physics.DYN: 26 p.stepSimulation(physicsClientId=self.CLIENT) 27 #### Save the last applied action (e.g. to compute drag) ### 28 self.last_clipped_action = clipped_action 29 #### Update and store the drones kinematic information ##### 30 self._updateAndStoreKinematicInformation() 31 #### Prepare the return values ############################# 32 rgb,kin = self._computeObs() 33 Observation={'RGB':rgb,'KIN':kin} 34 reward = self._computeReward() 35 done = self._computeDone() 36 info = self._computeInfo() 37 return Observation, reward, done, info 38この下は上の関数を持っているクラスを継承している 39 40for i in range(NUM_DRONES): 41 observation={'RGB':observation['RGB'][i],'KIN':observation['KIN'][i]} 42 action = Agents[i].get_action(observation) 43 next_observation, reward, done, _ = env.step(action,i) 44 next_observation={'RGB':next_observation['RGB'][i],'KIN':next_observation['KIN'][i]} 45 total_reward += reward 46 Agents[i].add_memory(observation, action, next_observation, reward, done) 47 48 Agents[i].train() 49 50 observation = next_observation
試したこと
変数の数を変える。スタックオーバーフローなどで同様の問題が解決されているか確認
ここに問題に対して試したことを記載してください。

回答1件
あなたの回答
tips
プレビュー