from __future__ import print_function
import unittest
from robotgame.logic.rollingstone import *
from robotgame.logic.direction import *


class RollingStoneTest(unittest.TestCase):
    def test_playfield(self):
        playfield_example_succeed = {
            (0, 0): Down,
            (0, 2): Right,
            (1, 3): Blocker,
            (2, 1): Blocker,
            (2, 2): Down,
            (2, 3): Right,
            }
        self.assertTrue(reaches_goal(playfield_example_succeed,
                                     4, 4, 100, (0, 0), (3, 3)))

        playfield_example_succeed[(1, 2)] = Blocker
        self.assertFalse(reaches_goal(playfield_example_succeed,
                                      4, 4, 100, (0, 0), (3, 3)))

    def test_playfield_generation(self):
        print()
        playfield, steps = generate_simple_playfield(10, 10, 100, 100)
        print_playfield(playfield, 10, 10, True)
        self.assertTrue(
            reaches_goal(playfield, 10, 10, steps, (0, 0), (9, 9)))

        print()
        playfield, steps = generate_simple_playfield(10, 10, 7, 20)
        print_playfield(playfield, 10, 10, True)
        self.assertTrue(
            reaches_goal(playfield, 10, 10, steps, (0, 0), (9, 9)))

        print()
        playfield, steps = generate_simple_playfield(10, 15, 4, 150)
        print_playfield(playfield, 10, 15, False)
        self.assertTrue(
            reaches_goal(playfield, 10, 15, steps, (0, 0), (9, 14)))
        
if __name__ == '__main__':
    unittest.main()