您现在的位置是:首页 >其他 >Model-Free TD Control: Q-Learning网站首页其他
Model-Free TD Control: Q-Learning
简介Model-Free TD Control: Q-Learning
import time
import random
class Env():
def __init__(self, length, height):
# define the height and length of the map
self.length = length
self.height = height
# define the agent's start position
self.x = 0
self.y = 0
def render(self, frames=50):
for i in range(self.height):
if i == 0: # cliff is in the line 0
line = ['S'] + ['x']*(self.length - 2) + ['T'] # 'S':start, 'T':terminal, 'x':the cliff
else:
line = ['.'] * self.length
if self.x == i:
line[self.y] = 'o' # mark the agent's position as 'o'
print(''.join(line))
print('