Skip to content
Permalink
Browse files
fix minor bugs
  • Loading branch information
James Brusey committed Jun 7, 2023
1 parent 79125e7 commit a0d11dea8b3fdaf47e6a3ccbd911a4adebb05714
Showing 1 changed file with 11 additions and 4 deletions.
@@ -9,9 +9,9 @@ GAMMA = 0.999

def first_visit_mc(policy, env, T):
V = np.zeros((N_S))
Returns = [] * N_S
Returns = [[]] * N_S

for k in range(1000):
for k in range(100):
observation, info = env.reset()

rewards = []
@@ -25,11 +25,18 @@ def first_visit_mc(policy, env, T):
break

G = 0
for j in range(i):
G = GAMMA * G + reward[i]
for j in range(i+1):
G = GAMMA * G + rewards[i]

s_t = observations[j]

if j == 0 or s_t not in observations[: j - 1]:
Returns[s_t].append(G)
V[s_t] = np.mean(Returns[s_t])
return V

def main():
env = gym.make("FrozenLake-v1", is_slippery=False)
policy = [2] * 16

print(first_visit_mc(policy, env, 16))

0 comments on commit a0d11de

Please sign in to comment.