데블스캠프2005/RUR-PLE/Harvest/Refactoring (rev. 1.6)
def move_and_pick():
move()
pick_beeper()
repeat(move_and_pick,6)
turn_left()
repeat(move_and_pick,5)
turn_left()
repeat(move_and_pick,5)
turn_left()
repeat(move_and_pick,4)
turn_left()
repeat(move_and_pick,4)
turn_left()
repeat(move_and_pick,3)
turn_left()
repeat(move_and_pick,3)
turn_left()
repeat(move_and_pick,2)
turn_left()
repeat(move_and_pick,2)
turn_left()
repeat(move_and_pick,1)
turn_left()
repeat(move_and_pick,1)
turn_off()
def turn_right():
repeat(turn_left, 3)
def pickLineBeeper():
for i in range(5):
pick_beeper()
move()
pick_beeper()
def turnLeftAndUp():
turn_left()
move()
turn_left()
def turnRightAndUp():
turn_right()
move()
turn_right()
#start
move()
pickLineBeeper()
turnLeftAndUp()
pickLineBeeper()
turnRightAndUp()
pickLineBeeper()
turnLeftAndUp()
pickLineBeeper()
turnRightAndUp()
pickLineBeeper()
turnLeftAndUp()
pickLineBeeper()
turn_off()
def turn_right():
repeat(turn_left,3)
move()
def harvest():
for i in range(5):
pick_beeper()
move()
pick_beeper()
turn_left()
i=0
move()
turn_left()
for i in range(5):
pick_beeper()
move()
pick_beeper()
turn_right()
i=0
move()
turn_right()
repeat(harvest,3)
turn_off()
def pickup():
move()
pick_beeper()
def turn_right():
repeat(turn_left, 3)
def goright():
repeat(pickup, 5)
turn_left()
def goleft():
repeat(pickup, 5)
turn_right()
def goup_right():
move()
pick_beeper()
turn_left()
def goup_left():
move()
pick_beeper()
turn_right()
move()
pick_beeper()
goright()
goup_right()
goleft()
goup_left()
goright()
goup_right()
goleft()
goup_left()
goright()
goup_right()
goleft()
turn_off()
def turn_right():
turn_left()
turn_left()
turn_left()
def right():
repeat(eat,5)
turn_left()
move()
pick_beeper()
turn_left()
def left():
repeat(eat,5)
turn_right()
move()
pick_beeper()
turn_right()
def eat():
move()
pick_beeper()
move()
pick_beeper()
right()
left()
right()
left()
right()
repeat(eat,5)
turn_off()
~cpp
def turn_right():
repeat(turn_left,3)
def go_pick():
move()
pick_beeper()
def go_go()
turn_right()
move()
pick_beeper()
turn_right()
repeat(go_pick,5)
turn_left()
move()
pick_beeper()
turn_left()
repeat(go_pick,5)
repeat(go_pick,6)
turn_left()
move()
pick_beeper()
turn_left()
repeat(go_pick,5)
go_go()
go_go()
turn_off()
~cpp
def turn_right():
repeat(turn_left, 3)
def pick_1():
move()
pick_beeper()
def pick_5():
repeat(pick_1,5)
def right_pick():
pick_5()
turn_right()
pick_1()
turn_right()
def left_pick():
pick_5()
turn_left()
pick_1()
turn_left()
pick_1()
turn_left()
right_pick()
left_pick()
right_pick()
left_pick()
right_pick()
pick_5()
turn_off()
~cpp
def turn_right():
repeat(turn_left, 3)
def move_p():
move()
pick_beeper()
def move_p5():
repeat(move_p, 5)
move_p5()
move_p()
turn_left()
move_p()
turn_left()
move_p5()
turn_right()
move_p()
turn_right()
move_p5()
turn_left()
move_p()
turn_left()
move_p5()
turn_right()
move_p()
turn_right()
move_p5()
turn_left()
move_p()
turn_left()
move_p5()
pick_beeper()
turn_off()