]> git.treefish.org Git - shutbox.git/commitdiff
refactoring master
authorAlexander Schmidt <alex@treefish.org>
Tue, 3 Nov 2020 10:41:18 +0000 (11:41 +0100)
committerAlexander Schmidt <alex@treefish.org>
Tue, 3 Nov 2020 10:41:18 +0000 (11:41 +0100)
src/qtable.py

index fb650085955820d25d7fa0194763f9a384e79807..29a3081235bfa8675657cdc6d0b866158ee88f7a 100755 (executable)
@@ -40,7 +40,6 @@ def select_option(opts, qs):
         decision_pt += qs[ opt_qid_pair[1] ]
         if ran_pt <= decision_pt:
             return (opt_qid_pair[0], opt_qid_pair[1])
-    return (None, None)
 
 Q = np.ones([states_dim, actions_dim])
 
@@ -51,8 +50,9 @@ for i in range(num_episodes):
     g.dice()
     state_qid = find_state_qid(g.get_shutable(), g.get_diced())
     while not g.is_over():
-        opt, opt_qid = select_option( g.get_options(), Q[state_qid, :] )
-        if opt:
+        options = g.get_options()
+        if len(options) > 0:
+            opt, opt_qid = select_option( options, Q[state_qid, :] )
             old_score = g.get_score()
             g.shut(opt)
             g.dice()