예제 #1
0
def task():
    #Commands to control the "world"
    #Open a particular world file
    world.readWorld("beeperWorld.kwld")
    #Set the size of the visible world
    world.setSize(10, 10)
    #Set the speed of the robot
    world.setDelay(30)

    sb15 = UrRobot(5, 6, North, 1, fill='green', outline='blue')

    def turn(a):
        for i in range(a):
            sb15.turnLeft()

    def pickAndTurn(a):
        for i in range(a):
            sb15.pickBeeper()
            sb15.turnLeft()
            sb15.move()
            turn(3)
            sb15.move()

    #Write the code to make your robot pick up all the beepers.
    sb15.turnLeft()
    sb15.move()
    pickAndTurn(4)
    sb15.pickBeeper()
    time.sleep(3)
예제 #2
0
def task():
        def turnSB15(a):
                for i in range(a):
                        sb15.turnLeft()
        def turnKarel(a):
                for i in range(a):
                        karel.turnLeft()
#       Commands to control the "world"
        world.readWorld("stepsWorld.kwld")    # open a particular world file
        world.setSize(10,10)               # set the size of the visible world
        #^^ should be 10
        world.setDelay(90)                # set simulation speed. 0-fastest, 100-slowest

        karel = UrRobot(2,3,East, 1,fill="blue")
        sb15 = UrRobot(1,6,North, 10, fill="green")
        sb15.move()
        karel.turnLeft()
        turnSB15(1)
        sb15.move()
        turnSB15(3)
        sb15.move()
        turnSB15(1)
        sb15.move()
        turnSB15(1)
        turnKarel(1)
        karel.move()
        turnKarel(1)
        karel.move()
        turnKarel(2)
        turnSB15(2)
예제 #3
0
def task():
#       Commands to control the "world"
        world.readWorld("steps2.kwld")    # open a particular world file
        world.setSize(10,10)               # set the size of the visible world
        world.setDelay(50)                # set simulation speed. 0-fastest, 100-slowest

        mrP = Climber(1,1,North, 1)     #Creating an UrRobot called mrP
예제 #4
0
 def setUp(self):
     world.setSize(10, 10)
     world.reset()
     world.setDelay(0)
     self.karel = UrRobot(5, 5, North, 0)
     world.setVisible(
         0
     )  #Doesn't work. It is reset visible whenever Robota is loaded again.
예제 #5
0
def task():
        #Commands to control the "world"
        #Opens a particular world file
        world.setSize(10,10)
        #Sets the size of the visible world
        world.setDelay(30)
        #set simulation speed. 0-fastest, 100-slowest
        sb15 = Dancer(3,3,North,1,fill="green", outline="blue")
        sb2 = Dancer(3,6,North,1,fill="blue", outline="green")
        #Write the code to test the methods of Dancer Class with different robots
        sb2.dance(1)
        sb15.partnerDance(1)
예제 #6
0
def task():
        #Commands to control the "world"
        world.readWorld("steps2.kwld")
        #Opens a particular world file
        world.setSize(10,10)
        #Sets the size of the visible world
        world.setDelay(30)
        #set simulation speed. 0-fastest, 100-slowest

        sb15 = Climber(1, 1, North, 1, fill="green", outline="blue")        
        #Write the code to make your robot climb the steps and get to the other side
        sb15.climbStep(5)
        sb15.turnOff()
예제 #7
0
def task():
    #       Commands to control the "world"
    world.readWorld("steps2.kwld")  # open a particular world file
    world.setSize(10, 10)  # set the size of the visible world
    world.setDelay(50)  # set simulation speed. 0-fastest, 100-slowest

    robot1 = Turner(
        1, 1, West,
        0)  #Note: this will cause an error until you import the class
    robot2 = Turner(2, 2, South, 0, "pink")
    robot3 = Turner(4, 3, North, 0, "red")
    robot4 = Turner(5, 4, North, 0, "blue")
    robot5 = Turner(6, 7, North, 0, "black")
