Пример #1
0
def build_base(slot):
    """((S (K dec)) I)"""
    apply_card("put", slot)
    apply_slot(slot, "dec")
    apply_card("K", slot)
    apply_card("S", slot)
    apply_slot(slot, "I")
Пример #2
0
def build_kelly():
    """((S (horace fanny)) ian)"""
    # build fanny (always in 0)
    build_fanny()
    # build horace in 2.
    build_horace(2)

    # move fanny to 1. 
    apply_card("put", 1)
    apply_slot(1, "zero")
    apply_card("get", 1)

    # move horace to 0.
    apply_card("put", 0)
    apply_slot(0, "zero")
    apply_card("succ", 0)
    apply_card("succ", 0)
    apply_card("get", 0)

    # smash together to get (horace fanny) in 0.
    smash()

    # put an S around (horace fanny) in 0 to get (S (horace fanny))
    apply_card("S", 0)

    # build ian in 1.
    build_ian(1)
    # smash together to get ((S (horace fanny)) ian) in 0.
    smash()
Пример #3
0
def build_base(slot):
    """((S (K dec)) I)"""
    apply_card("put", slot)
    apply_slot(slot, "dec")
    apply_card("K", slot)
    apply_card("S", slot)
    apply_slot(slot, "I")
Пример #4
0
def build_rightpart():
    """Build the right part of the fireball function."""
    # build in 1: (K dec)
    apply_card("put", 1)
    apply_slot(1, "dec")
    apply_card("K", 1)

    # build in 0: greg
    build_greg(0)

    # smash together to get (greg (K dec)) in 0
    smash()

    # copy it to 1.
    apply_card("put", 1)
    apply_slot(1, "zero")
    apply_card("get", 1)

    # build horace in 0.
    build_horace(0)

    # smash together to get (horace (greg (K dec))) in 0.
    smash()

    # Wrap with an S.
    apply_card("S", 0)

    # build ian in 1.
    build_ian(1)

    # smash together to get ((S (horace (greg (K dec)))) ian) in 0.
    smash()
Пример #5
0
def build_rightpart():
    """Build the right part of the fireball function."""
    # build in 1: (K dec)
    apply_card("put", 1)
    apply_slot(1, "dec")
    apply_card("K", 1)

    # build in 0: greg
    build_greg(0)

    # smash together to get (greg (K dec)) in 0
    smash()

    # copy it to 1.
    apply_card("put", 1)
    apply_slot(1, "zero")
    apply_card("get", 1)

    # build horace in 0.
    build_horace(0)

    # smash together to get (horace (greg (K dec))) in 0.
    smash()

    # Wrap with an S.
    apply_card("S", 0)

    # build ian in 1.
    build_ian(1)

    # smash together to get ((S (horace (greg (K dec)))) ian) in 0.
    smash()
Пример #6
0
def build_fanny():
    """((S (K K)) (K K)).
    Uses slots 0 and 1, result ends up in slot 0."""
    apply_card("put", 1)
    apply_slot(1, "K")
    apply_card("K", 1)
    build_greg(0)
    smash()
Пример #7
0
def main():
    ## build the damage function.
    build_linkedlist_better()

    # two backup copies of the function.
    copy(0, 1)
    copy(0, 2)

    ## step 1: kill their low-numberd slots. (high-numbered for us.)
    build_num_in_slot(254, 1)
    smash()
    for targetslot in range(254, 256):
        for i in range(LOOPS):
            ### put the unrolled fireball in slot 0.
            unsafe_copy(2, 0)
            ## pass the function a target slot number.
            smash()
        if targetslot != 255:
            apply_card("succ", 1)

    build_num_in_slot(250, 1)
    for targetslot in range(250, 254):
        for i in range(LOOPS):
            ### put the unrolled fireball in slot 0.
            unsafe_copy(2, 0)
            ## pass the function a target slot number.
            smash()
        if targetslot != 253:
            apply_card("succ", 1)

    ## just in case we've iterated over all the slots, try it twice. This
    ## should take us through the end of a game.
    for times in range(2):
        unsafe_copy(2, 0)
        copy(2, 1)
        ## now start working on slot 0, which is easy to attack.
        apply_slot(0, "zero")
        for i in range(LOOPS):
            unsafe_copy(1, 0)
            ## pass slot 0 a slot number.
            apply_slot(0, "zero")

        build_num_in_slot(0, 1)
        for targetslot in range(1, 256):
            apply_card("succ", 1)
            for i in range(LOOPS):
                ### put the unrolled fireball in slot 0.
                unsafe_copy(2, 0)
                ## pass the function a target slot number.
                smash()
    gameloop()
