MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / update

Method update

rl/tic_tac_toe.py:117–130  ·  view source on GitHub ↗
(self, env)

Source from the content-addressed store, hash-verified

115 self.state_history.append(s)
116
117 def update(self, env):
118 # we want to BACKTRACK over the states, so that:
119 # V(prev_state) = V(prev_state) + alpha*(V(next_state) - V(prev_state))
120 # where V(next_state) = reward if it's the most current state
121 #
122 # NOTE: we ONLY do this at the end of an episode
123 # not so for all the algorithms we will study
124 reward = env.reward(self.sym)
125 target = reward
126 for prev in reversed(self.state_history):
127 value = self.V[prev] + self.alpha*(target - self.V[prev])
128 self.V[prev] = value
129 target = value
130 self.reset_history()
131
132
133# this class represents a tic-tac-toe game

Callers 1

play_gameFunction · 0.45

Calls 2

reset_historyMethod · 0.95
rewardMethod · 0.45

Tested by

no test coverage detected