# BeeprBot Unary Addition
# This program requires AUXILIARY MODE
# set this in your menu, under
#  - under robot select settings
#  - in the pop-up: 
#  - - click the button for auxiliary mode
#  - -  click the save button

# this is similar to the one developed in class
# but may not be identical

# unary addition example, not destroying inputs
define main {
    # get the first input
    move
    get_and_restore
    
    # get the second input
    move
    get_and_restore

    # output the result
    move
    display_sum
    move
}

# pick up the beepers and put them in 
# bag 1, at the same time recreating
# the pile
define get_and_restore {
    while (next_to_a_beeper) {
        pick_beeper
    }
    while (has_beeper(0)) {
        move_beeper(0,1)
        create_beeper
    }
}

# drop all the beepers from bag 1
# RECALL put_beeper only works on
# bag 0
define display_sum {
    while (has_beeper(1)) {
        move_beeper(1,0)
        put_beeper
    }
}