Пример #8
0
def main():
    ## build the damage function.
    build_linkedlist_better()

    # two backup copies of the function.
    copy(0, 1)
    copy(0, 2)

    ## step 1: kill their low-numberd slots. (high-numbered for us.)
    build_num_in_slot(254,1)
    smash()
    for targetslot in range(254, 256):
        for i in range(LOOPS):
            ### put the unrolled fireball in slot 0.
            unsafe_copy(2,0)
            ## pass the function a target slot number.
            smash()
        if targetslot != 255:
            apply_card("succ", 1)

    build_num_in_slot(250,1)
    for targetslot in range(250, 254):
        for i in range(LOOPS):
            ### put the unrolled fireball in slot 0.
            unsafe_copy(2,0)
            ## pass the function a target slot number.
            smash()
        if targetslot != 253:
            apply_card("succ", 1)

    ## just in case we've iterated over all the slots, try it twice. This
    ## should take us through the end of a game.
    for times in range(2):
        unsafe_copy(2,0)
        copy(2,1)
        ## now start working on slot 0, which is easy to attack.
        apply_slot(0, "zero")
        for i in range(LOOPS):
            unsafe_copy(1,0)
            ## pass slot 0 a slot number.
            apply_slot(0, "zero")

        build_num_in_slot(0, 1)
        for targetslot in range(1, 256):
            apply_card("succ", 1)
            for i in range(LOOPS):
                ### put the unrolled fireball in slot 0.
                unsafe_copy(2,0)
                ## pass the function a target slot number.
                smash()
    gameloop()
Пример #9
0
def build_linkedlist_better():
    """Builds the linked list of dec in slot 0."""
    ## build the stuff.
    apply_slot(0, "S")
    apply_slot(0,"dec")
    apply_slot(0,"dec")
    for i in range(330):
        apply_card("S", 0)
        apply_slot(0,"dec")
Пример #10
0
def build_linkedlist_better():
    """Builds the linked list of dec in slot 0."""
    ## build the stuff.
    apply_slot(0, "S")
    apply_slot(0, "dec")
    apply_slot(0, "dec")
    for i in range(330):
        apply_card("S", 0)
        apply_slot(0, "dec")
Пример #11
0
def build_june2():
    """june2: takes up slots 0 and 1.
    ((S (horace fanny)) (greg I)) """
    # build fanny (always in 0)
    build_fanny()
    # move fanny to 1. 
    copy(0,1)
    # build horace in 0
    build_horace(0)
    # smash together to get (horace fanny) in 0
    smash()
    # wrap with an S
    apply_card("S", 0)

    # (greg I) is the equivalent of K, so just apply what we have in
    # slot 0 to K!
    apply_slot(0, "K")
Пример #12
0
def build_onemore():
    """(S ((S (horace (greg (K dec)))) (greg I)))"""
    apply_card("put", 1)
    apply_slot(1, "dec")
    apply_card("K", 1)
    build_greg(0)
    smash()

    # now should have (greg (K dec)) in 0.
    copy(0, 1)
    build_horace(0)
    smash()
    apply_card("S", 0)
    # now up to (S (horace (greg (K dec)))) in 0.

    # (greg I) is equivalent to K, so we can just apply slot 0 to K!
    apply_slot(0, "K")

    apply_card("S", 0)
Пример #13
0
def build_onemore():
    """(S ((S (horace (greg (K dec)))) (greg I)))"""
    apply_card("put", 1)
    apply_slot(1, "dec")
    apply_card("K", 1)
    build_greg(0)
    smash()

    # now should have (greg (K dec)) in 0.
    copy(0,1)
    build_horace(0)
    smash()
    apply_card("S", 0)
    # now up to (S (horace (greg (K dec)))) in 0.

    # (greg I) is equivalent to K, so we can just apply slot 0 to K!
    apply_slot(0, "K")

    apply_card("S", 0)
Пример #14
0
def build_june1():
    """june1: takes up slots 0 and 1.
    (S (horace (greg (K S))))"""
    # put greg in 0
    build_greg(0)
    # put S in 1
    apply_card("put", 1)
    apply_slot(1, "S")
    # put K around the S
    apply_card("K", 1)
    # smash together to get (greg (K S))
    smash()
    # copy (greg (K S)) to 1
    copy(0, 1)
    # put horace in 0
    build_horace(0)
    # smash together for (horace (greg (K S)))
    smash()
    # wrap with an S for (S (horace (greg (K S))))
    apply_card("S", 0)