예제 #8
0
def task():
    #       Commands to control the "world"

    # set the size of the visible world
    world.setSize(9)
    # set simulation speed. 0-fastest, 100-slowest
    world.setDelay(0.001)

    #TO DO: Create a PinSetter Robot, Street 1, Avenue 5, facing North, 10 beepers
    ps = PinSetter(1, 5, North, 17, fill='green', outline='blue')
    hv = Harvester(1, 5, North, 0, fill='blue', outline='green')
    #Wirte the instructions for your robot to set the pins:
    ps.setPins()
    hv.colPins()
예제 #9
0
def task():
        #Commands to control the "world"
        world.readWorld("danceWorld.kwld")
        #Set the size of the visible world
        world.setSize(10,10)
        #Set simulation speed. 0-fastest, 100-slowest
        world.setDelay(20)
        #Start a Dancer at Street 7, Avenue 3, facing North, with 0 beepers:
        dancer1 = Dancer(7,3,North,0)
        #Write the code for the dancer to perform the first dance
        dancer1.danceSteps1()
        #Start 2nd Dancer at Street 7, Avenue 7, facing North, with 0 beepers:
        dancer2 = Dancer(7,7,North,0)
        #Write the code for the second dancer to perform the second dance
        dancer2.danceSteps2()
예제 #10
0
def task():
    #       Commands to control the "world"
    world.readWorld("maze2.kwld")  # open a particular world file
    world.setSize(10, 10)  # set the size of the visible world
    world.setDelay(50)  # set simulation speed. 0-fastest, 100-slowest

    #create a Robot sprite (give it your name) and start it on
    # Street 3, Avenue 1
    sb15 = Robot(3, 1, East, 0, fill='blue', outline='green')

    #Write the code to make your robot find it's way out of the maze and end up
    #on Street 8, Avenue 5 and pick up the beeper that's there
    while not sb15.anyBeepersInBeeperBag():
        if sb15.frontIsClear():
            sb15.move()
        else:
            sb15.turnLeft()
            if not sb15.frontIsClear():
                sb15.turnLeft()
                sb15.turnLeft()
        if sb15.nextToABeeper():
            sb15.pickBeeper()
예제 #11
0
def task():
    #Commands to control the "world"
    size = int(54)
    world.setSize(size, size)  # set the size of the visible world
    world.setDelay(0)  # set simulation speed. 0-fastest, 100-slowest

    #Write the code to test the methods of Dancer Class with different robots
    sb2 = Writer(1, 1, East, infinity)
    #For newLine(a), a = the number of letters in the line before it.
    sb2.s()
    sb2.h()
    sb2.o()
    sb2.e()
    sb2.m()
    sb2.a()
    sb2.k()
    sb2.e()
    sb2.r()
    sb2.newLine(9)
    sb2.t()
    sb2.o()
    sb2.m()
    sb2.m()
    sb2.y()
예제 #12
0
        
    def cancel(self, event = None):
        Dialog.cancel(self, event)
        exit()

    def forgetBindings(self):        
        self._canvas.unbind('<Button-1>')
        self._canvas.unbind('<Button-2>')
        self._canvas.unbind('<Button-3>')
        self._canvas.config(cursor = '') # standard cursor
        self.toolLabel.grid_forget()
        self.toolLabel = Label(self.master, text = "current tool")
        self.toolLabel.grid(row = 2, column = 0, columnspan = 2) #, sticky = N+E+W+S)
    
    def clear(self):
        self.forgetBindings()
        self.world.reset()

    def buttonbox(self):
        pass
            
 
def task():
    world._showBuilder()
    
if __name__ == '__main__' :
    from karel.robota import world
    world.setSize(10, 10)
    world.getWindow().run(task)
    
예제 #13
0
def task():  # this is just a sample of what you can do
    world.setSize(10, 10)
    control = RemoteControl("karel", 1, 1, East, infinity, 'blue')
    control = RemoteControl("carol", 1, 2, East, 0)