def test_get_entity_position(): """ Tests that position is correctly retrieved """ env = Environment(3, 3, 0, 0) env.entity_position = (0, 1) assert env.get_entity_position() == (0, 1)
def test_entity_facing_out_false(): """ Tests that entity_facing_out returns true at each edge """ env = Environment(5, 5, 0, 0) env.entity_direction = Direction.NORTH env.entity_position = (2, 3) assert not env.entity_facing_out() env.entity_direction = Direction.EAST env.entity_position = (3, 0) assert not env.entity_facing_out() env.entity_direction = Direction.SOUTH env.entity_position = (0, 0) assert not env.entity_facing_out() env.entity_direction = Direction.WEST env.entity_position = (4, 0) assert not env.entity_facing_out()
def test_move_entity_nothing(): """ Tests that moving the entity changes its position """ env = Environment(3, 3, 0, 0) env.entity_direction = Direction.SOUTH env.entity_position = (0, 1) env.move_entity(Action.NOTHING) assert env.entity_direction == Direction.SOUTH assert env.entity_position == (0, 1)
def test_move_entity_left(): """ Tests that moving the entity changes its position """ env = Environment(3, 3, 0, 0) env.entity_direction = Direction.NORTH env.entity_position = (0, 1) env.move_entity(Action.LEFT) assert env.entity_direction == Direction.WEST assert env.entity_position == (0, 1)
def test_move_entity_forwards(): """ Tests that moving the entity changes its position """ env = Environment(3, 3, 0, 0) env.entity_direction = Direction.SOUTH env.entity_position = (0, 0) env.move_entity(Action.FORWARDS) assert env.entity_position == (0, 1) assert env.entity_direction == Direction.SOUTH env.move_entity(Action.FORWARDS) assert env.entity_position == (0, 2) assert env.entity_direction == Direction.SOUTH
def test_get_entity_angle_to_position(): """ Tests the angle function. """ env = Environment(3, 3, 0, 0) env.entity_direction = Direction.NORTH env.entity_position = (1, 1) assert env.get_entity_angle_to_position((1, 1)) == 0 assert env.get_entity_angle_to_position((2, 0)) == 0.125 assert env.get_entity_angle_to_position((1, 0)) == 0 assert env.get_entity_angle_to_position((2, 1)) == 0.25 assert env.get_entity_angle_to_position((2, 2)) == 0.375 assert env.get_entity_angle_to_position((1, 2)) == 0.5 assert env.get_entity_angle_to_position((0, 2)) == 0.625 assert env.get_entity_angle_to_position((0, 1)) == 0.75 assert env.get_entity_angle_to_position((0, 0)) == 0.875