Пример #15
0
def main():
    # Set up address of slot 3, in slot 0.
    build_num_in_slot(3, 0)

    # Set up contents of slot 3.
    build_num_in_slot(50, 3)

    # Set up address of slot 255, in slot 1.
    build_num_in_slot(255, 1)

    # Set up contents of slot 255.
    build_num_in_slot(20, 255)

    init_slot_with_card(5, "succ")

    # Apply succ, in slot 5, to 50, in slot 3.  Result should be 51,
    # and end up in slot 5.
    apply_slotX_to_slotY(5, 3, yaddr=0)

    init_slot_with_card(6, "dbl")

    # Apply dbl, in slot 6, to 20, in slot 255.  Result should be 40,
    # and end up in slot 6.
    apply_slotX_to_slotY(6, 255, yaddr=1)

    # Build the applicative Y combinator in slot 30.  Should touch
    # slots 0, 1, 30, 31, and 32.
    build_applicative_y(30)

    # The 'help target target amount' thing -- thanks, Jesse!
    build_num_in_slot(30, 1)
    build_num_in_slot(300,0)

    apply_slot(70, "help")
    apply_slotX_to_slotY(70, 1)
    apply_slotX_to_slotY(70, 1)
    apply_slotX_to_slotY(70, 0)

    gameloop()
Пример #16
0
def main():
    ## This takes up slots 0,1 and also 5,6,7, but it puts the y combinator
    ## into slot 5.
    build_applicative_y(5)

    ## stomps registers [0,4]. Result is in 0.
    build_fireball()

    ## make 0 and 1 Y, fireball respectively
    copy(0, 1)
    copy(5, 0)

    ## combinate: now the combinated fireball is in 0.
    smash()

    ## make backup copies of the combinated fireball.
    copy(0, 1)
    copy(0, 2)
    ## pass slot 0 a slot number.
    apply_slot(0, "zero")
    for i in range(999):
        unsafe_copy(1, 0)
        ## pass slot 0 a slot number.
        apply_slot(0, "zero")

    build_num_in_slot(0, 1)

    ## really should be up to range 256, but we're not fast enough yet.
    for targetslot in range(1, 10):
        apply_card("succ", 1)
        for i in range(1000):
            ### put the combinated fireball in slot 0.
            unsafe_copy(2, 0)
            ## pass slot 0 a slot number.
            smash()

    gameloop()
Пример #17
0
def main():
    ## This takes up slots 0,1 and also 5,6,7, but it puts the y combinator
    ## into slot 5.
    build_applicative_y(5)

    ## stomps registers [0,4]. Result is in 0.
    build_fireball()

    ## make 0 and 1 Y, fireball respectively
    copy(0,1)
    copy(5,0)

    ## combinate: now the combinated fireball is in 0.
    smash()

    ## make backup copies of the combinated fireball.
    copy(0,1)
    copy(0,2)
    ## pass slot 0 a slot number.
    apply_slot(0, "zero")
    for i in range(999):
        unsafe_copy(1,0)
        ## pass slot 0 a slot number.
        apply_slot(0, "zero")

    build_num_in_slot(0, 1)

    ## really should be up to range 256, but we're not fast enough yet.
    for targetslot in range(1, 10):
        apply_card("succ", 1)
        for i in range(1000):
            ### put the combinated fireball in slot 0.
            unsafe_copy(2,0)
            ## pass slot 0 a slot number.
            smash()

    gameloop()
Пример #18
0
def main():

    # Decrements all the other player's slots by 8 within 17,000 turns
    # or so.  Maybe we can exploit this?

    # Put "((S dec) dec)" in slot 1.
    apply_slot(1, "dec")
    apply_card("S", 1)
    apply_slot(1, "dec")

    # Build an S in slot 0.
    apply_slot(0, "S")

    # # Put (S ((S dec) dec)) in slot 0.
    smash()

    # Put (S ((S dec) dec)) and ((S dec) dec) together in slot 0.
    smash()

    # Slot 0 contains: ((S ((S dec) dec)) ((S dec) dec))
    # Copy it over to slot 1 as well
    copy(0,1)

    # # Now do: (((S slot0) slot1) targetslot)
    apply_card("S", 0)
    smash()

    num = 0;
    while (len(pipeline) < 17000):
        # Save for later
        copy(0,2)

        build_num_in_slot(num, 1)
        smash()

        # Copy back to slot 0
        copy(2,0)

        num = num + 1

    gameloop()
