# Path: simpleai/environments.py
# class RLEnvironment(Environment):
# 
#     def __init__(self, agents, initial_state):
#         super(RLEnvironment, self).__init__(agents, initial_state)
# 
#     def step(self, viewer=None):
#         super(RLEnvironment, self).step(viewer)
#         for agent in self.agents:
#             agent.set_reward(self.reward(self.state, agent), self.is_completed(self.state))
# 
#     def reward(self, state, agent):
#         raise NotImplementedError()


from simpleai.machine_learning.reinforcement_learning import TDQLearner, \
                                                             make_exponential_temperature, \
                                                             PerformanceCounter, \
                                                             RLProblem
from simpleai.environments import RLEnvironment
    from Tkinter import *
    from tkinter import *
import threading
        cy = 100 * (y - 1) + 50
        r = 30
        return (cx - r, cy - r, cx + r, cy + r)

    def step(self):
        if self.environment.is_completed(self.environment.state):
            self.timer.cancel()
        else:
            self.environment.step(viewer=self)

    def start(self):
        self.timer = PerpetualTimer(0.5, self.step)
        self.timer.start()
        self.environment.state = self.environment.initial_state

    def stop(self):
        self.timer.cancel()

    def event(self, state1, action, state2, agent):
        print('action: %s state: %s' % (action, str(state2)))
        x, y, have_gold = state2
        if have_gold and self.gold:
            self.w.delete(self.gold)
            self.w.itemconfig(self.agent, outline="yellow", width=6.0)
        self.w.coords(self.agent, self._coord(x, y))


class WumpusEnvironment(RLEnvironment):

    def __init__(self, agent):

# Path: simpleai/environments.py
# class RLEnvironment(Environment):
# 
#     def __init__(self, agents, initial_state):
#         super(RLEnvironment, self).__init__(agents, initial_state)
# 
#     def step(self, viewer=None):
#         super(RLEnvironment, self).step(viewer)
#         for agent in self.agents:
#             agent.set_reward(self.reward(self.state, agent), self.is_completed(self.state))
# 
#     def reward(self, state, agent):
#         raise NotImplementedError()


# Path: samples/machine_learning/wumpus.py
from simpleai.machine_learning.reinforcement_learning import TDQLearner, \
                                                             make_exponential_temperature, \
                                                             PerformanceCounter, \
                                                             RLProblem
from simpleai.environments import RLEnvironment
    from Tkinter import *
    from tkinter import *
import threading

        cy = 100 * (y - 1) + 50
        r = 30
        return (cx - r, cy - r, cx + r, cy + r)

    def step(self):
        if self.environment.is_completed(self.environment.state):
            self.timer.cancel()
        else:
            self.environment.step(viewer=self)

    def start(self):
        self.timer = PerpetualTimer(0.5, self.step)
        self.timer.start()
        self.environment.state = self.environment.initial_state

    def stop(self):
        self.timer.cancel()

    def event(self, state1, action, state2, agent):
        print('action: %s state: %s' % (action, str(state2)))
        x, y, have_gold = state2
        if have_gold and self.gold:
            self.w.delete(self.gold)
            self.w.itemconfig(self.agent, outline="yellow", width=6.0)
        self.w.coords(self.agent, self._coord(x, y))


class WumpusEnvironment(RLEnvironment):

    def __init__(self, agent):

        super(RLEnvironment, self).__init__([agent], (1, 1, False))