def expand(self,clist): temp_q = [] # temporary q for storing the bunh of nodes (~20) expanded from this node board = np.copy(self.b) for i in range(4): for j in range(4): if board[i,j] : new_node = self.hor([i,j],'pos') if new_node != 0 and not repeat_check(new_node, clist): temp_q.append(new_node) disp(new_node) new_node = self.hor([i,j],'neg') if new_node != 0 and not repeat_check(new_node, clist): temp_q.append(new_node) disp(new_node) new_node = self.ver([i,j],'pos') if new_node != 0 and not repeat_check(new_node, clist): temp_q.append(new_node) disp(new_node) new_node = self.ver([i,j],'neg') if new_node != 0 and not repeat_check(new_node, clist): temp_q.append(new_node) disp(new_node) return temp_q
def compConvert(fileLocn): fp = open(fileLocn, 'r') # format Label@CMD@ARG1,ARG2,ARG3................... code = [] fp.seek(0) for x in fp: code.append(x.strip()) pseudoType = ['START', 'USING', 'EQU', 'END'] rrType = ['BALR', 'BR', 'SR', 'AR', 'LR'] rxType = ['L', 'A', 'ST', 'CLI', 'BNE', 'DS', 'DC', 'LA', 'C'] codeModified = [x.split('@') for x in code] litTab = [] relLocn = relocator.relLocationCalc(codeModified, pseudoType, rrType, rxType, litTab) symTab = tableGenerator.symbolTable(relLocn, pseudoType, rrType, rxType) bTab = tableGenerator.baseTable(relLocn, symTab) machTab = machineInstructions.machInstn(relLocn, symTab, bTab, litTab, pseudoType, rrType, rxType) display.disp(relLocn, symTab, litTab, bTab, machTab)
def coach( music, mode ): # Decides of the following events according to the difficulties of the player if mode == 'basic': # Just waits for the player to press the right keys in order to generate the animation of the next 2 seconds fsampling, Notes = read_file.read_tlp(music) tau = 1 / fsampling t = 0 for sample in Notes: # Pause of a tau length t += tau display.disp(sample) error = error.get( ) # We check if the player has made an error or not else: print("Unavailable function at the moment") return exit_flag # The player needs to be able to quit the software at any moment
def coach( music, mode, ref_table ): # Decides of the following events according to the difficulties of the player if mode == 'basic': # Just waits for the player to press the right keys in order to generate the animation of the next 2 seconds fsampling, Notes = read_file.read_tlp(music) for sample in Notes: display.disp( Notes[sample], fsampling ) # The current structure of dis does not allow this contruction... error = error.get_error() elif mode == 'none': # Just displays the notes, regardless of the player's performance Notes, fsampling = read_file.read(music) display.disp(Notes, fsampling, 100, ref_table) else: print("Unavailable function at the moment") return exit_flag # The player needs to be able to quit the software at any moment
open_q = [] # the q of nodes which need to be exanded open_q.append(p_start) # adding the root node while open_q: exp_node = open_q[0] open_q.remove(open_q[0]) closed_list.append(exp_node) print 'expanding state', exp_node.indx # disp(exp_node) new_nodes_list = exp_node.expand(closed_list) check = goal_check(new_nodes_list, [2, 2]) if check != 0: print 'found goal' plan = plan + backtrack(new_nodes_list[check], closed_list) break else: open_q = open_q + new_nodes_list # printing the plan if len(plan) != 0: for i in range(len(plan)): disp(plan[-(i + 1)]) print '=============' print 'the length of the plan is ', len(plan) else: print 'no plan exist' print(len(closed_list)) print len(open_q) raw_input('press enter to solve next game') state_node.total_node = 0
from count import counter from timer import allot from display import disp #Getting count values of each road r1_count = counter("assets/video1.mp4", "Road 1") r2_count = counter("assets/video2.mp4", "Road 2") r3_count = counter("assets/video3.mp4", "Road 3") r4_count = counter("assets/video4.mp4", "Road 4") # Getting time allotment for each road r1_time = allot(r1_count) r2_time = allot(r2_count) r3_time = allot(r3_count) r4_time = allot(r4_count) # disp() disp(r1_time, r2_time, r3_time, r4_time)