def button(text): colour = '' word = '' for w in words: if w in text: word = w for c in colours: if c in text: colour = c if '' == colour or '' == word: speak('Not a button') return if BombSetup.batts > 1 and word == 'detonate': speak("Press the Button") elif BombSetup.batts > 2 and BombSetup.frk: speak("Press the Button") elif colour == 'red' and word == 'hold': speak("Press the Button") else: speak("Hold the Button")
def bomb_status(): speak(f'Batteries {batts}...' f' Vowel {vowel}...' f' Even {even}...' f' Port {parallelport}...' f' Freak {frk}...' f' Car {car}...' f'Strikes {strikes}')
def batteries(text): global batts text = text.replace('zero', '0').replace('one', '1').replace('two', '2').replace('to', '2').replace('too', '2') \ .replace('three', '3').replace('four', '4').replace('five', '5').replace('six', '6').replace('for', '4') try: batts = int(text) except ValueError: speak("Try batteries again")
def keypad(text): symbols = text.lower() groups = [[ 'balloon', 'alpha', 'alfa', 'lambda', 'lightning', 'kitty', 'h', 'hotel', 'charlie' ], [ 'euro', 'balloon', 'charlie', 'cursive', 'star', 'h', 'hotel', 'question' ], [ 'copyright', 'nose', 'knows', 'cursive', 'butterfly', ';', 'lambda', 'star' ], [ 'six', '6', 'paragraph', 'b', 'bravo', 'kitty', 'butterfly', 'question', 'smile', 'smiley' ], [ 'trident', 'smile', 'smiley', 'b', 'bravo', 'c', 'charlie', 'paragraph', 'three', '3', 'star' ], [ 'six', '6', 'euro', 'puzzle', 'smash', 'trident', 'november', 'omega' ]] curr_symbols = symbols.replace('.', '').replace(';', ' ;').split() for group in groups: for symbol in curr_symbols: if symbol not in group: break else: for symbol in group: if symbol in curr_symbols: answer.append(symbol) janswer = ' '.join([str(elem) for elem in answer]) janswer = janswer.replace(';', 'semicolon') try: speak(janswer) except AssertionError: speak('A symbol does not exist') return return
def onfirst(text): word = text.lower() answer_dict = { 'empty': 'Bottom Left', 'blank': 'Middle Right', 'charlie': 'Top Right', 'cc': 'Bottom Right', 'display': 'Bottom Right', 'first': 'Top Right', '1st': 'Top Right', 'hold on': 'Bottom Right', 'lead': 'Bottom Right', 'led': 'Middle Left', 'lead to': 'Bottom Left', 'no': 'Bottom Right', 'nothing': 'Middle Left', 'okay': 'Top Right', 'read': 'Middle Right', 'red': 'Middle Right', 'read to': 'Bottom Left', 'says': 'Bottom Right', 'c': 'Bottom Right', 'see': 'Bottom Right', 'their india': 'Middle Right', 'there india': 'Middle Right', 'there': 'Bottom Right', 'they are apostrophe': 'Bottom Left', 'they are': 'Middle Left', 'you are letters': 'Top Left', 'yes': 'Middle Left', 'you': 'Middle Right', 'your': 'Middle Right', 'you are': 'Bottom Right', 'you are apostrophe': 'Middle Right', } if word in answer_dict: answer = answer_dict[word] else: speak('That is not a word') return False speak(answer) return True
def knobs(posask): answer = 'not a knob' pos = posask.replace(' ', '').replace('three', '3').replace('six', '6').replace('five', '5').replace('two', '2')\ .replace('to', '2').replace('too', '2').replace('one', '1').replace('-', '') if pos == '36' or pos == '35': answer = 'UP' elif pos == '236' or pos == '0': answer = 'Down' elif pos == '5': answer = 'Left' elif pos == '135' or pos == '13': answer = 'Right' speak(answer)
def sequence(text): global sequences global redc global bluec global blackc wireask = text.lower() if 'stop' not in wireask: wireask = wireask.replace('alpha', 'a').replace('bravo', 'b').replace('charlie', 'c').replace('read', 'red') wires = wireask.split(' next ') answer = [] for index, item in enumerate(wires): item = item.split(' ') try: color, letter = item except ValueError: speak('Say Next in Between Wires') return if letter in sequences[str('red')][redc] and color == 'red': answer.append('Yes,') elif letter in sequences[str('blue')][bluec] and color == 'blue': answer.append('Yes,') elif letter in sequences[str('black')][blackc] and color == 'black': answer.append('Yes,') else: answer.append("No,") if color == 'red': redc += 1 elif color == 'blue': bluec += 1 else: blackc += 1 janswer = ' '.join([str(elem) for elem in answer]) speak(janswer)
def simon(text): flash = text.replace('blue', 'b').replace('red', 'r').replace('yellow', 'y').replace('green', 'g') if BombSetup.vowel: if BombSetup.strikes == 0: flash = flash.replace('r', "BLUE ") flash = flash.replace('b', "RED ") flash = flash.replace('g', "YELLOW ") flash = flash.replace('y', "GREEN ") elif BombSetup.strikes == 1: flash = flash.replace('r', "YELLOW ") flash = flash.replace('b', "GREEN ") flash = flash.replace('g', "BLUE ") flash = flash.replace('y', "RED ") else: flash = flash.replace('r', "GREEN ") flash = flash.replace('b', "RED ") flash = flash.replace('g', "YELLOW ") flash = flash.replace('y', "BLUE ") else: if BombSetup.strikes == 0: flash = flash.replace('r', "BLUE ") flash = flash.replace('b', "YELLOW ") flash = flash.replace('g', "GREEN ") flash = flash.replace('y', "RED ") elif BombSetup.strikes == 1: flash = flash.replace('r', "RED ") flash = flash.replace('b', "BLUE ") flash = flash.replace('g', "YELLOW ") flash = flash.replace('y', "GREEN ") else: flash = flash.replace('r', "YELLOW ") flash = flash.replace('b', "GREEN ") flash = flash.replace('g', "BLUE ") flash = flash.replace('y', "RED ") speak(flash)
def mazetranslate(): global answer mzsolution = msolution last = mzsolution[0] mzsolution.remove(str(last)) for character in mzsolution: if last[0] < character[0]: answer.append('right,') elif last[0] > character[0]: answer.append('left,') elif last[1] < character[1]: answer.append('down,') else: answer.append('up,') last = character janswer = ' '.join([str(elem) for elem in answer]) speak(janswer) print(janswer)
def holdbutton(text): text = text.lower() if 'blue' in text: speak('4') elif 'yellow' in text: speak('5') else: speak('1')
def bfs_shortest_path(smaze, start, goal): # keep track of explored nodes explored = [] # keep track of all the paths to be checked queue = [[start]] # return path if start is goal if start == goal: speak("That was easy! Start = goal") # keeps looping until all possible paths have been checked while queue: # pop the first path from the queue path = queue.pop(0) # get the last node from the path node = path[-1] if node not in explored: neighbours = smaze[node] # go through all neighbour nodes, construct a new path and # push it into the queue for neighbour in neighbours: new_path = list(path) new_path.append(neighbour) queue.append(new_path) # return path if neighbour is goal if neighbour == goal: global msolution # print(new_path) msolution = new_path return new_path # mark node as explored explored.append(node) # in case there's no path between the 2 nodes speak("A connecting path doesn't exist") return
def password(text): curr_password = [] crow1 = [] crow3 = [] txt = text.lower() text = txt.split(' next ') try: row1 = text[0].split() row3 = text[1].split() except IndexError: speak('Say Next in between rows') return for word in row1: lrow = word.replace(word, word[0]) crow1.append(lrow) letters = ' '.join([str(elem) for elem in crow1]) curr_password.append(letters) for word in row3: lrow = word.replace(word, word[0]) crow3.append(lrow) letters = ' '.join([str(elem) for elem in crow3]) curr_password.append(letters) passwords = [ 'about', 'after', 'again', 'below', 'could', 'every', 'first', 'found', 'great', 'house', 'large', 'learn', 'never', 'other', 'place', 'plant', 'point', 'right', 'small', 'sound', 'spell', 'still', 'study', 'their', 'there', 'these', 'thing', 'think', 'three', 'water', 'where', 'which', 'world', 'would', 'write' ] posibles = [] for password in passwords: if password[0] in curr_password[0] and password[2] in curr_password[1]: posibles.append(password) janswer = ' '.join([str(elem) for elem in posibles]) if janswer.strip() == '': speak('No Possible answers') return speak(janswer)
def addstrike(): global strikes strikes += 1 speak(f'Strike Added, {strikes} total')
def morse(text): global morse_letters text = text.replace(' ', '').replace('-', '') code = text.replace('one', '-').replace('zero', '.').replace('1', '-').replace('0', '.').replace(':', '') morseg = { 'a': '.-', 'b': '-...', 'c': '-.-.', 'e': '.', 'f': '..-.', 'g': '--.', 'h': '....', 'i': '..', 'k': '-.-', 'l': '.-..', 'm': '--', 'n': '-.', 'o': '---', 'r': '.-.', 's': '...', 't': '-', 'v': '...-', 'x': '-..-', } codes = {} for key, val in morseg.items(): if code == val: morse_letters.append(key) codes[val] = key try: print(str(morse_letters)) except AssertionError: speak('That is not a letter') return if len(morse_letters) < 2: return words = { 'shell 5 0 5', 'halls 5 1 5', 'slick 5 2 2', 'trick 5 3 2', 'boxes 5 3 5', 'leaks 5 4 2', 'strobe 5 4 5', 'bistro 5 5 2', 'flick 5 5 5', 'bombs 5 6 5', 'break 5 7 2', 'brick 5 7 5', 'steak 5 8 2', 'sting 5 9 2', 'vector 5 9 5', 'beats 6 0 0', } posibles = [] for word in words: for letter in morse_letters: if letter in word: if word not in posibles: posibles.append(word) else: if word in posibles: posibles.remove(word) break if len(posibles) == 1: janswer = ' '.join([str(elem) for elem in posibles]) speak(janswer) else: speak('Not enough letters') return
def total_reset(): Morse.resetmorse() WireSequence.resetsequence() Morse.resetmorse() BombSetup.resetsetup() speak('Bomb Reset')
or "on first 2" in text.replace('to', '2').replace('too', '2').replace('two', '2'): text = text.replace('to', '2').replace('too', '2').replace('two', '2') text = text.replace("on 1st 2 ", '').replace("on first 2 ", '') answer = OnFirst.onfirstwords(text) if answer != "Not a Word": p = multiprocessing.Process(target=speak, args=(answer, )) p.start() while p.is_alive(): listen = get_audio() if listen == 'stop': p.terminate() else: speak(answer) elif 'reset memory' in text: Memory.resetmemstage() speak('Memory reset') elif 'memory' in text: # Number on screen, then buttons text = text.replace('to', '2').replace('too', '2').replace('two', '2')\ .replace('for ', '4').replace('memory ', '').replace('at', '').replace('-', '')\ .replace('0', '').replace(' ', '') Memory.memory(text) elif 'reset morse' in text: Morse.resetmorse() speak('Morse reset')
def simplewires(text): colors = text.replace('read', 'red') scolors = (colors.split(' ')) wires = str(len(scolors)) if wires == '3': w3 = scolors[2] if colors.count('red') == 0: speak("Second Wire") elif w3 == 'white': speak("Last Wire") elif colors.count('u') > 1: speak("Last Blue Wire") else: speak("Last Wire") elif wires == '4': w4 = scolors[3] if colors.count('red') > 1 and not BombSetup.even: speak('last red wire') elif w4 == 'yellow' and colors.count('red') == 0: speak("Cut First Wire") elif colors.count('blue') == 1: speak('First Wire') elif colors.count('yellow') > 1: speak('Last Wire') else: speak('Second Wire') elif wires == '5': w5 = scolors[4] if w5 == 'black' and not BombSetup.even: speak('Fourth Wire') elif colors.count('red') == 1 and colors.count('yellow') > 1: speak('First Wire') elif colors.count('black') == 0: speak('Second Wire') else: speak('First Wire') elif wires == '6': if colors.count('yellow') == 0 and not BombSetup.even: speak('Third wire') elif colors.count('yellow') == 1 and colors.count('white') > 1: speak('Fourth Wire') elif colors.count('red') == 0: speak('Last Wire') else: speak('Fourth Wire') elif wires == '7': speak('Too many wires') elif wires <= '2': speak('Not enough wires')
data = np.array(encode) strData = data.tostring() #Send Image client_sock.send(str(len(strData)).ljust(16).encode()) #b'len' client_sock.send(strData) # Waiting for Result try: msg = client_sock.recv(SIZE) word += msg.decode() except Exception as e: _ = 0 cv.putText(zero, word, font_location, font, fontscale, WHITE, 5) elif key == ord('a'): speak(word) elif key == ord('s'): #erase word = word[:-1] elif key == ord('d'): #RESET word = "" zero = np.zeros((display_height, display_width), dtype=np.uint8) elif key == 27: client_sock.send(end_msg.encode()) break client_sock.close() cap.release() cv.destroyAllWindows()
def maze(info): a_maze = { '11': ['21', '12'], '21': ['11', '31'], '31': ['21', '32'], '41': ['42', '51'], '51': ['41', '61'], '61': ['51'], '12': ['11', '13'], '22': ['32', '23'], '32': ['22', '31'], '42': ['41', '52'], '52': ['42', '62'], '62': ['52', '63'], '13': ['12', '14'], '23': ['22', '33'], '33': ['23', '34'], '43': ['44', '53'], '53': ['43', '63'], '63': ['53', '62', '64'], '14': ['13', '15'], '24': ['34'], '34': ['24', '33', '44'], '44': ['34', '43'], '54': ['64'], '64': ['54', '63', '65'], '15': ['14', '25', '16'], '25': ['15', '35'], '35': ['25', '36'], '45': ['46', '55'], '55': ['45'], '65': ['64', '66'], '16': ['15', '26'], '26': ['16'], '36': ['35', '46'], '46': ['36', '45'], '56': ['66'], '66': ['56', '65'] # 11 21 31 | 41 51 61 # -- ----- # 12 |22 32 | 42 52 62 # ----------- # 13 |23 33 | 43 53 63 # -- -- # 14 |24 34 44 |54 64 # --------------- # 15 25 35 | 45 55 |65 # -- ---| # 16 26 |36 46 |56 66 } b_maze = { '11': ['21'], '21': ['11', '31', '22'], '31': ['21'], '41': ['42', '51'], '51': ['41', '61', '52'], '61': ['51'], '12': ['22', '13'], '22': ['12', '21'], '32': ['33', '42'], '42': ['41', '32'], '52': ['51', '62'], '62': ['52', '63'], '13': ['12', '14'], '23': ['24', '33'], '33': ['23', '32'], '43': ['44', '53'], '53': ['43', '63'], '63': ['53', '62', '64'], '14': ['13', '15', '24'], '24': ['14', '23'], '34': ['35', '44'], '44': ['34', '43'], '54': ['55'], '64': ['63', '65'], '15': ['14', '16'], '25': ['26'], '35': ['34', '36'], '45': ['46', '55'], '55': ['45', '54'], '65': ['64', '66'], '16': ['15'], '26': ['25', '36'], '36': ['35', '26'], '46': ['56', '45'], '56': ['66', '46'], '66': ['56', '65'] } c_maze = { '11': ['21', '12'], '21': ['11', '31'], '31': ['21', '32'], '41': ['42'], '51': ['61', '52'], '61': ['51', '62'], '12': ['11'], '22': ['23'], '32': ['33', '31'], '42': ['41', '52'], '52': ['51', '42'], '62': ['61', '63'], '13': ['23', '14'], '23': ['24', '21', '13'], '33': ['34', '32'], '43': ['44', '53'], '53': ['43', '54'], '63': ['62', '64'], '14': ['13', '15'], '24': ['25', '23'], '34': ['35', '33'], '44': ['45', '43'], '54': ['55', '53'], '64': ['63', '65'], '15': ['14', '16'], '25': ['24', '35'], '35': ['34', '25'], '45': ['46', '44'], '55': ['56', '54'], '65': ['64', '66'], '16': ['15', '26'], '26': ['16', '36'], '36': ['46', '26'], '46': ['36', '45'], '56': ['66', '54'], '66': ['56', '65'] } d_maze = { '11': ['21', '12'], '21': ['11', '22'], '31': ['41'], '41': ['31', '51'], '51': ['61', '41'], '61': ['51', '62'], '12': ['11', '13'], '22': ['23', '21'], '32': ['33', '42'], '42': ['32', '52'], '52': ['62', '42'], '62': ['61', '63', '52'], '13': ['12', '14'], '23': ['22', '33'], '33': ['23', '32'], '43': ['44', '53'], '53': ['43'], '63': ['62', '64'], '14': ['13', '15'], '24': ['34'], '34': ['24', '44'], '44': ['34', '43', '54'], '54': ['44', '34'], '64': ['63', '65', '54'], '15': ['14', '16', '25'], '25': ['15', '35'], '35': ['45', '25'], '45': ['35', '55'], '55': ['56', '45'], '65': ['64', '66'], '16': ['15', '26'], '26': ['16', '36'], '36': ['26'], '46': ['56'], '56': ['46', '55'], '66': ['65'] } e_maze = { '11': ['21'], '21': ['11', '31'], '31': ['41', '21'], '41': ['31', '51'], '51': ['61', '41', '52'], '61': ['51', '62'], '12': ['22', '13'], '22': ['12', '32'], '32': ['22', '42'], '42': ['32', '52', '43'], '52': ['51', '42'], '62': ['61'], '13': ['12', '14', '23'], '23': ['13', '24'], '33': ['43'], '43': ['33', '42'], '53': ['63', '54'], '63': ['53', '64'], '14': ['13', '15'], '24': ['34', '23'], '34': ['24', '44'], '44': ['34', '45'], '54': ['53'], '64': ['63', '65'], '15': ['14', '16'], '25': ['26', '35'], '35': ['45', '25'], '45': ['35', '55', '44'], '55': ['45'], '65': ['64', '66'], '16': ['15'], '26': ['25', '36'], '36': ['26', '46'], '46': ['56', '36'], '56': ['46', '66'], '66': ['65', '56'] } f_maze = { '11': ['12'], '21': ['22', '31'], '31': ['32', '21'], '41': ['51'], '51': ['61', '41', '52'], '61': ['51', '62'], '12': ['11', '13'], '22': ['21', '23'], '32': ['31', '33'], '42': ['52', '43'], '52': ['51', '42'], '62': ['61', '63'], '13': ['12', '14', '23'], '23': ['13', '22'], '33': ['32'], '43': ['44', '42'], '53': ['63', '54'], '63': ['53', '62'], '14': ['13', '24'], '24': ['14', '25'], '34': ['35', '44'], '44': ['34', '45', '43'], '54': ['53', '55'], '64': ['65'], '15': ['25', '16'], '25': ['24', '15'], '35': ['34'], '45': ['46', '44'], '55': ['54', '65'], '65': ['64', '66', '55'], '16': ['15', '26'], '26': ['16', '36'], '36': ['26', '46'], '46': ['45', '36'], '56': ['66'], '66': ['65', '56'] } g_maze = { '11': ['12', '21'], '21': ['11', '31'], '31': ['41', '21'], '41': ['31', '42'], '51': ['61', '52'], '61': ['51', '62'], '12': ['11', '13'], '22': ['32', '23'], '32': ['22'], '42': ['52', '41'], '52': ['51', '42'], '62': ['61', '63'], '13': ['12', '23'], '23': ['13', '22'], '33': ['34', '43'], '43': ['33'], '53': ['63', '54'], '63': ['53', '62'], '14': ['15', '24'], '24': ['14', '25'], '34': ['35', '44', '33'], '44': ['34', '54'], '54': ['53', '44'], '64': ['65'], '15': ['14', '16'], '25': ['24'], '35': ['34', '45'], '45': ['35', '55'], '55': ['45', '56'], '65': ['64', '66'], '16': ['15', '26'], '26': ['16', '36'], '36': ['26', '46'], '46': ['56', '36'], '56': ['66', '46', '55'], '66': ['65', '56'] } h_maze = { '11': ['12'], '21': ['22', '31'], '31': ['41', '21'], '41': ['31', '42'], '51': ['61', '52'], '61': ['51', '62'], '12': ['11', '13', '22'], '22': ['32', '21', '12'], '32': ['22'], '42': ['52', '41'], '52': ['51', '42'], '62': ['61', '63'], '13': ['12', '14'], '23': ['24', '33'], '33': ['23', '43'], '43': ['33', '53'], '53': ['43', '54'], '63': ['64', '62'], '14': ['15', '16'], '24': ['23', '34'], '34': ['35', '24'], '44': ['54'], '54': ['52', '44', '64'], '64': ['63', '54'], '15': ['14', '16'], '25': ['26'], '35': ['34', '45'], '45': ['35', '55'], '55': ['45', '56'], '65': ['55'], '16': ['15', '26'], '26': ['16', '36', '25'], '36': ['26', '46'], '46': ['56', '36'], '56': ['66', '46'], '66': ['56'] } i_maze = { '11': ['12'], '21': ['22', '31'], '31': ['41', '21'], '41': ['31', '42'], '51': ['61', '52', '41'], '61': ['51', '62'], '12': ['11', '13'], '22': ['23', '21'], '32': ['42', '33'], '42': ['32'], '52': ['51', '53'], '62': ['61', '63'], '13': ['12', '14', '23'], '23': ['22', '33', '13'], '33': ['23', '32'], '43': ['44', '53'], '53': ['43', '52'], '63': ['64', '62'], '14': ['15', '16'], '24': ['25'], '34': ['35', '44'], '44': ['43', '34'], '54': ['64'], '64': ['63', '54', '65'], '15': ['14', '16'], '25': ['26', '24'], '35': ['34', '36'], '45': ['46', '55'], '55': ['45', '56'], '65': ['64'], '16': ['15', '26'], '26': ['16', '25'], '36': ['35', '46'], '46': ['56', '45'], '56': ['66', '55'], '66': ['56'] } info = info.replace(' ', '').replace('-', '') sinfo = info.split("next") ssinfo = [] for word in sinfo: word = word.replace('to', '2').replace('three', '3').replace('four', '4').replace('for', '4')\ .replace('five', '5').replace('six', '6').replace('two', '2').replace('one', '1').replace('0', '')\ .replace('zero', '') ssinfo.append(word) try: fmaze, player, finish = ssinfo except ValueError: speak('Not enough coordinates') return if fmaze == '12' or fmaze == '63': maze = a_maze elif fmaze == '24' or fmaze == '52': maze = b_maze elif fmaze == '44' or fmaze == '64': maze = c_maze elif fmaze == '11' or fmaze == '14': maze = d_maze elif fmaze == '53' or fmaze == '46': maze = e_maze elif fmaze == '51' or fmaze == '35': maze = f_maze elif fmaze == '21' or fmaze == '26': maze = g_maze elif fmaze == '41' or fmaze == '34': maze = h_maze elif fmaze == '32' or fmaze == '15': maze = i_maze else: speak('That is Not a Maze') return # finds shortest path between 2 nodes of a graph using BFS def bfs_shortest_path(smaze, start, goal): # keep track of explored nodes explored = [] # keep track of all the paths to be checked queue = [[start]] # return path if start is goal if start == goal: speak("That was easy! Start = goal") # keeps looping until all possible paths have been checked while queue: # pop the first path from the queue path = queue.pop(0) # get the last node from the path node = path[-1] if node not in explored: neighbours = smaze[node] # go through all neighbour nodes, construct a new path and # push it into the queue for neighbour in neighbours: new_path = list(path) new_path.append(neighbour) queue.append(new_path) # return path if neighbour is goal if neighbour == goal: global msolution # print(new_path) msolution = new_path return new_path # mark node as explored explored.append(node) # in case there's no path between the 2 nodes speak("A connecting path doesn't exist") return try: bfs_shortest_path(maze, player, finish) mazetranslate() except UnboundLocalError: return
def removestrike(): global strikes strikes -= 1 speak(f'Strike Removed, {strikes} total')
def compwires(text): wires = text.split(' next ') print(wires) for wire in wires: wire = wire.lower() if 'red' in wire: red = True else: red = False if 'blue' in wire: blue = True else: blue = False if 'star' in wire: star = True else: star = False if 'light' in wire: led = True else: led = False # Just Cut if red and not blue and star and not led: answer.append('Yes, ') elif not red and not blue and star and not led: answer.append('Yes, ') elif not red and not blue and not star and not led: answer.append('Yes, ') # Cut if Serial is Even elif (red and blue and not star and led) and BombSetup.even: answer.append('Yes, ') elif (red and blue and not star and not led) and BombSetup.even: answer.append('Yes, ') elif (red and not blue and not star and not led) and BombSetup.even: answer.append('Yes, ') elif (not red and blue and not star and not led) and BombSetup.even: answer.append('Yes, ') # Cut if Parallel Port elif (red and blue and star and not led) and BombSetup.parallelport: answer.append('Yes, ') elif (not red and blue and star and led) and BombSetup.parallelport: answer.append('Yes, ') elif (not red and blue and not star and led) and BombSetup.parallelport: answer.append('Yes, ') # Cut if Bomb has 2 or More Batteries elif (red and not blue and star and led) and (BombSetup.batts > 1): answer.append('Yes, ') elif (red and not blue and not star and led) and (BombSetup.batts > 1): answer.append('Yes, ') elif (not red and not blue and star and led) and (BombSetup.batts > 1): answer.append('Yes, ') else: answer.append("No") janswer = ' '.join([str(elem) for elem in answer]) speak(janswer)
def memory(s): screen = [] for i in s: screen.append(i) global stage global sonepos global sonelabel global stwopos global stwolabel global sthreepos global sthreelabel global sfourpos global sfourlabel if not len(screen) == 5: speak('Not enough numbers') return else: if stage == 1: if int(screen[0]) == 1: speak('Position 2') sonepos = 2 sonelabel = screen[sonepos] # 2 elif int(screen[0]) == 2: speak('Position 2') sonepos = 2 sonelabel = screen[sonepos] elif int(screen[0]) == 3: speak('Position 3') sonepos = 3 sonelabel = screen[sonepos] else: speak('Position 4') sonepos = 4 sonelabel = screen[sonepos] elif stage == 2: if int(screen[0]) == 1: speak('Labeled "4"') stwopos = str(screen.index('4')) # 4 stwolabel = 4 elif int(screen[0]) == 2: speak('Position ' + str(sonepos)) stwopos = sonepos stwolabel = screen[stwopos] elif int(screen[0]) == 3: speak('Position 1') stwopos = 1 stwolabel = screen[stwopos] else: speak('Position ' + str(sonepos)) stwopos = sonepos stwolabel = screen[stwopos] elif stage == 3: if int(screen[0]) == 1: speak(f'Labeled "{stwolabel}"') sthreepos = str(screen.index(str(stwolabel))) sthreelabel = stwolabel elif int(screen[0]) == 2: speak(f'Labeled "{sonelabel}"') sthreepos = str(screen.index(str(sonelabel))) sthreelabel = sonelabel elif int(screen[0]) == 3: speak('Position 3') sthreepos = 3 sthreelabel = screen[sthreepos] else: speak('Labeled "4"') sthreepos = str(screen.index('4')) sthreelabel = 4 elif stage == 4: if int(screen[0]) == 1: speak(f'position {sonepos}') sfourpos = sonepos sfourlabel = screen[sfourpos] elif int(screen[0]) == 2: speak(f'Position 1') sfourpos = 1 sfourlabel = screen[sfourpos] elif int(screen[0]) == 3: speak(f'Position {stwopos}') sfourpos = stwopos sfourlabel = screen[sfourpos] else: speak(f'Position {stwopos}') sfourpos = stwopos sfourlabel = screen[int(sfourpos)] else: if int(screen[0]) == 1: speak(f'Labeled "{sonelabel}"') elif int(screen[0]) == 2: speak(f'Labeled "{stwolabel}"') elif int(screen[0]) == 3: speak(f'Labeled "{sfourlabel}"') else: speak(f'Labeled "{sthreelabel}"') stage += 1