Beispiel #1
0
        if is_winner(board, self.symbol):
            reward = 1
        elif is_winner(board, opponent[self.symbol]):
            reward = -1
        else:
            reward = 0
        return reward


random.seed(1)

my_agent = MyAgent(alpha=0.2, epsilon=0.5)
my_agent.learning = False
random_agent = RandomAgent()

train_and_plot(agent=my_agent,
               validation_agent=random_agent,
               iterations=50,
               trainings=100,
               validations=1000)

train(my_agent, 3000)

validation_agent = RandomAgent()

validation_result = validate(agent_x=my_agent,
                             agent_o=validation_agent,
                             iterations=100)

plot_validation(validation_result)
Beispiel #2
0
 def validate(self):
     self.learning = False
     validation_agent = RandomAgent()
     validation_result = validate(agent_x=self, agent_o=validation_agent, iterations=1000)
     plot_validation(validation_result)