示例#1
0
 def test_find_all_seven_object_period_9_siteswaps_with_passes_selfs_and_heffs(
         self):
     partial_siteswap = ['?'] * 9
     output = complete_the_siteswap.filter_rotations(
         complete_the_siteswap.complete(partial_siteswap, [6, 7, 8], 7))
     # 10 according to juggling lab.
     self.assertEqual(len(output), 10)
示例#2
0
 def test_find_all_three_object_period_5_siteswaps_max_height_9(self):
     partial_siteswap = ['?'] * 5
     output = complete_the_siteswap.filter_rotations(
         complete_the_siteswap.complete(partial_siteswap, list(range(8)),
                                        3))
     # 89 according to juggling lab.
     self.assertEqual(len(output), 89)
示例#3
0
def do_not_throw_pass(raw_siteswap, index, permitted_throws):

    patterns_found = []
    siteswap = raw_siteswap.copy()
    siteswap = siteswap[index:] + siteswap[:index]  # rotate so pass at front
    number_of_objects = sum(siteswap) / len(siteswap)
    # print(siteswap)

    if siteswap[0] % 2 != 1:
        print("There's no pass there not to throw!")
        return None

    elif len([throw for throw in raw_siteswap if throw % 2 == 1]) <= 2:
        #All selfs, not an interesting pattern
        return []
    else:  # first throw is a pass and still have passes after removing it
        siteswap[(siteswap[0] - 2) % len(siteswap)] = 2
        siteswap[0] = '?'

    for time, throw in enumerate(siteswap):
        if throw != '?' and time % 2 == 0 and throw % 2 == 0:
            siteswap[time] = '?'

    permitted_self_throws = [
        throw for throw in permitted_throws if throw % 2 == 0
    ]  # This is to rule out adding in extra passes over the transition
    solutions = complete_the_siteswap.complete(siteswap, permitted_self_throws,
                                               number_of_objects)
    raw_siteswap = raw_siteswap[index:] + raw_siteswap[:index]
    if solutions == []:
        pass
    for pattern in complete_the_siteswap.filter_rotations(solutions):
        patterns_found.append(
            find_transitions(raw_siteswap, pattern, [2, 4, 6, 8]))
    return patterns_found
示例#4
0
 def test_valid_siteswaps_give_one_solution(self):
     valid_siteswaps = [[3, 4, 5], [11, 9, 7, 5, 3, 1], [11, 0, 1]]
     output = [
         complete_the_siteswap.complete(i, list(range(10)))
         for i in valid_siteswaps
     ]
     answer = [[valid_siteswap] for valid_siteswap in valid_siteswaps]
     self.assertEqual(output, answer)
示例#5
0
 def test_find_all_three_object_period_5_siteswaps_max_height_9_no_0s_or_2s(
         self):
     partial_siteswap = ['?'] * 5
     output = complete_the_siteswap.filter_rotations(
         complete_the_siteswap.complete(partial_siteswap,
                                        [1, 3, 4, 5, 6, 7], 3))
     # 12 according to juggling lab.
     self.assertEqual(len(output), 12)
示例#6
0
 def test_finals_all_ways_to_fill_two_gaps(self):
     partial_siteswap = [4, 4, '?', '?']
     output = complete_the_siteswap.complete(partial_siteswap,
                                             list(range(10)))
     answer = [[4,4,i,j] for i in [0,4,8] for j in [0,4,8]] + \
             [[4,4,i,j] for i in [1,5,9] for j in [3,7]]
     output.sort()
     answer.sort()
     self.assertEqual(output, answer)
示例#7
0
 def test_invalid_partial_siteswaps_gives_empty_list(self):
     invalid_partial_siteswaps = [[5, 4, '?', '?'], [8, '?', '?', '?', 4],
                                  [3, '?', 1], [2, '?', '?', 7]]
     output = [
         complete_the_siteswap.complete(i, list(range(10)))
         for i in invalid_partial_siteswaps
     ]
     answer = [[] for i in invalid_partial_siteswaps]
     self.assertEqual(output, answer)
示例#8
0
def throw_extra_pass(raw_siteswap,
                     index,
                     permitted_throws,
                     extra_pass=None,
                     response_pass=None):
    if len(raw_siteswap) % 2 == 1:
        raw_siteswap *= 2
    siteswap = raw_siteswap.copy()
    siteswap = siteswap[
        index:] + siteswap[:index]  # rotate so extra pass is at front
    patterns_found = []
    # print(siteswap)

    number_of_objects = sum(siteswap) / len(siteswap)

    for time, throw in enumerate(siteswap):
        if time % 2 == 0 and throw % 2 == 0:
            siteswap[time] = '?'
    if extra_pass == None:
        extra_pass = len(raw_siteswap) // 2 + 2
    siteswap[0] = extra_pass
    # TODO: does this give weird results?
    if response_pass == None:
        response_pass = len(raw_siteswap) // 2 + 2
    siteswap[(extra_pass - 2) % len(siteswap)] = response_pass

    permitted_self_throws = [
        throw for throw in permitted_throws if throw % 2 == 0
    ]  # This is to rule out adding in extra passes over the transition
    solutions = complete_the_siteswap.complete(siteswap, permitted_self_throws,
                                               number_of_objects)
    raw_siteswap = raw_siteswap[index:] + raw_siteswap[:index]
    if solutions == []:
        pass
    for pattern in complete_the_siteswap.filter_rotations(solutions):
        patterns_found.append(
            find_transitions(raw_siteswap, pattern, [2, 4, 6, 8]))
    return patterns_found
示例#9
0
 def test_finds_all_ways_to_fill_one_gap(self):
     partial_siteswap = [5, '?', 4]
     output = complete_the_siteswap.complete(partial_siteswap,
                                             list(range(10)))
     answer = [[5, i, 4] for i in range(10) if i % 3 == 0]
     self.assertEqual(output, answer)
示例#10
0
 def test_find_all_three_object_period_3_siteswaps_max_height_9(self):
     partial_siteswap = ['?'] * 3
     output = complete_the_siteswap.filter_rotations(
         complete_the_siteswap.complete(partial_siteswap, list(range(10)),
                                        3))
     self.assertEqual(len(output), 13)