Пример #19
0
def main():

    # Decrements all the other player's slots by 8 within 17,000 turns
    # or so.  Maybe we can exploit this?

    # Put "((S dec) dec)" in slot 1.
    apply_slot(1, "dec")
    apply_card("S", 1)
    apply_slot(1, "dec")

    # Build an S in slot 0.
    apply_slot(0, "S")

    # # Put (S ((S dec) dec)) in slot 0.
    smash()

    # Put (S ((S dec) dec)) and ((S dec) dec) together in slot 0.
    smash()

    # Slot 0 contains: ((S ((S dec) dec)) ((S dec) dec))
    # Copy it over to slot 1 as well
    copy(0, 1)

    # # Now do: (((S slot0) slot1) targetslot)
    apply_card("S", 0)
    smash()

    num = 0
    while (len(pipeline) < 17000):
        # Save for later
        copy(0, 2)

        build_num_in_slot(num, 1)
        smash()

        # Copy back to slot 0
        copy(2, 0)

        num = num + 1

    gameloop()
Пример #20
0
def main():
    build_onemore()
    copy(0, 2) ## back up the onemore for later use
    build_base(1)
    smash()
    copy(0,1) ## move the now-bigger function into 1

    ## build up a function that does 67 damage. That's the biggest one that we
    ## can run without going over the function application limit.
    for i in range(65):
        # copy the onemore into 0
        copy(2,0)
        smash()
        # copy the now-bigger function into 1
        copy(0,1)

    ## two backup copies of the 67-damage thing.
    copy(0,2)

    ## step 1: kill their low-numbered slots. (high-numbered for us.)
    build_num_in_slot(253,1)
    smash()
    for targetslot in range(253, 256):
        for i in range(LOOPS):
            ### put the unrolled fireball in slot 0.
            unsafe_copy(2,0)
            ## pass the function a target slot number.
            smash()
        if targetslot != 255:
            apply_card("succ", 1)

    build_num_in_slot(250,1)
    for targetslot in range(250, 253):
        for i in range(LOOPS):
            ### put the unrolled fireball in slot 0.
            unsafe_copy(2,0)
            ## pass the function a target slot number.
            smash()
        if targetslot != 253:
            apply_card("succ", 1)

    unsafe_copy(2,0)
    copy(2,1)
    ## now start working on slot 0, which is easy to attack.
    apply_slot(0, "zero")
    for i in range(LOOPS):
        unsafe_copy(1,0)
        ## pass slot 0 a slot number.
        apply_slot(0, "zero")

    build_num_in_slot(0, 1)
    ## really should be up to range 256. How fast are we?
    for targetslot in range(1, 100):
        apply_card("succ", 1)
        for i in range(LOOPS):
            ### put the unrolled fireball in slot 0.
            unsafe_copy(2,0)
            ## pass the function a target slot number.
            smash()

    gameloop()
Пример #21
0
def build_horace(slot):
    """(S (K S))"""
    apply_card("put", slot)
    apply_slot(slot, "S")
    apply_card("K", slot)
    apply_card("S", slot)
