esakilab / building-facility-simulator

1 stars 0 forks source link

Step数の途中経過を保存できるように #5

Closed shugo256 closed 3 years ago

shugo256 commented 3 years ago

3 の一部(複数xml対応はまた別でやる)

for (state, reward) in bfs.advance_steps(action, 10):
  do_something()
for (state, reward) in bfs.advance_steps(action, 10):
  do_something()

みたいにすると、二つ目のfor文は10ステップ目(0-indexed)からスタートする データセットを消費し切ったかどうかは

bfs.has_finished()

でチェック可能

shugo256 commented 3 years ago

ちなみにadvance_stepsstepsを指定しないと、今まで通り最後まで進めるgeneratorとなる

shugo256 commented 3 years ago

1stepじゃなくなった結果、actionが正しく更新されないっぽいことがわかったので、一旦draftに戻す(draftに戻すボタンがない)

shugo256 commented 3 years ago

ready for review

shugo256 commented 3 years ago

actionは↑みたいなfor文の形でも(pythonのオブジェクトは参照なので)ちゃんと更新されていたが、非直感的なので、普通に毎step引数で渡す形式に変更した

10ステップずつやるとしたら↓みたいなイメージ

while not bfs.has_finished():
  for _ in range(10):
    if bfs.has_finished():
      break
    (st, rw) = bfs.step(action)

一方でgeneratorの形式を残しつつ、次のactionを指定するためだけのメソッドを生やすという方法も考えられる

while not bfs.has_finished():
  for (st, rw) in bfs.advance_steps(10):
    bfs.set_next_action(action)

@niconico22 どっちがいいかな? 上の方が直感的だが、ステップ数が10で割り切れない時のケアを使う側でする必要があるという弱点もある(下は、advance_steps側で範囲チェックを入れられる)

niconico22 commented 3 years ago

とりあえず前者の形で実装してくれていると思うのでそれを使ってあとはAI側で調整してみます