Exemple #1
0
def octagon():
    #environment(corner3_5+beepers)
    # IB2a, IB3, IC, IIB1
    return (environment.default(xpos=7, ypos=2), """def turn_around():
    for i in range(2):
        turn_left()
def line(size):
    for i in range(size):
        drop_beeper()
        move()
def diagonal_line(size):
    for i in range(size):
        drop_beeper()
        move()
        turn_left()
        move()
        turn_right()
def octagon(size):
    for i in range(4):
        diagonal_line(size)
        turn_left()
        line(size)
octagon(2)
turn_off()
""")
Exemple #2
0
def measurement_area():
    #environment(corner*_*) vary dir?
    # IB1a, IB2a, IC, IIA2, IIB2
    return (environment.default(0,0,0,0), """def turn_around():
    for i in range(2):
        turn_left()
def dist_to_wall():
    d=0
    while front_is_clear():
        move()
        d+=1
    turn_around()
    for i in range(d):
        move()
    turn_around()
    return d
a=dist_to_wall()
turn_around()
a+=dist_to_wall()
turn_left()
b=dist_to_wall()
turn_around()
b+=dist_to_wall()
turn_right()
print "The area is", (a+1)*(b+1)
turn_off()
""")
Exemple #3
0
def pattern():
    #environment(default+beepers)
    # IA2, IB1a, IB2a, IB2c, IB3, IC, IIB1, IIIA1, IIIA2, IIIB1
    code = ("""for i in range(4):
    for j in range(5):
        if i+1 == j or j+i == 4:
            drop_beepers(1)
        else:
            drop_beepers(2)
    crlf()""", """for g in range(3):
    for h in range(3):
        if g == h+1 or g+h == 2:
            drop_beepers(1)
        else:
            drop_beepers(2)
    crlf()""")
    return (environment.default(), """def turn_around():
    for i in range(2):
        turn_left()
def crlf():
    turn_left()
    move()
    turn_left()
    while front_is_clear():
        move()
    turn_around()
    move()
def drop_beepers(num):
    for i in range(num):
        drop_beeper()
    move()
move()
""" + code[random.randint(0,1)] + """
turn_off()
""")
Exemple #4
0
def filled_triangle():
    #environment(default+beepers)
    # IA1, IA2, IB2a, IB2c, IC, IIB1, IIIA1, IIIB1, IIIB2, IIIB3
    size = random.randint(2,5) if not writeMode else 4
    return (environment.default(), """def turn_around():
    for i in range(2):
        turn_left()
def line(size):
    for i in range(size):
        move()
        drop_beeper()
def filled_triangle(size):
    for i in range(size+1):
        move()
    for i in range(size,0,-1):
        if (size-i)%2 == 0:
            turn_left()
            move()
            turn_left()
        else:
            move()
            turn_right()
            move()
            turn_right()
        line(i)
    if size%2 == 0:
        turn_around()
    move()
    turn_left()
    for i in range(size):
        move()
    turn_left()
filled_triangle(""" + str(size) + """)
turn_off()
""")
Exemple #5
0
def rectangle():
    #environment(default+beepers)
    # IB2a, IC, IIB1
    length = random.randint(3,5) if not writeMode else 3
    width = random.randint(3,5) if not writeMode else 4
    return (environment.default(), """def turn_around():
    for i in range(2):
        turn_left()
def line(size):
    for i in range(size):
        drop_beeper()
        move()
def rectangle(width,length):
    size=[width,length]
    move()
    turn_left()
    move()
    turn_right()
    for i in range(4):
        line(size[i%2]-1)
        turn_left()
    turn_around()
    move()
    turn_left()
    move()
    turn_left()
def square(size):
    rectangle(size,size)
rectangle(""" + str(width) + "," + str(length) + """)
turn_off()
""")
Exemple #6
0
def spaced_beepers():
    #environment(default+beepers)
    # IA1, IB2a, IB2c, IB3, IIIA1, IIIB1
    code = ("""for i in range(10):
    if i%3 == 0:
        drop_beeper()
    move()
turn_off()
""", """for i in range(11):
    if i%2 == 0:
        for j in range(i/2 + 1):
            drop_beeper()
    move()
turn_off()
""")
    return (environment.default(12,12), code[random.randint(0,1)])
Exemple #7
0
def measurement_dist():
    #environment(default) vary dir?
    # IB1a, IB2a, IC, IIA2, IIB2
    return (environment.default(0,0,0,0), """def turn_around():
    for i in range(2):
        turn_left()
d=0
while front_is_clear():
    move()
    d+=1
turn_around()
for i in range(d):
    move()
turn_around()
print "The distance is", d
turn_off()
""")
Exemple #8
0
def calendar():
    #environment(corner3_5+beepers)
    # IA2, IB1a, IB2a, IB2c, IB3, IC, IIA1, IIA2, IIB1, IIIA1, IIIB1, IIIB2, IIIB3
    return (environment.default(xpos=3, ypos=5), """def turn_around():
    for i in range(2):
        turn_left()
def week(first,days,dir=1):
    if dir == -1:
        start = first+days-1
        end = first-1
    else:
        start = first
        end = first+days
    for i in range(start,end,dir):
        for j in range(i):
            drop_beeper()
        move()
def calendar(first,days):
    turn_left()
    for i in range(first):
        move()
    week(1,7-first)
    start = 8-first
    dir=0
    while start <= days:
        if dir == 0:
            for i in range(2):
                turn_right()
                move()
            for i in range(start+6-days):
                move()
        else:
            for i in range(2):
                turn_left()
                move()
        week(start,min(days-start+1,7),dir*2-1)
        start += 7
        dir = (dir+1)%2
calendar(4,30)
turn_off()
""")
Exemple #9
0
def bowling():
    #environment(default+beepers)
    # IA1, IA2, IB2a, IB2c, IC, IIB1, IIIB1
    rows = random.randint(3,4) if not writeMode else 4
    return (environment.default(), """def turn_around():
    for i in range(2):
        turn_left()
def line(size):
    for i in range(size):
        move()
        drop_beeper()
        move()
def bowling_pins(size):
    for i in range(4):
        move()
    for i in range(size):
        move()
        if i%2 == 0:
            turn_left()
            move()
            turn_left()
        else:
            turn_right()
            move()
            turn_right()
        line(i+1)
    if size%2 == 0:
        turn_around()
    while front_is_clear():
        move()
    turn_left()
    for i in range(size):
        move()
    turn_left()
bowling_pins(""" + str(rows) + """)
turn_off()
""")
Exemple #10
0
def triangle():
    #environment(default+beepers)
    # IB2a, IC, IIB1
    size = random.randint(3,5) if not writeMode else 4
    return (environment.default(), """def turn_around():
    for i in range(2):
        turn_left()
def line(size):
    for i in range(size):
        drop_beeper()
        move()
def diagonal_line(size):
    for i in range(size):
        drop_beeper()
        move()
        turn_left()
        move()
        turn_right()
def triangle(size):
    move()
    turn_left()
    move()
    turn_right()
    line(size-1)
    turn_left()
    diagonal_line(size-1)
    turn_around()
    line(size-1)
    turn_right()
    move()
    turn_left()
    move()
    turn_left()
triangle(""" + str(size) + """)
turn_off()
""")