Пример #22
0
def build_applicative_y(n):
    """
    Build the applicative-order Y combinator into slot n.  Warning:
    touches slots 0 and 1 as well as slots n, n+1, and n+2.

    Supposedly, what we're building is:

    ((S 
      ((S (horace (greg I))) 
       ((S (horace (june1 ((S (horace (june1 kelly))) kelly)))) (greg ian))))
     ((S (horace (greg I))) 
      ((S (horace (june1 ((S (horace (june1 kelly))) kelly)))) (greg ian)))))

    """

    # Put (june1 kelly) in slot n.
    build_june1()
    copy(0, n) # move june1 to slot n
    build_kelly()
    apply_slotX_to_slotY(n, 0)

    # Put address of n in slot 0.
    build_num_in_slot(n, 0)

    # Put (horace (june1 kelly)) in slot n+1.
    build_horace(n+1)
    apply_slotX_to_slotY(n+1, n, yaddr=0)

    # Put (S (horace (june1 kelly))) in slot n+1.
    apply_card("S", n+1)

    # Put ((S (horace (june1 kelly))) kelly) in slot n+1.
    build_kelly() # always ends up in slot 0.
    apply_slotX_to_slotY(n+1, 0)

    # Put june1 in slot 0.
    build_june1()

    # Put address of n+1 in slot 1.
    build_num_in_slot(n+1, 1)

    # Put (june1 ((S (horace (june1 kelly))) kelly)) in slot 0.
    apply_slotX_to_slotY(0, n+1, yaddr=1)

    # Put horace in slot n.
    build_horace(n)

    # Put (horace (june1 ((S (horace (june1 kelly))) kelly))) in slot n.
    apply_slotX_to_slotY(n, 0)

    # Put (S (horace (june1 ((S (horace (june1 kelly))) kelly)))) in slot n.
    apply_card("S", n)

    # Put (greg ian) in slot 0.
    build_greg(0)
    build_ian(1)
    smash()

    # Put 
    # ((S (horace (june1 ((S (horace (june1 kelly))) kelly)))) (greg ian)) 
    # in slot n.
    apply_slotX_to_slotY(n, 0)
    
    # Put (greg I) in slot n+1.
    # It turns out (greg I) is equivalent to K!
    apply_card("put", n+1)
    apply_slot(n+1, "K")

    # Put (horace (greg I)) in slot n+2.
    build_horace(n+2)
    # Put address of n+1 in slot 1.
    build_num_in_slot(n+1, 1)
    apply_slotX_to_slotY(n+2, n+1, yaddr=1)

    # Put (S (horace (greg I))) in slot n+2.
    apply_card("S", n+2)

    # Put
    # ((S (horace (greg I))) 
    #  ((S (horace (june1 ((S (horace (june1 kelly))) kelly)))) (greg ian)))
    # in slot n+2.
    build_num_in_slot(n, 0)
    apply_slotX_to_slotY(n+2, n, yaddr=0)

    # Copy slot n+2 to slot n+1.
    copy(n+2, n+1)

    # Apply S to slot n+2, leaving the result in slot n+2.
    apply_card("S", n+2)

    # Apply contents of n+2 to contents of n+1, leaving the result in
    # slot n+2.
    #build_num_in_slot(n+1, 1)
    apply_slotX_to_slotY(n+2, n+1, yaddr=1)

    # Copy slot n+2 to slot n.
    copy(n+2, n)
Пример #23
0
def build_clarice(slot):
    apply_slot(slot,"S")
    apply_card("K",slot)
    apply_card("S",slot)
    apply_slot(slot,"K")
    apply_card("S",slot) # and now the S around clarice.
Пример #24
0
def build_dianne(slot):
    apply_card("put",slot)
    apply_card("S",slot)
    apply_slot(slot,"I")
    apply_card("K",slot)
Пример #25
0
def build_greg(slot):
    """(S (K K))"""
    apply_card("put", slot)
    apply_slot(slot, "K")
    apply_card("K", slot)
    apply_card("S", slot)
Пример #26
0
def main():
    build_onemore()
    copy(0, 2)  ## back up the onemore for later use
    build_base(1)
    smash()
    copy(0, 1)  ## move the now-bigger function into 1

    ## build up a function that does 67 damage. That's the biggest one that we
    ## can run without going over the function application limit.
    for i in range(65):
        # copy the onemore into 0
        copy(2, 0)
        smash()
        # copy the now-bigger function into 1
        copy(0, 1)

    ## two backup copies of the 67-damage thing.
    copy(0, 2)

    ## step 1: kill their low-numbered slots. (high-numbered for us.)
    build_num_in_slot(253, 1)
    smash()
    for targetslot in range(253, 256):
        for i in range(LOOPS):
            ### put the unrolled fireball in slot 0.
            unsafe_copy(2, 0)
            ## pass the function a target slot number.
            smash()
        if targetslot != 255:
            apply_card("succ", 1)

    build_num_in_slot(250, 1)
    for targetslot in range(250, 253):
        for i in range(LOOPS):
            ### put the unrolled fireball in slot 0.
            unsafe_copy(2, 0)
            ## pass the function a target slot number.
            smash()
        if targetslot != 253:
            apply_card("succ", 1)

    unsafe_copy(2, 0)
    copy(2, 1)
    ## now start working on slot 0, which is easy to attack.
    apply_slot(0, "zero")
    for i in range(LOOPS):
        unsafe_copy(1, 0)
        ## pass slot 0 a slot number.
        apply_slot(0, "zero")

    build_num_in_slot(0, 1)
    ## really should be up to range 256. How fast are we?
    for targetslot in range(1, 100):
        apply_card("succ", 1)
        for i in range(LOOPS):
            ### put the unrolled fireball in slot 0.
            unsafe_copy(2, 0)
            ## pass the function a target slot number.
            smash()

    gameloop()