<s> import numpy as np <EOL> import gym <EOL> from gym import spaces <EOL> class RouletteEnv ( gym . Env ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , spots = <NUM_LIT> ) : <EOL> self . n = spots + <NUM_LIT:1> <EOL> self . action_space = spaces . Discrete ( self . n ) <EOL> self . observation_space = spaces . Discrete ( <NUM_LIT:1> ) <EOL> def _step ( self , action ) : <EOL> assert ( action >= <NUM_LIT:0> and action < self . n ) <EOL> if action == self . n - <NUM_LIT:1> : <EOL> return <NUM_LIT:0> , <NUM_LIT:0> , True , { } <EOL> val = np . random . randint ( <NUM_LIT:0> , self . n - <NUM_LIT:1> ) <EOL> if val == action == <NUM_LIT:0> : <EOL> reward = self . n - <NUM_LIT> <EOL> elif val != <NUM_LIT:0> and action != <NUM_LIT:0> and val % <NUM_LIT:2> == action % <NUM_LIT:2> : <EOL> reward = <NUM_LIT:1.0> <EOL> else : <EOL> reward = - <NUM_LIT:1.0> <EOL> return <NUM_LIT:0> , reward , False , { } <EOL> def _reset ( self ) : <EOL> return <NUM_LIT:0> </s>
