I'm trying to start reinforcement learning in Window by using vscode but have some errors.
import gym
#from tqdm import tqdm
from gym.envs.registration import register
import msvcrt
class _Getch:
def __call__(self):
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(sys.stdin.fileno())
ch = sys.stdin.read(3)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
inkey = _Getch()
left = 0
down = 1
right = 2
up = 3
arrow_keys={'\x1b[A' : up,'\x1b[B' : down,'\x1b[C' : right,'\x1b[D' : left}
register(
id='FrozenLake-v3',
entry_point = 'gym.envs.toy_text : FrozenLakeEnv',
kwargs={'map_name' : '4x4', 'is_slippery':False}
)
env = gym.make("FrozenLake-v3")
env.render()
while True:
key = inkey()
if key not in arrow_keys.keys():
print("Game aborted!")
break
action = arrow_keys[key]
state, reward, done, info = env.step(action)
env.render()
print("State: ", state, "Action: ", action, "Reward: ", reward, "Info: ", info)
if done:
print("Finished with reward", reward)
break
I install gym and check gym library is in pip list.
ModuleNotFoundError: No module named 'gym.envs.toy_text '
How to solve this problem? I want to solve this problem and i can make any progress.