From: Alexander Schmidt Date: Tue, 3 Nov 2020 10:41:18 +0000 (+0100) Subject: refactoring X-Git-Url: http://git.treefish.org/~alex/shutbox.git/commitdiff_plain/HEAD?ds=sidebyside refactoring --- diff --git a/src/qtable.py b/src/qtable.py index fb65008..29a3081 100755 --- a/src/qtable.py +++ b/src/qtable.py @@ -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()