robot_test module
from robotworld import RobotWorld from robot import Robot from coordinates import Coordinates import direction from spinbot import Spinbot from drunkbot import Drunkbot from lovebot import Lovebot from nosebot import Nosebot def main(): test_world = RobotWorld(5, 5) wall1_coordinates = Coordinates(2, 4) test_world.add_wall(wall1_coordinates) wall2_coordinates = Coordinates(1, 3) test_world.add_wall(wall2_coordinates) first_location = Coordinates(4, 3) first_body = Robot('Bart') first_brain = Spinbot(first_body) first_body.set_brain(first_brain) test_world.add_robot(first_body, first_location, direction.EAST) fifth_location = Coordinates(4, 4) fifth_body = Robot('Speedy Gonzales') fifth_brain = Nosebot(fifth_body) fifth_body.set_brain(fifth_brain) test_world.add_robot(fifth_body, fifth_location, direction.WEST) second_location = Coordinates(2, 1) second_body = Robot('Homer') second_brain = Drunkbot(second_body, 456) second_body.set_brain(second_brain) test_world.add_robot(second_body, second_location, direction.SOUTH) third_location = Coordinates(4, 0) third_body = Robot('Creepy') third_brain = Lovebot(third_body, second_body) third_body.set_brain(third_brain) test_world.add_robot(third_body, third_location, direction.NORTH) fourth_location = Coordinates(1, 1) fourth_body = Robot('Lwaxana') fourth_brain = Drunkbot(fourth_body, 3) fourth_body.set_brain(fourth_brain) test_world.add_robot(fourth_body, fourth_location, direction.WEST) sixth_location = Coordinates(0, 2) sixth_body = Robot('Tog') sixth_brain = Lovebot(sixth_body, fourth_body) sixth_body.set_brain(sixth_brain) test_world.add_robot(sixth_body, sixth_location, direction.NORTH) for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------' test_world.next_full_turn() for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------' test_world.next_full_turn() for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------' test_world.next_full_turn() for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------' test_world.next_full_turn() for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------' test_world.next_full_turn() for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------' test_world.next_full_turn() for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------' test_world.next_full_turn() for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------' if __name__ == '__main__': main()
Functions
def main(
)
def main(): test_world = RobotWorld(5, 5) wall1_coordinates = Coordinates(2, 4) test_world.add_wall(wall1_coordinates) wall2_coordinates = Coordinates(1, 3) test_world.add_wall(wall2_coordinates) first_location = Coordinates(4, 3) first_body = Robot('Bart') first_brain = Spinbot(first_body) first_body.set_brain(first_brain) test_world.add_robot(first_body, first_location, direction.EAST) fifth_location = Coordinates(4, 4) fifth_body = Robot('Speedy Gonzales') fifth_brain = Nosebot(fifth_body) fifth_body.set_brain(fifth_brain) test_world.add_robot(fifth_body, fifth_location, direction.WEST) second_location = Coordinates(2, 1) second_body = Robot('Homer') second_brain = Drunkbot(second_body, 456) second_body.set_brain(second_brain) test_world.add_robot(second_body, second_location, direction.SOUTH) third_location = Coordinates(4, 0) third_body = Robot('Creepy') third_brain = Lovebot(third_body, second_body) third_body.set_brain(third_brain) test_world.add_robot(third_body, third_location, direction.NORTH) fourth_location = Coordinates(1, 1) fourth_body = Robot('Lwaxana') fourth_brain = Drunkbot(fourth_body, 3) fourth_body.set_brain(fourth_brain) test_world.add_robot(fourth_body, fourth_location, direction.WEST) sixth_location = Coordinates(0, 2) sixth_body = Robot('Tog') sixth_brain = Lovebot(sixth_body, fourth_body) sixth_body.set_brain(sixth_brain) test_world.add_robot(sixth_body, sixth_location, direction.NORTH) for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------' test_world.next_full_turn() for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------' test_world.next_full_turn() for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------' test_world.next_full_turn() for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------' test_world.next_full_turn() for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------' test_world.next_full_turn() for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------' test_world.next_full_turn() for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------' test_world.next_full_turn() for robot in test_world.get_robots(): print robot.get_location(), robot.get_facing(), robot.is_broken(), robot.get_name() print '-----------'