|
reset world
move turnleft turnright build_wall_on_left putbeeper pickbeeper makebeeper
|
|
|||||||||||||
This software is free. You are encouraged to make your own copy of it, as long as you keep the source code free. One of my design goals here is to make the program very easy to distribute, so all of the code is in one file, and you can literally copy the source by using the "View Source" feature of your browser.
Normally authors of software discourage "forking," but I encourage it. If you make your own version, you can say something along the lines of "I evolved this program from an initial version written by Steve Howell" somewhere on your page, but there is no obligation. If you decide to fork your own version, I would love to know about it, so you can contact me here. But again, there is no obligation.
If you would like to collaborate with me, please send an email to Steve.
def turnaround:
turnleft
turnleft
def move_two:
move
move
def face_north:
while not_facing_north:
turnleft
def face_west:
while not_facing_west:
turnleft
def face_east:
while not_facing_east:
turnleft
def face_south:
while not_facing_south:
turnleft
def transfer_two_squares_south:
while next_to_a_beeper:
face_south
pickbeeper
move_two
putbeeper
face_north
move_two
turnaround
face_south
move_two
def copy_north:
face_north
while next_to_a_beeper:
pickbeeper
move
putbeeper
move
makebeeper
putbeeper
turnaround
move_two
turnaround
move_two
turnaround
transfer_two_squares_south
face_east
def pickup_all_beepers:
while next_to_a_beeper:
pickbeeper
def drop_all_beepers:
while any_beepers_in_beeper_bag:
putbeeper
def add:
face_west
move_two
copy_north
move
copy_north
turnleft
move
turnleft
move
turnaround
pickup_all_beepers
move
pickup_all_beepers
move
turnright
move
drop_all_beepers
turnleft
def make_fibonacci_sequence:
do 2:
# first two numbers are 1 and 1
makebeeper
putbeeper
move
do 5:
# continue sequence for next 5 numbers
add
move
make_fibonacci_sequence
# This build a 5 x 5 square.
# Try editing it to make a smaller
# square!
def build_square:
do 4:
do 5:
move
build_wall_on_left
move
turnleft
turnleft
do 4:
do 5:
move
move
turnright
build_square
def zig_zag_and_build:
do 5:
build_wall_on_left
move
turnleft
move
build_wall_on_left
turnright
def turn_the_corner:
turnleft
move
turnleft
move
turnleft
move
def zag_zig:
do 4:
turnright
move
turnleft
move
zig_zag_and_build
turn_the_corner
zag_zig
def make_and_put_beeper: makebeeper putbeeper make_and_put_beeper move make_and_put_beeper make_and_put_beeper turnleft move make_and_put_beeper make_and_put_beeper make_and_put_beeper turnleft move make_and_put_beeper make_and_put_beeper make_and_put_beeper make_and_put_beeper turnright move
do 4:
while front_is_clear:
move
turnleft
if front_is_clear: move if front_is_blocked: # won't try to do this putbeeper if front_is_blocked: # won't do this turnleft else: # will do this instead turnright