def test_jump(self):
     search = self.search
     state = parse_state("../../tests/jump.json")
     print(state)
     game = Game('red', state)
     best_action = search.search(game, state)
     self.assertEqual(((0, 0), (2, -2), 'JUMP'), best_action)
 def test_eat_green(self):
     search = self.search
     state = parse_state("../../tests/eat_green.json")
     print(state)
     game = Game('red', state)
     best_action = search.search(game, state)
     self.assertTupleEqual(((0, 0), (2, -2), 'JUMP'), best_action)
 def test_initial(self):
     search = self.search
     state = parse_state("../../tests/red_initial_state.json")
     print(state)
     game = Game('red', state)
     best_action = search.search(game, state)
     print(best_action)
 def test_must_exit(self):
     search = self.search
     state = parse_state("../../tests/must_exit_0.json")
     print(state)
     game = Game('red', state)
     best_action = search.search(game, state)
     self.assertEqual(best_action[-1], 'EXIT')
 def test_busy(self):
     search = self.search
     state = parse_state("../../tests/busy.json")
     print(state)
     game = Game('red', state)
     best_action = search.search(game, state)
     print(best_action)
 def test_dominates(self):
     search = self.search
     state = parse_state("../../tests/red_dominates.json")
     print(state)
     game = Game('blue', state)
     best_action = search.search(game, state)
     print(best_action)
 def test_pass(self):
     search = self.search
     state = parse_state("../../tests/pass.json")
     print(state)
     game = Game('blue', state)
     best_action = search.search(game, state)
     self.assertTupleEqual((None, None, 'PASS'), best_action)
 def test_move_not_jump(self):
     search = self.search
     state = parse_state("../../tests/move_not_jump.json")
     print(state)
     game = Game('red', state)
     best_action = search.search(game, state)
     print(best_action)
    def test_avoid_eaten(self):
        search = self.search
        state = parse_state("../../tests/avoid_eaten.json")
        print(state)

        game = Game('red', state)
        best_action = search.search(game, state)
        self.assertTupleEqual(((-2, -1), (-3, 0), 'MOVE'), best_action)
 def test_inch_forward(self):
     search = self.search
     state = parse_state("../../tests/inch_forward.json")
     print(state)
     game = Game('red', state)
     best_action = search.search(game, state)
     print(best_action)
     self.assertEqual(((-3, 2), (-2, 2), 'MOVE'), best_action)
 def test_move(self):
     search = self.search
     state = parse_state("../../tests/move.json")
     print(state)
     game = Game('red', state)
     best_action = search.search(game, state)
     print(best_action)
     self.assertEqual(((1, 0), 'MOVE'), best_action[1:])
 def test_exit(self):
     search = self.search
     state = parse_state("../../tests/please_exit.json")
     print(state)
     game = Game('red', state)
     best_action = search.search(game, state)
     print(best_action)
     self.assertEqual('EXIT', best_action[-1])
node_type = SimpleRLNode2

policy = "greedy"
# policy = "choice"

# debug = 0.001
# debug = 0.1
debug = 0

# explore = 0
# explore = 0.1
# explore = 0.2
# explore = 0.5
explore = 1

# theta = 0.05
# theta = 0.01
theta = 0.005
# theta = 0.001
# theta = 0.0005

gamma = 1
# gamma = 0.99

initial_state = State(Player.start_config, "red")
game = Game("red", initial_state)
agent.td_train(game, initial_state, debug=debug,
               node_type=node_type, policy=policy,
               explore=explore, theta=theta, gamma=gamma)