def run_game(): pygame.init() pygame.display.set_caption('Alien Invasion') ai_setings = Setting() screen = pygame.display.set_mode( (ai_setings.screen_width, ai_setings.screen_height), pygame.FULLSCREEN) play_button = Button(ai_setings, screen, 'Play') setting_button = S_Button(ai_setings, screen, 'Setting') q_button = Q_Button(ai_setings, screen, 'Quit') ship = Ship(ai_setings, screen) bullet = Group() alien = Alien(ai_setings, screen, scale) aliens = Group() gf.create_fleet(ai_setings, screen, ship, aliens) stats = GameStats(ai_setings) sb = scoreboard(ai_setings, screen, stats) gf.update_screen(ai_setings, screen, stats, sb, ship, bullet, aliens, play_button, setting_button, q_button) while True: gf.check_events(ai_setings, screen, stats, sb, play_button, setting_button, q_button, ship, aliens, bullet) if stats.game_active: ship.update() gf.update_screen(ai_setings, screen, stats, sb, ship, bullet, aliens, play_button, setting_button, q_button) gf.update_bullet(ai_setings, screen, stats, sb, ship, bullet, aliens) gf.update_aliens(ai_setings, stats, screen, sb, ship, aliens, bullet)
def main(): transDict, Greek_word_num, Greek_search_dict, Greek_text = preprocessing() # Save lemma to translations found found_translist = {} try: while (True): scoreKeeper = scoreboard(MAX_SCOREBOARD_SIZE, MIN_SCORE) input_phrase = input("Enter Search Phrase> ") if re.sub(" ", "", re.sub("q", "", input_phrase)) == "" or re.sub(" ", "", re.sub("quit", "", input_phrase)) == "": exit(0) if (valid_search(input_phrase)): search = search_phrase(input_phrase, "Latin") # Find all the translations of the given words for i in range(search.search_len): search.has_translation[i] = trn.get_translation(search.text[i], transDict, found_translist) xls.try_all_search_combos(search, scoreKeeper, Greek_word_num, Greek_search_dict, Greek_text) print(scoreKeeper) else: print('Please enter a valid string\n') except KeyboardInterrupt: print('\nProgram Terminated\n') sys.exit(0)
def search_by_phrase(input_phrase, language, transDict, Greek_word_num, Greek_search_dict, Greek_text, max_scoreboard_size, min_score): if not (valid_search(input_phrase)): return ERROR else: output_translation_matrix = [] output_translation_matrix.append([""]) # Save lemma to translations found found_translist = {} scoreKeeper = scoreboard(max_scoreboard_size, min_score) search = search_phrase(input_phrase, language) # Find all the translations of the given words for i in range(search.search_len): search.has_translation[i] = trn.get_translation(search.text[i], transDict, found_translist) xls.try_all_search_combos(search, scoreKeeper, Greek_word_num, Greek_search_dict, Greek_text, output_translation_matrix) #translations_of_search = translation_matrix_to_string(output_translation_matrix) output_translation_matrix.pop(0) return scoreKeeper, output_translation_matrix
def __init__(self, strRGB_i, pos_ply1, pos_ply2, reset=0, play=1): # Inputs. self.strRGB_i = strRGB_i self.pos_ply1 = pos_ply1 self.pos_ply2 = pos_ply2 self.reset = reset self.play = play # Outputs. self.sound = Signal(2) self.channel = Signal(2) self.strRGB_o = [ Signal(11), Signal(11), Signal(), Signal(), Signal(), Signal(), Signal(), Signal() ] # Submodules. # Create two vertical players with control signals. # We chain the streams RGB. self.mod_p0 = player(self.strRGB_i, self.pos_ply1, offset=screen.posX_left) self.mod_p1 = player(self.mod_p0.strRGB_o, self.pos_ply2, offset=screen.posX_right) # Created dynamic module for game. # TODO: 'Reset' and 'Play' Signals. self.mod_d0 = dynamicGame(self.reset, self.play, self.pos_ply1, self.pos_ply2) # Create module that draw ball in (x_ball, y_ball) position on a stream RGB. self.mod_p2 = ball(self.mod_p1.strRGB_o, self.mod_d0.x_ball, self.mod_d0.y_ball) # Create a scoreboard for players goals. # TODO: Create behaviour for 'reset' score signal. self.mod_p3 = scoreboard(self.mod_p2.strRGB_o, 0, self.mod_d0.goal_ply1, self.mod_d0.goal_ply2)
if (0 == QUIT_AFTER_FIRST_MATCH): return; # If no more attempts, break from inner for loop else: return return if __name__ == '__main__': Latin_word_num, Latin_search_dict, Latin_text, Greek_word_num, Greek_search_dict, Greek_text = preprocessing() # Save lemma to translations found found_translist = {} #Create scoreboard scoreKeeper = scoreboard(MAX_SCOREBOARD_SIZE, MIN_SCORE) try: print("Beginning Search\n") # Finds all word pairs in Latin_text that are within 1,2,3, .. MAX_DISTANCE_LATIN positions of each other for j in range(1, MAX_DISTANCE_LATIN): for i in range(Latin_word_num - j - 1): # For both the first and second word in the pair find the word, its position, and the occurences in the text L1, L2 = xls.get_LatinWordStats(Latin_text, Latin_search_dict, i, j) if -1 == trn.get_translation_pair(L1, L2, transDict, found_translist): continue
def elaborate(self, platform: Platform) -> Module: m = Module() # Generated VGA stream in a 'sync' domain (16Mhz). mod_0 = pxClkGen (16, 50, 'px') # Use PLL for 50Mhz from 16Mhz and use 'px' domain. m.domains.px = mod_0.domain # Update 'px' domain clock from new module 'mod_0'. clk_pin = ClockSignal('sync') # Get the signal system clock 'sync'. m.d.comb += mod_0.clk_pin.eq(clk_pin) # Assign 'clk_pin' to PLL module 'mod_0'. # Created new 'frm' domain with 'endframe' clock (72 frames per second). clk_frm = Signal() m.domains += ClockDomain('frm') clk_frm = ClockSignal('frm') # Update a counter each 'clk_frm' for dynamic clock. counter = Signal(25) m.d.frm += counter.eq (counter+1) # Created new 'dyn' domain with dynamic clock for an animation objects. # Each 2^6 = 64 frames in counter. clk_dyn = Signal() m.domains += ClockDomain('dyn') clk_dyn = ClockSignal('dyn') m.d.comb += clk_dyn.eq (counter[6]) # Create new module for VGA synchronisms signals. mod_1 = syncVGAGen () # We improvise a combinational module to generate the new frame clock. m.d.comb += clk_frm.eq ((mod_1.x == 0) & (mod_1.y == 0)) # Create new module with tennis court in a stream RGB. mod_2 = court (mod_1.strVGA) # Create two vertical players with control buttons. ply1_up = Signal() ply1_down = Signal() ply2_up = Signal() ply2_down = Signal() ctl_1 = ctlButtons (ply1_up, ply1_down, ply2_up, ply2_down) mod_3 = player (mod_2.strRGB_o, ctl_1.pos_ply1, offset= screen.offset_player) mod_4 = player (mod_3.strRGB_o, ctl_1.pos_ply2, offset= screen.width-screen.offset_player-screen.width_player) # Created dynamic module for game. din_1 = dynamicGame (0, 1, ctl_1.pos_ply1, ctl_1.pos_ply2) # Create new module with ball in (x,y) position in a stream RGB. mod_5 = ball (mod_4.strRGB_o, din_1.x_ball, din_1.y_ball) # Create module with sound card. snd_1 = soundCard (din_1.sound, din_1.channel) # Create a scoreboard for player's goals. mod_6 = scoreboard (mod_5.strRGB_o, 0, din_1.goal_ply1, din_1.goal_ply2) # Add all submodules. m.submodules += [mod_0, mod_1, mod_2, mod_3, mod_4, mod_5, mod_6, din_1, ctl_1, snd_1] # Conected signals with externals pins. # VGA signals. strRGB_o = mod_6.strRGB_o m.d.comb += platform.request ("pin_13").o.eq(strRGB_o[st.VS]) m.d.comb += platform.request ("pin_12").o.eq(strRGB_o[st.HS]) m.d.comb += platform.request ("pin_11").o.eq(strRGB_o[st.R]) m.d.comb += platform.request ("pin_10").o.eq(strRGB_o[st.G]) m.d.comb += platform.request ( "pin_9").o.eq(strRGB_o[st.B]) # Test LED m.d.comb += platform.request("pin_14").o.eq(counter[16]) # Audio signals. m.d.comb += platform.request ("pin_19").o.eq(snd_1.left_ch) m.d.comb += platform.request ("pin_20").o.eq(snd_1.right_ch) # Control signals. m.d.comb += ply1_up.eq (platform.request ("pin_21")) m.d.comb += ply1_down.eq (platform.request ("pin_22")) m.d.comb += ply2_up.eq (platform.request ("pin_23")) m.d.comb += ply2_down.eq (platform.request ("pin_24")) return m
print(set(string.ascii_lowercase).intersection(word)) print(set(string.ascii_uppercase).intersection(word)) print(set(string.digits).intersection(word)) print(set(string.punctuation).intersection(word)) #print(string.digits.index(word[0])) typed_string_pix = numpy.zeros((32, 32)) canvas_pix = display_object(0, 0, 32, 32) test_master = matrix_master(canvas_pix) # display_object for user typed input (in typing game) user_typed_obj = display_object(1, 4, 30, 7) test_master.display_object_list.append(user_typed_obj) # display_object for the score scoreboard_obj = scoreboard(1, 16, 4) test_master.display_object_list.append(scoreboard_obj) #print_to_matrix_default(displayAt(0,0,scoreboard_obj.getScoreboard_pix(0))) user_input = raw_input("Press any key to start\t") # take first char input --> initialize typed_string #typed_string = array.array('c',[user_input]) typed_string = [] # add char input.pix --> user_typed_obj #this_char = chartopix(user_input) user_typed_idx = 0 score = 0 while (user_input != 'QUIT'): user_input = raw_input("Press any key\t") print(user_input)
def start_menu(): ascii = """ ███████╗███████╗ ██████╗ █████╗ ██████╗ ███████╗ ██████╗ ██████╗ ██████╗ ███╗ ███╗ ██╔════╝██╔════╝██╔════╝██╔══██╗██╔══██╗██╔════╝ ██╔══██╗██╔═══██╗██╔═══██╗████╗ ████║ █████╗ ███████╗██║ ███████║██████╔╝█████╗ ██████╔╝██║ ██║██║ ██║██╔████╔██║ ██╔══╝ ╚════██║██║ ██╔══██║██╔═══╝ ██╔══╝ ██╔══██╗██║ ██║██║ ██║██║╚██╔╝██║ ███████╗███████║╚██████╗██║ ██║██║ ███████╗ ██║ ██║╚██████╔╝╚██████╔╝██║ ╚═╝ ██║ ╚══════╝╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ """ about = """A puzzle game where you must solve the clues to escape your neighbour's house before they get home. \n\n """ menu = """ PRESS ANY KEY IF YOU WISH TO CONTINUE enter -99 to exit SCOREBOARD: """ for char in ascii: #sleep(0.009) # print(char, end="") sys.stdout.write(char) sys.stdout.flush() for char in about: #sleep(0.08) # print(char, end="") sys.stdout.write(char) sys.stdout.flush() for char in menu: #sleep(0.1) # print(char, end="") sys.stdout.write(char) sys.stdout.flush() print("\t\t\t\t" , "NAME" , "\t\t" , "TIME(s)") scoreboard() user_input = input("> ") if user_input == str(-99): quit() global game_id game_id ="" while len(game_id) != 3: print("Enter your name ( 3 characters only )") game_id = input("") return game_id
class Issue_stage(Module): io = IO( clk_i=Input(U.w(1)), rst_ni=Input(U.w(1)), #时钟信号要定义吗? sb_full_o=Output(U.w(1)), flush_unissued_instr_i=Input(U.w(1)), flush_i=Input(U.w(1)), decoded_instr_i=Input(scoreboard_entry_t()), ##### decoded_instr_valid_i=Input(U.w(1)), is_ctrl_flow_i=Input(U.w(1)), decoded_instr_ack_o=Output(U.w(1)), fu_data_o=Output(fu_data_t()), ##### pc_o=Output(U.w(64)), is_compressed_instr_o=Output(U.w(1)), flu_ready_i=Input(U.w(1)), alu_valid_o=Output(U.w(1)), #ex just resolved our predicted branch, we are ready to accept new requests resolve_branch_i=Input(U.w(1)), lsu_ready_i=Input(U.w(1)), lsu_valid_o=Output(U.w(1)), branch_valid_o=Output(U.w(1)), branch_predict_o=Input(branchpredict_sbe_t()), ##### mult_valid_o=Output(U.w(1)), fpu_ready_i=Input(U.w(1)), fpu_valid_o=Output(U.w(1)), fpu_fmt_o=Output(U.w(2)), fpu_rm_o=Output(U.w(3)), csr_valid_o=Output(U.w(1)), trans_id_i=Input(Vec(NR_WB_PORTS, U.w(3))), resolved_branch_i=Input(bp_resolve_t), ##### wbdata_i=Input(Vec(NR_WB_PORTS, U.w(64))), ex_ex_i=Input(Vec(NR_WB_PORTS, exception_t())), ##### wt_valid_i=Input(U.w(NR_WB_PORTS)), waddr_i=Input(Vec(NR_COMMIT_PORTS, U.w(5))), wdata_i=Input(Vec(NR_COMMIT_PORTS, U.w(64))), we_gpr_i=Input(U.w(NR_COMMIT_PORTS)), we_fpr_i=Input(U.w(NR_COMMIT_PORTS)), commit_instr_o=Output(Vec(NR_COMMIT_PORTS, scoreboard_entry_t())), ##### commit_ack_i=Input(U.w(NR_COMMIT_PORTS))) rd_clobber_gpr_sb_iro = Reg(Vec(64, U.w(4))) rd_clobber_fpr_sb_iro = Reg(Vec(64, U.w(4))) rs1_iro_sb = Reg(U.w(6)) rs1_valid_sb_iro = Reg(U.w(1)) rs2_iro_sb = Reg(U.w(6)) rs2_sb_iro = Reg(U.w(64)) rs2_valid_iro_sb = Reg(U.w(1)) rs3_iro_sb = Reg(U.w(6)) #logic [FLEN-1:0] rs3_sb_iro; rs3_valid_iro_sb = Reg(U.w(1)) issue_instr_rename_sb = Wire(scoreboard_entry_t()) ##### issue_instr_valid_rename_sb = Reg(U.w(1)) issue_ack_sb_rename = Reg(U.w(1)) issue_instr_sb_iro = Wire(scoreboard_entry_t()) ##### issue_instr_valid_sb_iro = Reg(U.w(1)) issue_ack_iro_sb = Reg(U.w(1)) i_re_name = re_name() i_re_name.io.clk_i <<= io.clk_i i_re_name.io.rst_ni <<= io.rst_ni i_re_name.io.flush_i <<= io.flush_i i_re_name.io.flush_unissied_instr_i <<= io.flush_unissued_instr_i i_re_name.io.issue_instr_i <<= io.decoded_instr_i i_re_name.io.issue_instr_valid_i <<= io.decoded_instr_valid_i io.decoded_instr_ack_o <<= i_re_name.io.issue_ack_o issue_instr_rename_sb <<= i_re_name.io.issue_instr_o issue_instr_valid_rename_sb <<= i_re_name.io.issue_instr_valid_o i_re_name.io.issue_ack_i <<= issue_ack_sb_rename i_scoreboard = scoreboard(NR_ENTRIES, NR_WB_PORTS, NR_COMMIT_PORTS) io.sb_full_o <<= i_scoreboard.io.sb_full_o i_scoreboard.io.unresolved_branch_i <<= U(0) rd_clobber_gpr_sb_iro <<= i_scoreboard.io.rd_clobber_gpr_o rd_clobber_fpr_sb_iro <<= i_scoreboard.io.rd_clobber_fpr_o i_scoreboard.io.rs1_i <<= rs1_iro_sb rs1_sb_iro <<= i_scoreboard.io.rs1_o rs1_valid_sb_iro <<= i_scoreboard.io.rs1_valid_o i_scoreboard.io.rs2_i <<= rs2_iro_sb rs2_sb_iro <<= i_scoreboard.io.rs2_o rs2_valid_iro_sb <<= i_scoreboard.io.rs2_valid_o i_scoreboard.io.rs3_i <<= rs3_iro_sb rs3_sb_iro <<= i_scoreboard.io.rs3_o rs3_valid_iro_sb <<= i_scoreboard.io.rs3_valid_o i_scoreboard.io.decoded_instr_i <<= issue_instr_rename_sb i_scoreboard.io.decoded_instr_valid_i <<= issue_instr_valid_rename_sb issue_ack_sb_rename <<= i_scoreboard.io.decoded_instr_ack_o issue_instr_sb_iro <<= i_scoreboard.io.issue_instr_o issue_instr_valid_sb_iro <<= i_scoreboard.io.issue_instr_valid_o i_scoreboard.io.issue_ack_i <<= issue_ack_iro_sb i_scoreboard.io.resolved_branch_i <<= io.resolved_branch_i i_scoreboard.io.trans_id_i <<= io.trans_id_i i_scoreboard.io.wbdata_i <<= io.wbdata_i i_scoreboard.io.ex_i <<= io.ex_ex_i i_issue_read_operands = issue_read_operands(NR_COMMIT_PORTS) i_issue_read_operands.io.flush_i <<= io.flush_unissued_instr_i i_issue_read_operands.io.issue_instr_i <<= io.issue_instr_sb_iro i_issue_read_operands.io.issue_instr_valid_i <<= issue_instr_valid_sb_iro issue_ack_iro_sb <<= i_issue_read_operands.io.issue_ack_o io.fu_data_o <<= i_issue_read_operands.io.fu_data_o i_issue_read_operands.io.flu_ready_i <<= io.flu_ready_i rs1_o <<= i_issue_read_operands.io.rs1_o i_issue_read_operands.io.rs1_i <<= io.rs1_sb_iro i_issue_read_operands.io.rs1_valid_i <<= io.rs1_valid_sb_iro rs2_iro_sb <<= i_issue_read_operands.io.rs2_o i_issue_read_operands.io.rs2_i <<= rs2_sb_iro i_issue_read_operands.io.rs2_valid_i <<= rs2_valid_iro_sb rs3_iro_sb <<= i_issue_read_operands.io.rs3_o i_issue_read_operands.io.rs3_i <<= io.rs3_sb_iro i_issue_read_operands.io.rs3_valid_i <<= rs3_valid_iro_sb i_issue_read_operands.io.rd_clobber_gpr_i <<= rd_clobber_gpr_sb_iro i_issue_read_operands.io.rd_clobber_fpr_i <<= io.rd_clobber_fpr_sb_iro alu_valid_o <<= i_issue_read_operands.io.alu_valid_o branch_valid_o <<= i_issue_read_operands.io.branch_valid_o csr_valid_o <<= i_issue_read_operands.io.csr_valid_o mult_valid_o <<= i_issue_read_operands.io.mult_valid_o
def test_functions(): print("Starting unit testing of simpleXLing.py") tests = [] #====Build Search Dict====# #Attempts to build a search dictionary for a .txt file containing Latin words (Doesn't check lemmatized text file) curr_test = test("Build latin search dictionary (XLingFunctions.py)") latin_filename = "./test_files/small_latin.txt" words_in_file = 663 language = "Latin" lemmatized_version = False tests.append(test_build_search_dict(curr_test,latin_filename, words_in_file, language, lemmatized_version )) #Attempts to build a search dictionary for a .txt file containing Greek wors (Doesn't check lemmatized text file) curr_test = test("Build greek search dictionary (XLingFunctions.py)") greek_filename = "./test_files/small_greek.txt" word_in_file = 789 language = "Greek" lemmatized_version = False tests.append(test_build_search_dict(curr_test,greek_filename, words_in_file, language, lemmatized_version)) #Builds an arbitrary translation dictionary and attempts to find translation for a valid word pair curr_test = test("Get valid translations (translate.py)") LA = word("latina", 1, 3, None) LB = word("latinb", 2, 4, None) transDict = {} latin_a_translations = ["greek1", "greek2", "greek3"] latin_b_translations = ["greek4"] transDict["latina"] = latin_a_translations transDict["latinb"] = latin_b_translations result = trn.get_translation_pair(LA,LB,transDict) if result == -1: curr_test.passed = False error_message = "Translations for two valid dictionary entries were not found" curr_test.errors.append(error_message) if not (LA.translations == latin_a_translations): curr_test.passed = False error_message = "Latina.translations doesn't match the actual translations" curr_test.errors.append(error_message) if not (LB.translations == latin_b_translations): curr_test.passed = False error_message = "Latinb.translations doesn't match the actual translations" curr_test.errors.append(error_message) tests.append(curr_test) #Attempts to find a translation for an invalid word pair curr_test = test("Get invalid translations (translate.py)") LC = word("latinc", 2, 3, None) result = trn.get_translation_pair(LA,LC,transDict) if not (result == -1): curr_test.passed = False error_message = "Translations for two valid dictionary entries were not found" curr_test.errors.append(error_message) if not (LA.translations == latin_a_translations): curr_test.passed = False error_message = "Latin_a.translations doesn't match the actual translations" curr_test.errors.append(error_message) if not (LC.translations == None): curr_test.passed = False error_message = "Latin_c. shouldn't have any translations" curr_test.errors.append(error_message) tests.append(curr_test) #Search for a translation of a pair of latin words in a greek search dictionary curr_test = test("Get Greek translation pair (XLingFunctions.py)") L1_translation = "greek1" L2_translation = "greek2" G_search_dict = { 'greek1' : [1,3], 'greek2' : [2] } G1, G2 = xls.get_GreekPair(L1_translation, L2_translation, G_search_dict) if not (G1 == [1,3]): curr_test.passed = False curr_test.errors.append("Translation array (array of indices in greek text where translation of latin word appear) is incorrect") if not (G2 == [2]): curr_test.passed = False curr_test.errors.append("Translation array (array of indices in greek text where translation of latin word appear) is incorrect") tests.append(curr_test) #Search for a translation of a pair of latin words in a greek search dictionary (when translations aren't in dictionary) curr_test = test("Get Greek translation pair with incomplete search dict (XLingFunctions.py)") L3_translation = "greek3" G1, G3 = xls.get_GreekPair(L1_translation, L3_translation, G_search_dict) if not (G1 == None): curr_test.passed = False curr_test.errors.append("Translation array (array of indices in greek text where translation of latin word appear) is incorrect") if not (G3 == None): curr_test.passed = False curr_test.errors.append("Translation array (array of indices in greek text where translation of latin word appear) is incorrect") tests.append(curr_test) #Get latin word stats curr_test = test("Get Latin word stats (XLingFunctions.py)") latin_text = ['L1', 'L2', 'L1', 'L1', 'L2', 'L3','L4', 'L5', 'L5', 'L5'] latin_search_dict = { 'L1' : [0,2,3], 'L2' : [1,4], 'L3' : [5], 'L4' : [6], 'L5': [7,8,9]} i = 3 j = 4 L1, L2 = xls.get_LatinWordStats(latin_text,latin_search_dict, i, j) if not ( L1.word == "L1"): curr_test.passed = False curr_test.errors.append("Latin word object #1 corresponds to the wrong word (" + str(L1.word) + ")") if not (L1.pos == 3): curr_test.passed = False curr_test.errors.append("Latin word object #1 corresponds to the wrong position in text (" + str(L1.pos) + ")") if not (L1.occurences == 3): curr_test.passed = False curr_test.errors.append("Latin word object #1 should occur 3 times, only occurs" + str(L1.occurences) + " times") if not ( L2.word == "L5"): curr_test.passed = False curr_test.errors.append("Latin word object #2 corresponds to the wrong word (" + str(L2.word) + ")" ) if not (L2.pos == 7): curr_test.passed = False curr_test.errors.append("Latin word object #2 corresponds to the wrong position in text (" + str(L2.pos) + ")" ) if not (L2.occurences == 3): curr_test.passed = False curr_test.errors.append("Latin word object #2 should occur 3 times, only occurs" + str(L2.occurences) + " times") tests.append(curr_test) #Find match pair test (three possible matches in greek test, should take the match with the two words side by side) Uses same L1,L2, Latin text, and latin text as above curr_test = test("Find match pair given three matches in the greek corpus (XLingFunctions.py") L1_translation = "g1" L2_translation = "g2" Greek_text = [ "g1", "x", "x", "g2", "g1", "x", "g2", "x", "x", "x", "g1" ] Greek_search_dict = {"g1": [0,4,10], "g2": [ 3,6], "x": [1,2,5,7,8,9]} bestMatch = xls.find_match_pair(L1, L2, L1_translation, L2_translation, Greek_search_dict, latin_text, len(latin_text), Greek_text, len(Greek_text), None) if not bestMatch: curr_test.passed = False curr_test.errors.append("No match was found") elif not (bestMatch.G1_pos == 4) or not(bestMatch.G2_pos == 3): curr_test.passed = False curr_test.errors.append("The best match did not occur in the expected position ( G1 = " +str(bestMatch.G1_pos) + " G2 = " + str(bestMatch.G2_pos) ) tests.append(curr_test) #Ensures that try_all_search_combos produces all combos of position indicies curr_test = test("Try all search combos (finds best match in a greek text given a search prhase)") search = search_phrase("L1 L2 L3", "Latin") search.has_translation = [1, 1, 1] search.text[0].translations = ["g1", "g4", "g3" ] search.text[1].translations = ["g6"] search.text[2].translations = ["g5", "g2"] score = scoreboard(1) xls.try_all_search_combos( search, score, len(Greek_text), Greek_search_dict, Greek_text) if not ( score.matches[0].G1_pos == 4 and score.matches[0].G2_pos == 3): curr_test.passed = False curr_test.errors.append("The wrong top match was found for the search") tests.append(curr_test) return tests