def talkStarterRivalFight(data): worldText( data, data.rival.name + ': Where are you running off to?! Now that we\'ve both got Pokemon', data.player.name + ', let\'s fight and see who\'s best!') data.enemy = data.rival outcome = startBattle(data) if outcome == 'Win': text(data, data.rival.name + ': Yeah, okay, beginner\'s luck.') worldText( data, data.rival.name + ': Next time I won\'t go so easy on you. Anyway, smell ya later!') else: text(data, data.rival.name + ': Just as I expected, easy.') worldText( data, data.rival.name + ': Better luck next time. Anyway, smell ya later!') data.story.starterRivalFightCompleted = True worldText( data, 'Oak: In any case', data.player.name + ", great effort! Let me heal your " + data.player.pokemon.name + " up.") healPokemon(data.player.pokemon) worldText( data, "Here, take 5 PokeBalls and go and start your Pokemon adventure!") worldText(data, '> Congratulations, you received 5 PokeBalls!')
def useItem(data, item, battle): if item.type == "Healing": selectionText = "Which Pokemon would you like to use " + item.name + " on?" while True: pokemon = openPokemonSelectionScreen(data, battle=battle, selectionText=selectionText, useOrGiveItem=True) if pokemon == "Back": return False else: healed = healPokemon(data, pokemon, item, battle) if healed == True: removeItemFromBag(data, item, 1) return else: selectionText = "This would have no effect on " + pokemon.name + "! Choose another Pokemon!" if item.type == "Ball": removeItemFromBag(data, item, 1) text(data, 'You throw the', item.name, 'at the opposing', data.enemy.pokemon.name + '!') if data.enemy.type != 'Wild': text(data, 'The', data.enemy.type, data.enemy.name, 'swatted the ball away! You can\'t use that here!') return 'No Catch' else: catch = getCatch(data, item) if catch == 1: return 1 else: return catch pass
def Update(self): pos = 0 specialfrogs = 0 for x in self.entities: x.Update() if x.dead == True: del self.entities[pos] pos += 1 if hasattr(x, 'special') and x.special == True: specialfrogs += 1 if specialfrogs >= 2: text.text(10,10, ["Well done, stalactites. Frogs now inhabit the", "bottom of our cavern."]) ika.Exit() frogsalive = False for x in self.frogs: x.Update() if x.alive == True: frogsalive = True if frogsalive == False: text.text(10,10, ["You were unable to keep the frogs moist long enough."]) self.reset() engine.startgame(0)
def Update(self): pos = 0 specialfrogs = 0 for x in self.entities: x.Update() if x.dead == True: del self.entities[pos] pos += 1 if hasattr(x, 'special') and x.special == True: specialfrogs += 1 if specialfrogs >= 2: text.text(10, 10, [ "Well done, stalactites. Frogs now inhabit the", "bottom of our cavern." ]) ika.Exit() frogsalive = False for x in self.frogs: x.Update() if x.alive == True: frogsalive = True if frogsalive == False: text.text(10, 10, ["You were unable to keep the frogs moist long enough."]) self.reset() engine.startgame(0)
def spawn_score_text(self, x, y, score=None): if score is None: self.text_objects.append(text(str(self.m_points), 16, (x, y))) self.score_time = pygame.time.get_ticks() if self.m_points < 1600: self.m_points *= 2 else: self.text_objects.append(text(str(score), 16, (x, y)))
def __init__(self): loc = [0,0] #initial location for side chains bol = False #cycloBool self.suffixes = {'ol': text('OH', loc, 0), 'amine': text('NH2',loc, 0), 'ene': "double bond", 'en': "double bond", 'yne': "triple bond", 'yn': "triple bond", 'yl': "nothing - yl", 'ane': "alkane", 'an': "alkane" } self.numberPrefixes = {'di': 2, 'mono': 1, 'tri': 3,'quat': 4} # self.numberPrefixes = {'di': 2, 'mono': 1, 'tri': 3,'quat': 4, 'penta': 5, 'hexa': 6, 'septa': 7, 'octa': 8, 'nona': 9, 'deca': 10, 'hendeca': 11, 'icosa': 20} self.alkaneRoots = {'meth': line(loc, 0, 0), 'eth': carbonBackbone( loc, 2, bol) , 'prop': carbonBackbone( loc, 3, bol) , 'but': carbonBackbone( loc, 4, bol) , 'pent': carbonBackbone( loc, 5, bol) , 'hex': carbonBackbone( loc, 6, bol) , 'hept': carbonBackbone( loc, 7, bol) , 'oct': carbonBackbone( loc, 8, bol) , 'non': carbonBackbone( loc, 9, bol) , 'dec': carbonBackbone( loc, 10, bol) , 'undec': carbonBackbone( loc, 11, bol) , 'dodec': carbonBackbone( loc, 12, bol) } self.sideChainRoots = {'iodo': text('I', loc, 0), 'chloro': text('Cl', loc, 0),'floro': text('F', loc, 0), 'bromo': text('Br', loc, 0), "hydroxy": text('OH',loc, 0) } #sec-butyl, isoStuff, tertStuff self.hyphenatedPrefixes = {'sec': "thing 1", 'tert': "thing 2"}
def getCaughtPokemon(data): if len(data.player.defaultTeam) < 6: getNamePokemon(data, data.enemy.pokemon) data.player.defaultTeam.append(data.enemy.pokemon) data.player.team = data.player.defaultTeam.copy() text(data, 'You added', data.enemy.pokemon.name, 'to your team!') else: getNamePokemon(data, data.enemy.pokemon) data.pc.boxes[0].inventory.append(data.enemy.pokemon) text(data, 'You sent', data.enemy.pokemon.name, 'to the PC!')
def intro(): text.text(10, 10, [ "Greetings stalactites. Frogs have inhabited the", "bottom of our dreary cave, and it is our goal to keep them", "alive until they can produce offspring capable of living", "here under their own powers.", "", "Until then, release the water from yourselves onto the frogs so", "that their skin does not dry out.", "Best of luck to us all.", "", "", "(Press 'Space' to proceed)" ]) startgame(0) #number for possible future additions of difficulty level
def split_video(videoName): cap = cv2.VideoCapture(videoName) try: if not os.path.exists("Frames"): os.makedirs("Frames") for i in os.listdir("./Frames"): j = i[:-4] os.remove("Frames\\" + i) except: None currentFrame = 0 length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) contador = 0 while (currentFrame <= length): ret, frame = cap.read() cap.set(cv2.CAP_PROP_POS_FRAMES, currentFrame) frame_copy = frame.copy() frame_copy = frame_copy[100:180, 80:350] phase = text(frame_copy) frame_copy2 = frame.copy() frame_copy2 = frame_copy2[380:450, 565:715] end = text(frame_copy2) if phase == "6TH PICK PHASE": cv2.imwrite("./Frames/{}.png".format(str(contador)), frame) currentFrame += 500 contador += 1 if end == "TDM - BOMB\nCUSTOM GAME": cv2.imwrite("./Frames/1000.png", frame) currentFrame += 10 if currentFrame <= 95 * (length / 100): currentFrame += 200 else: currentFrame += 10 cv2.imshow('frame', frame) if cv2.waitKey(1) & 0xFF == ord('q'): break # print(end) for i in os.listdir("./Frames"): j = i[:-4] if int(j) % 2 != 0: os.remove("Frames\\" + i) cap.release() cv2.destroyAllWindows() return None
def checkPoisonPoint(data, atkPokemon, defPokemon): if defPokemon.ability == 'Poison Point' and atkPokemon.move.variety == 'Physical' and randint( 1, 5) == 1 and atkPokemon.nvStatus == 0: atkPokemon.nvStatus = 5 if atkPokemon == data.player.pokemon: text(data, data.player.pokemon.name, 'became poisoned by coming into contact with the opposing', data.enemy.pokemon.name + '!') else: text(data, 'The opposing', data.enemy.pokemon.name, 'became poisoned by coming into contact with', data.player.pokemon.name + '!')
def checkKeenEye(data, pokemon): if pokemon.ability == 'Keen Eye': if pokemon == data.player.pokemon: text( data, data.player.pokemon.name + '\'s keen eye prevented it\'s accuracy from falling!') else: text( data, 'The opposing', data.enemy.pokemon.name + '\'s keen eye prevented it\'s accuracy from falling!') return 1 else: return 0
def getExpYield(data): inBattleCount = 0 for j in data.player.team: if j.inCurrentBattle == 1: inBattleCount += 1 for i in data.player.team: if i.level != 100: a = 1 e = 1 f = 1 p = 1 s = 1 t = 1 v = 1 x = 1 y = 1 z = inBattleCount if data.enemy.type != 'Wild': a = 1.5 b = data.enemy.pokemon.BaseExpYield if i.item == 'Lucky Egg': e = 1.5 if i.affection >= 2: f = 1.2 l = data.enemy.pokemon.level if data.settings.settingsDict["Triple XP"]: x = 3 if data.settings.settingsDict["10x XP"]: y = 100 #p is for exp point power, not yet implemented if data.player.expShare == 1 and i.inCurrentBattle == 0: s = 2 if data.player.expShare != 0 or i.inCurrentBattle != 0: #t is for traded pokemon, not implemented #v is for pokemon that could have evolved already, not implemented expYield = int( (a * b * e * f * l * p * t * v * x * y) / (7 * s * z)) i.exp += expYield text(data, i.name, 'gained', expYield, 'exp!') while i.exp > i.nextLevelExp and i.level < 100: levelUpPokemon(data, i) text(data, i.name, 'went up one level and is now level', str(i.level) + '!') i.lastLevelExp = getExp(i.species, i.level) i.nextLevelExp = getExp(i.species, i.level + 1) getMoveLearn(data, i) evolutionDetails = getPokemonEvolutionDetails(i.species) if evolutionDetails['Evolve'] == 'Yes': if evolutionDetails['Type'] == 'Level': if i.level >= evolutionDetails['Detail']: i.shouldEvolve = 1
def checkShedSkin(data, defPokemon): if defPokemon.ability == 'Shed Skin' and defPokemon.nvStatus != 0 and randint( 1, 3) == 3: defPokemon.nvStatus = 0 defPokemon.nvStatusCount = 0 if defPokemon == data.player.pokemon: text(data, data.player.pokemon.name, 'shed it\'s skin and lost it\'s condition!') else: text(data, 'The opposing', data.enemy.pokemon.name, 'shed it\'s skin and lost it\'s condition!') return True else: return False
def checkIntimidateOnSwitch(data, atkPlayer, defPlayer): if atkPlayer.pokemon.ability == 'Intimidate': if defPlayer.mist == 0 and defPlayer.pokemon.substitute == 0: statList = [0, -1, 0, 0, 0, 0, 0, 0, 0] defPlayer.pokemon.statStage = list( map(add, defPlayer.pokemon.statStage, statList)) if atkPlayer.pokemon == data.player.pokemon: text(data, data.player.pokemon.name, 'intimidated the opposing', data.enemy.pokemon.name + '!') moveStatWordingAbilityOnEnemy(data, statList) else: text(data, 'The opposing', data.enemy.pokemon.name, 'intimidated', data.player.pokemon.name + '!') moveStatWordingAbilityOnPlayer(data, statList)
def intro(): text.text(10,10, ["Greetings stalactites. Frogs have inhabited the", "bottom of our dreary cave, and it is our goal to keep them", "alive until they can produce offspring capable of living", "here under their own powers.", "", "Until then, release the water from yourselves onto the frogs so", "that their skin does not dry out.", "Best of luck to us all.", "", "", "(Press 'Space' to proceed)"]) startgame(0) #number for possible future additions of difficulty level
def gainHealthAbility(data, pokemon, typeOfHeal, value): if typeOfHeal == 'constant': healAmount = value elif typeOfHeal == 'percentage': healAmount = (pokemon.maxhp / 100) * value if healAmount > pokemon.maxhp - pokemon.hp: healAmount = pokemon.maxhp - pokemon.hp pokemon.hp += healAmount if pokemon == data.player.pokemon: text(data, data.player.pokemon.name, 'regained', healAmount, 'HP. It has', (data.player.pokemon.hp), '/', (data.player.pokemon.maxhp), 'HP remaining!') else: text(data, 'The opposing', data.enemy.pokemon.name, 'regained', healAmount, 'HP. It has', (data.enemy.pokemon.hp), '/', (data.enemy.pokemon.maxhp), 'HP remaining!')
def main(screen): h = screen.getmaxyx()[0] buffer = files.open_file() top = basics.set_top(screen, buffer) position = [0, 0] buffer, position, top = basics.redraw_screen(screen, buffer, position, top) # color_thread = threading.Thread(target=color, args=(screen, buffer, position, top)) # color_thread.start() while 1: key = screen.getch() if key == curses.KEY_UP or key == curses.KEY_DOWN or key == curses.KEY_RIGHT or key == curses.KEY_LEFT: buffer, position, top = basics.move(screen, buffer, position, top, key) elif key == curses.KEY_BACKSPACE or key == 127: buffer, position, top = text.backspace(screen, buffer, position, top) elif key == curses.KEY_ENTER or key == 10: buffer, position, top = text.enter(screen, buffer, position, top) elif key == 27: files.save_file(buffer) return else: buffer, position = text.text(screen, buffer, position, top, chr(key))
def setType(self, type): #Delete old panels for i in self.GetChildren(): if i.GetName() in [ "imagePanel", "customPanel", "colorPanel", "rotationPanel", "textPanel", "vartextPanel" ]: i.Destroy() if type == "color": self.color = color(self) self.customSizer.Add(self.color, 1, wx.EXPAND | wx.ALL, 4) if type == "image": self.image = image(self) self.customSizer.Add(self.image, 1, wx.EXPAND | wx.ALL, 4) if type == "text": self.rotation = rotation(self) self.customSizer.Add(self.rotation, 0, wx.EXPAND | wx.ALL, 4) self.text = text(self) self.customSizer.Add(self.text, 1, wx.EXPAND | wx.ALL, 4) if type == "vartext": self.rotation = rotation(self) self.customSizer.Add(self.rotation, 0, wx.EXPAND | wx.ALL, 4) self.vartext = vartext(self) self.customSizer.Add(self.vartext, 1, wx.EXPAND | wx.ALL, 4) self.SetSizerAndFit(self.sizer) self.Layout() self.parent.Layout() self.parent.propertiesPanel.Layout()
def setType(self, type): #Delete old panels for i in self.GetChildren(): if i.GetName() in ["imagePanel", "customPanel", "colorPanel", "rotationPanel", "textPanel", "vartextPanel"]: i.Destroy() if type == "color": self.color = color(self) self.customSizer.Add(self.color, 1, wx.EXPAND|wx.ALL, 4) if type == "image": self.image = image(self) self.customSizer.Add(self.image, 1, wx.EXPAND|wx.ALL, 4) if type == "text": self.rotation = rotation(self) self.customSizer.Add(self.rotation, 0, wx.EXPAND|wx.ALL, 4) self.text = text(self) self.customSizer.Add(self.text, 1, wx.EXPAND|wx.ALL, 4) if type == "vartext": self.rotation = rotation(self) self.customSizer.Add(self.rotation, 0, wx.EXPAND|wx.ALL, 4) self.vartext = vartext(self) self.customSizer.Add(self.vartext, 1, wx.EXPAND|wx.ALL, 4) self.SetSizerAndFit(self.sizer) self.Layout() self.parent.Layout() self.parent.propertiesPanel.Layout()
def checkStartBattleIntimidate(data): statList = [0, -1, 0, 0, 0, 0, 0, 0, 0] if data.player.pokemon.ability == 'Intimidate': data.enemy.pokemon.statStage = list( map(add, data.enemy.pokemon.statStage, [0, -1, 0, 0, 0, 0, 0, 0, 0])) text(data, data.player.pokemon.name, 'intimidated the opposing', data.enemy.pokemon.name + '!') moveStatWordingAbilityOnEnemy(data, statList) if data.enemy.pokemon.ability == 'Intimidate': data.player.pokemon.statStage = list( map(add, data.player.pokemon.statStage, [0, -1, 0, 0, 0, 0, 0, 0, 0])) text(data, 'The opposing', data.enemy.pokemon.name, 'intimidated', data.player.pokemon.name + '!') moveStatWordingAbilityOnPlayer(data, statList)
def keyword(): global text_info global emo_info s_time = time.time() transcript = sound2text.sound2text() text_info = text.text(transcript) emo_info = tone.tones(transcript) print("The current text infomation is:" + str(text_info)) print("The current tone of discussion is:" + emo_info)
def checkEffectSpore(data, atkPokemon, defPokemon): if defPokemon.ability == 'Effect Spore' and atkPokemon.move.variety == 'Physical' and randint( 1, 5) == 1 and atkPokemon.nvStatus == 0: possibleStatusList = [2, 3, 5] atkPokemon.nvStatus = random.choice(possibleStatusList) statusToWordDictEffectSpore = { 2: 'became paralyzed', 3: 'was put to sleep', 5: 'became poisoned' } wording = statusToWordDictEffectSpore[atkPokemon.nvStatus] if atkPokemon == data.player.pokemon: text(data, data.player.pokemon.name, wording, 'by coming into contact with the opposing', data.enemy.pokemon.name + '!') else: text(data, 'The opposing', data.enemy.pokemon.name, wording, 'by coming into contact with', data.player.pokemon.name + '!')
def evolvePokemon(data, pokemon): evolutionDetails = getPokemonEvolutionDetails(pokemon.species) evolveInto = evolutionDetails['Pokemon'] oldPokemonName = pokemon.name if pokemon.name == pokemon.species: pokemon.name = evolveInto pokemon.species = evolveInto pokemon.sprite = getPokemonSprite(pokemon.species) text(data, oldPokemonName, 'evolved into', evolveInto + '!') pokemon.species = evolveInto pokemon.baseStats = getBaseStats(pokemon.species) pokemon.type = getPokemonType(pokemon) oldMaxHealth = pokemon.maxhp pokemon.maxhp = gethpStat(pokemon) increase = pokemon.maxhp - oldMaxHealth pokemon.hp += increase getMoveLearn(data, pokemon, justEvolved=True)
def checkFlashFireOrSimilar(data, atkPokemon, defPokemon): abilityList = ['Flash Fire', 'Dry Skin'] abilityTypeDict = {'Flash Fire': 'Fire', 'Dry Skin': 'Water'} if defPokemon.ability in abilityList: if abilityTypeDict[defPokemon.ability] == atkPokemon.move.type: if defPokemon == data.player.pokemon: text(data, data.player.pokemon.name, 'absorbed the attack with it\'s', data.player.pokemon.ability + '!') else: text(data, 'The opposing', data.enemy.pokemon.name, 'absorbed the attack with it\'s', data.enemy.pokemon.ability + '!') if defPokemon.ability == 'Flash Fire': defPokemon.flashFireMult += 0.1 elif defPokemon.ability == 'Dry Skin': gainHealthAbility(data, defPokemon, 'percentage', 25) return 1 return 0
def readDat(): dir = "dat/news4vip" data = [] for file in os.listdir(dir)[:100]: print(file) path = f"{dir}/{file}" with open(path, "r") as f: reses = [text.text(x[6]) for x in json.loads(f.read())["comments"]] for res in reses: data.append(res[0]) return data
def healPokemon(data, pokemon, item, battle): if pokemon.hp == 0: return False elif pokemon.hp == pokemon.maxhp: return False else: heal = item.modifier if pokemon.maxhp - pokemon.hp < heal: heal = pokemon.maxhp - pokemon.hp pokemon.hp += heal if battle == True: text( data, pokemon.name, 'has been healed by', heal, 'HP! It has', str(data.player.pokemon.hp) + '/' + str(data.player.pokemon.maxhp), 'remaining!') if item.name == "Full Restore" or item.name == "Full Heal": if pokemon.nvStatus != 0: pokemon.nvStatus = 0 if battle == True: text(data, pokemon.name + ' no longer has a status condition!') return True
def getSwitchBattle(data, pokemonChosen): while True: try: x = 0 trapped = data.player.pokemon.bind + data.player.pokemon.clamp + data.player.pokemon.fireSpin + data.player.pokemon.wrap if pokemonChosen == data.player.pokemon: if data.player.pokemon.hp == 0: return data.player.pokemon.name + ' has fainted! Please choose another Pokemon!' else: return 'That Pokemon is already out! Please choose another Pokemon!' elif pokemonChosen == "Back": if data.player.pokemon.hp == 0: return data.player.pokemon.name + ' has fainted! Please choose another Pokemon!' else: text(data, 'Keep going,', data.player.pokemon.name + '!') return False # No switch elif data.player.pokemon.hp != 0 and trapped != 0: return data.player.pokemon.name, ' is unable to escape due to being trapped!' return False else: if pokemonChosen.hp == 0: return pokemonChosen.name + ' has fainted! Please choose another Pokemon!' return False else: j = data.player.team.index(pokemonChosen) data.player.team[j], data.player.team[ 0] = data.player.team[0], data.player.team[j] data.player.pokemon = data.player.team[0] return True if x == 0: return "Please choose a Pokemon from the list above!" except ValueError: return "Please choose a Pokemon from the list above!"
def processUTFFile(self, filename): log = logging.getLogger('classify') log.debug("texfile.processUTFFile()") text_obj = text.text(self.gdbm_files, self.filter_file, self.path, self.category) textfile = open(filename, "r") excerpt = textfile.read() textfile.close() all_matches = text_obj.processUTFString(excerpt) log.debug(" All Matches:") log.debug("Number of Matches Found = %s" % len(all_matches)) all_matches = sorted(all_matches, key=lambda positive_match: positive_match.offset) for item in all_matches: item.printMatch() return
def processHTML(self, link): log = logging.getLogger('classify') log.debug("url.processHTML()") text_obj = text.text(self.gdbm_files, self.filter_file, self.path, self.category) textfile = self.grabHTML(link) html_file = open(textfile, "r") html = html_file.read() soup = BeautifulSoup.BeautifulSoup(html) # Removes <!-- --> comments from html comments = soup.findAll(text=lambda text:isinstance(text, Comment)) [comment.extract() for comment in comments] #visible_text = soup.findAll(text=lambda text: text.parent.name != "script" and text.parent.name != "style" and text.parent.name != "[document]" and text.parent.name != "head" and text.parent.name != "title") #log.debug("visible text = %s" % visible_text) visible_entries = [] # Filters out all visible content from the web page excluding text from the script, style, document, head, and title tags for element in soup.findAll(text=lambda text: text.parent.name != "script" and text.parent.name != "style" and text.parent.name != "[document]" and text.parent.name != "head" and text.parent.name != "title"): # Removes any matches that don't have any words or numbers in it if re.search("[\w\d]+", element): log.debug("element = %s" % element) visible_entries.append(element) log.debug("visible entries = %s" % visible_entries) visible_string = " ".join(visible_entries) log.debug("visible string = %s" % visible_string) all_matches = text_obj.processUnicodeString(visible_string) log.debug(" All Matches:") log.debug("Number of Matches Found = %s" % len(all_matches)) all_matches = sorted(all_matches, key=lambda positive_match: positive_match.offset) for item in all_matches: item.printMatch() # Closes the html file html_file.close() return
def template(img_path, template_path): img = cv2.imread(img_path) img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) template = cv2.imread(template_path, 0) w, h = template.shape[::-1] res = cv2.matchTemplate(img_gray, template, cv2.TM_CCOEFF_NORMED) threshold = 0.8 loc = np.where(res >= threshold) for pt in zip(*loc[::-1]): if pt[0] > 700: #azul defesa// laranja ataque img = img[385:435, 530:750] else: #azul ataque// laranja defesa img = img[635:685, 530:750] break bomb = text(img) return bomb
def open_callback(self): """Method for file open dialog, text processing, and display of statistics.""" #file open dialog (opens at current directory, allows only text files) path = filedialog.askopenfilename( \ initialdir=os.getcwd(), \ title="Select file", \ filetypes=(("text files","*.txt"),("text files","*.json"),("all files","*.*")) \ ) try: #check if dialog closed by 'cancel' if path == '': return else: #instantiate text object from path self.txt = text(path) #get file name, not entire path filename = path.split('/')[-1] #list of variables to be displayed in gui txt_vars = [filename, \ self.txt.word_count, \ self.txt.keystroke_count, \ self.txt.character_count, \ #self.txt.character_distribution, \ #self.txt.word_distribution, \ self.txt.average_word_length] gridrow = 1 #counting rows in grid #make a new label for each of the text statistics for item in txt_vars: lbl = tk.Label(self.root, text=item) lbl.grid(column=1, row=gridrow) gridrow += 1 self.root.update() #redraw gui with new labels except: return
def render(self): self.win.fill(self.background) # Render Game Objects self.ground.render(self.win) self.player1.render(self.win) self.player2.render(self.win) for bullet in self.bullets: bullet.render(self.win) # Render UI Elements text( self.win, "Player 1: " + str(self.player1.score), 35, (255, 255, 255), (80, 30) ) text( self.win, "Player 2: " + str(self.player2.score), 35, (255, 255, 255), (self.win_size[0] - 80, 30) ) if self.current_player == self.player1: turn_display = "Player 1's Turn" elif self.current_player == self.player2: turn_display = "Player 2's Turn" if not self.shooting: text( self.win, turn_display, 40, (255, 255, 255), (self.win_size[0] / 2, self.win_size[1] - 70) ) pygame.display.flip()
def moveStatWordingAbilityOnEnemy(data, statList): count = 0 for i in statList: if i != 0: stat = statDict[count] changeForStat = statList[count] if changeForStat == 1: text(data, 'The opposing', data.enemy.pokemon.name + '\'s', stat, 'raised!') if changeForStat == 2: text(data, 'The opposing', data.enemy.pokemon.name + '\'s', stat, 'raised sharply!') if changeForStat >= 3: text(data, 'The opposing', data.enemy.pokemon.name + '\'s', stat, 'raised hugely!') if changeForStat == -1: text(data, 'The opposing', data.enemy.pokemon.name + '\'s', stat, 'fell!') if changeForStat == -2: text(data, 'The opposing', data.enemy.pokemon.name + '\'s', stat, 'fell sharply!') if changeForStat <= -3: text(data, 'The opposing', data.enemy.pokemon.name + '\'s', stat, 'fell hugely!') count += 1
# -*- coding: utf-8 -*- from serialDriver import serialDriver from text import text from textLib import textLib from sys import argv script, number, message = argv print "Number: " + number print "Message: " + message serD = serialDriver("/dev/ttyUSB0", 9600) serD.open() if serD.err: print serD.errMessage else: texter = textLib(serD) t1 = text(number, message) res = texter.sendText(t1) if not res: print "Error texting" if serD.err: print serD.errMessage
newgame.onentrance(newgameenter) globals.menuslides['menumain']=menumain globals.menuslides['loadmenu']=loadmenu globals.menuslides['savemenu']=savemenu globals.menuslides['return_root']=newgame parameters.setfirstslides(menumain, menumain) bench = AoIimage(FilePath('bench.jpg', None, 0), rect = (430,65), slide = menumain) optionmenubk = AoIimage(FilePath('optionsmenu.jpg', None, 0), rect = (175,122), visible = 0, slide = menumain, layer=2) quitmenumain = AoIimage(FilePath('quitmenu.jpg', None, 0), rect = (175,122), visible = 0, slide = menumain, layer=2) transopt = AoIimage(FilePath('radiobutton.bmp', None, 0), rect = (252,245), visible = 0, alpha = (0,0), slide = menumain, layer=3) check = AoIimage(FilePath('radiobutton.bmp', None, 0), rect = (252,425), visible = 0, alpha = (0,0), slide = menumain, layer=3) quitmenusave = AoIimage(FilePath('savemenu.jpg', None, 0), rect = (175,122), visible = 0, slide = savemenu, layer=2) toptext = text(FilePath('AC.TTF', None, 0), (100, 35, 400, 100), 'The Ages of Ilathid', (0,0,0), 1, 0, 26, None, menumain) urutext = text(FilePath('Ilathidhi01.ttf', None, 0), (100, 135, 400, 100), 'URU live is not dead', (0,0,0), 1, 0, 14, None, menumain) newtext = text(FilePath('AC.TTF', None, 0), (500, 300, 200, 40), 'New Game', (0,0,0), 1, 0, 35, None, menumain) restext = text(FilePath('AC.TTF', None, 0), (500, 340, 200, 40), 'Resume Game', (0,0,0), 1, 0, 35, None, menumain) loadtext = text(FilePath('AC.TTF', None, 0), (500, 380, 200, 40), 'Load Game', (0,0,0), 1, 0, 35, None, menumain) optext = text(FilePath('AC.TTF', None, 0), (500, 420, 200, 40), 'Options', (0,0,0), 1, 0, 35, None, menumain) savetext = text(FilePath('AC.TTF', None, 0), (500, 460, 200, 40), 'Save Game', (0,0,0), 1, 0, 35, None, menumain) quittext = text(FilePath('AC.TTF', None, 0), (500, 500, 200, 40), 'Quit Game', (0,0,0), 1, 0, 35, None, menumain) loadtitle = text(FilePath('AC.TTF', None, 0), (200, 35, 250, 50), 'Load', (0,0,0), 1, 0, 35, None, loadmenu) savetitle = text(FilePath('AC.TTF', None, 0), (200, 35, 250, 50), 'Save', (0,0,0), 1, 0, 35, None, savemenu) backloadtitle = text(FilePath('avgardn.ttf', None, 0), (77, 35, 400, 100), 'Back', (0,0,250), 1, 0, 15, None, loadmenu) backsavetitle = text(FilePath('avgardn.ttf', None, 0), (77, 35, 400, 100), 'Back', (0,0,250), 1, 0, 15, None, savemenu) ###Build the save and load menu slides #open the encrypted index file
def processHTML(self, link): log = logging.getLogger('classify') log.debug("url.processHTML()") text_obj = text.text(self.gdbm_files, self.filter_file, self.path, self.category) textfile = self.grabHTML(link) html_file = open(textfile, "r") html = html_file.read() soup = BeautifulSoup.BeautifulSoup(html) # Removes <!-- --> comments from html comments = soup.findAll(text=lambda text:isinstance(text, Comment)) [comment.extract() for comment in comments] all_matches = [] # List of all matches found in text in order they are found id_count = 1 # Specifies the id count number that will be inserted into the id attribute previous_element_parent = {} # Stores previously seen parent tree (key = previously seen parent tree ; value = last modified index in tree) # Filters out all visible content from the web page excluding text from the script, style, document, head, and title tags for element in soup.findAll(text=lambda text: text.parent.name != "script" and text.parent.name != "style" and text.parent.name != "[document]" and text.parent.name != "head" and text.parent.name != "title"): # Removes any matches that don't have any words or numbers in it if re.search("[\w\d]+", element): log.debug("element = %s" % element) matches = text_obj.processUnicodeString(element) if matches: # Match is found log.debug("matches = %s" % matches) all_matches.extend(matches) # concatenates lists phrase = element match_index = [] # Finds if the given visible text entry contains any matches and stores the words that come before it for match in matches: index = phrase.find(match.getMatch()) if index != -1: match_index.append(phrase[:index]) phrase = phrase[index+len(match.getMatch()):] log.debug("match_index = %s" % match_index) log.debug("phrase = %s" % phrase) b_tags = [] # Creates the b tag objects for match in matches: b = Tag(soup, "b") # Creates a b tag b["id"] = id_count # Add the id attribute to the b tag b["style"] = "background-color: #ffff00" # Add the background color to the b tag b.insert(0, match.getMatch()) # Inserts the matched key word in between the b tag b_tags.append(b) id_count += 1 log.debug("element.parent.contents = %s" % element.parent.contents) count = 0 # Checks if the parent tree has been previously seen. If so, it gets that index + 1 in the tree if element.parent in previous_element_parent: log.debug("element.parent in previous_element_parent") count = previous_element_parent[element.parent] # If the current index is a Tag object, skip it and go onto the next index while(count < len(element.parent.contents) and type(element.parent.contents[count]) == Tag): log.debug("incrementing count because of tag") count += 1 else: # Checks if an object in the tree has already been previouly seen. If so, it gets that index + 1 in the tree for index in range(len(element.parent.contents)): if element.parent.contents[index] in previous_element_parent: log.debug("Current index has been previously seen - set count to index") count = index + 1 # Inserts the b tags and strings in their right order for index in range(len(match_index)): element.parent.insert(count, match_index[index]) element.parent.insert(count+1, b_tags[index]) count += 2 element.parent.insert(count, phrase) log.debug("element.parent - before extract = %s" % element.parent) element.extract() # Removes the element from the tree previous_element_parent[b_tags[0].parent] = count + 1 # Stores the last modified index in the tree log.debug("element.parent - after extract = %s" % element.parent) log.debug("b_tags[].parent = %s" % b_tags[0].parent) # Closes the html file and overwrites it with the key words highlighted html_file.close() html_file = open(textfile, "w") html_file.write(str(soup)) log.debug("final id count = %s" % id_count) #log.debug("soup = %s" % soup) log.debug(" All Matches:") log.debug("Number of Matches Found = %s" % len(all_matches)) for item in all_matches: item.printMatch() text_obj.createResultJSONFile() text_obj.createEditJSONFile() return
import tkinter #导入TKinter模块 from tkinter import * from label import label from text import text from unit import unit from functools import partial from parameter import parameter area = 0.000000 transfer = 2.54 window = Tk() contentVar_area = tkinter.StringVar(window, '') Label(window, text="计算一种图形的面积时请把其它图形的参数填为0", bg='red').grid(row=6) text_list = [] num_list = [0, 1, 2, 3, 4] text_rect_length = text("rect_length", num_list[0], window) text_list.append(text_rect_length) text_rect_width = text("rect_widdth", num_list[1], window) text_list.append(text_rect_width) text_circle_diameter = text("circle_diameter", num_list[2], window) text_list.append(text_circle_diameter) text_triangle_bottom = text("triagle_bottom", num_list[3], window) text_list.append(text_triangle_bottom) text_triangle_height = text("triagle_height", num_list[4], window) text_list.append(text_triangle_height) for text in text_list: text.show(window) e3 = Entry(window, textvariable=contentVar_area, width=50) e3.grid(row=5, column=1)
def notmain(): pygame.init() screen = pygame.display.set_mode((600, 450)) pygame.display.set_caption("AI DRIVING") clock = pygame.time.Clock() BLACK = (250, 250, 250) WHITE = (5, 5, 5) GRAY = (150, 150, 150) RED = (200, 100, 100) GREEN = (100, 200, 100) BLUE = (100, 100, 200) timer = 0 endTimer = 0 currentRun = 1 history = [] road1, road2, road3, road4 = gf.setMap() gen = text(screen, "Gen: " + str(currentRun), (80, 240)) ai = [Car(screen), Car(screen), Car(screen), Car(screen), Car(screen)] for car in ai: for i in range(3): car.brain.createRandNode() while True: screen.fill(GRAY) currentRoad, roadNum = gf.selectRoad(ai[0].getPos(), [road1, road2, road3, road4]) preload = gf.preloadRoad(ai[0].getPos(), [road1, road2, road3, road4], roadNum) for car in ai: if currentRoad[2].overlap(car.mask, (int(car.x - currentRoad[1].x) - 11, int(car.y - currentRoad[1].y) - 11)): car.hit = True gf.checkpointCollision(car) car.checkSpeed() timer += 1 timer += gf.checkSpace() if timer > 400 + (2 * currentRun): endTimer += 1 if endTimer > 25: endTimer = 0 found = -1 for num, car in enumerate(ai, 0): if car.score != 0: history.append((car.brain.getTensorflowData(), car.score)) car.brain.randMutate() car.reset() timer = 0 currentRun += 1 gen.prep("Gen: " + str(currentRun)) if currentRun % 40 == 0 and currentRun != 0: xTrain = tf.constant([history[0]]) yTrain = tf.constant([history[1]]) print(xTrain) layer0 = tf.keras.layers.Dense(units=1, input_shape=(4,)) model = tf.keras.Sequential([ layer0, ]) model.compile(loss="mean_squared_error", optimizer=tf.keras.optimizers.Adam(0.1)) trainModel = model.fit(xTrain, yTrain, steps_per_epoch=1, epochs=5, verbose=False) # Prints information inside history (Information sent to tensorflow) if currentRun == 12 and timer <= 0: print(len(history)) for num, h in enumerate(history, 0): if num % 5 == 0: print("", end="") print(h[0], end=",\n") for h in history: print(h[1], end=",\n") for road in [road1, road2, road3, road4]: screen.blit(road[0], road[1]) for car in ai: if not car.hit: car.takeAction() car.update() car.draw() car.drawLines(GREEN) car.drawContact(car.scan(currentRoad, preload), BLACK) car.raypoints = car.posToDis(car.scan(currentRoad, preload)) else: car.draw(RED) gf.checkEvent(car) gen.blit() gf.drawCheckPointLines(screen) gf.drawImageBorders(screen) pygame.display.flip() clock.tick(60)
def main(): #creacion de objetos para el programa bg = background.background(settings.pantalla,"02.png",alpha = True, posicion = settings.screen_center) barra = img.img(settings.pantalla,"001.png",posicion=settings.screen_center) #control de los textos l0 = text.text(settings.pantalla,color = (255,255,255),nombre = "COOPBL.ttf",tamano = settings.text_tamano_1,posicion = (40,405),linea = u"Voz que parece familiar") l1 = text.text_anim_01(settings.pantalla,nombre = "ARLRDBD.ttf",tamano = settings.text_tamano_1,velocidad = settings.text_speed_1,color = (255,255,255), posicion = (25,455), linea = u"Marcelo Salas!") l2 = text.text_anim_01(settings.pantalla,nombre = "ARLRDBD.ttf",tamano = settings.text_tamano_1,velocidad = settings.text_speed_1,color = (255,255,255), posicion = (25,495), linea = u"Activaste mi carta trampa!") l3 = text.text_anim_01(settings.pantalla,nombre = "ARLRDBD.ttf",tamano = settings.text_tamano_1,velocidad = settings.text_speed_1,color = (255,255,255), posicion = (25,535), linea = "") lista = [l0,l1,l2,l3] parrafo = text.group_text(lista) #marcelo marcelo = sprites.personaje(settings.pantalla,posicion = (-300,450)) marcelo.add("marcelo.png") marcelo.add("marcelo01.png") x2 = pygame.transform.scale2x(marcelo.imagenes[0]) marcelo.imagenes[0] = x2 x3 = pygame.transform.scale2x(marcelo.imagenes[1]) marcelo.imagenes[1] = x3 marcelo.current(1) marcelo.anim_01((150,450),180) #marmota marmota = sprites.personaje(settings.pantalla,posicion = (1000,450)) marmota.add("marmota.png") marmota.add("marmota01.png") bgmusic = bgm.bgm("004.mp3") running = True #acciones de uso unico bgmusic.play() #bucle principal while running: #variables que se comprueban cada bucle #lista de los eventos que se ejecutaron for evento in pygame.event.get(): if evento.type == pygame.KEYDOWN: if evento.key == pygame.K_z: marmota.end_anim_01() marcelo.end_anim_01() if not(parrafo.renderizado): for linea in lista: linea.velocidad = 5000 if parrafo.renderizado: parrafo.contador += 1 if evento.type == pygame.KEYUP: if evento.key == pygame.K_z: for linea in lista: linea.velocidad = settings.text_speed_1 if evento.type == pygame.QUIT: running = False #manejo de textos if parrafo.renderizado and parrafo.contador == 2: parrafo.void() marcelo.anim_01((150,450),180) marcelo.current(0) marmota.current(1) #modificamos los textos l0.line(u"Marcelo") l1.line(u"No veo ni mierdas, podrías prender la luz?") if parrafo.renderizado and parrafo.contador == 4: parrafo.void() marcelo.current(1) marmota.current(0) #modificamos textos l0.line(u"Voz que parece familiar") bg = background.background(settings.pantalla,"03.jpg",alpha = False, posicion = settings.screen_center) l1.line(u"En este lugar no hay luz, solo hay Divinas Comedias! ") if parrafo.renderizado and parrafo.contador == 6: parrafo.void() marcelo.current(0) marmota.current(1) #modificamos textos l0.line(u"Marcelo") l1.line(u"Quien eres?") if parrafo.renderizado and parrafo.contador == 8: parrafo.void() marmota.anim_01((600,450),320) marmota.current(0) marcelo.current(1) #modificamos textos l0.line(u"Jesucristo") l1.line(u"Creías que Jesucristo era una buena persona?") l2.line(u"Jesucristo es de la Policía de Investigaciones!") l3.line(u"Cagaste culiao!") if parrafo.renderizado and parrafo.contador == 10: parrafo.void() #modificamos textos l0.line(u"Jesucristo") l1.line(u"Soy de la PDI! Quedaste arrestado por ") l2.line(u"contrabando y compra de transgénicos ") l3.line(u"ilegales!") if parrafo.renderizado and parrafo.contador == 12: parrafo.void() marcelo.current(0) marmota.current(1) #modificamos textos l0.line(u"Marcelo") l1.line(u"NOOOOOOOOOOOOOO ") if parrafo.renderizado and parrafo.contador == 14: parrafo.void() marmota.current(0) marcelo.current(1) #modificamos textos l0.line(u"Jesucristo") l1.line(u"Ajkajakjak y el weon se la cree ajajkakjakjk ") l2.line(u"Solo te tendí una trampa para transformarte ") l3.line(u"en Dante Allighieri ") if parrafo.renderizado and parrafo.contador == 16: parrafo.void() marcelo.current(0) marmota.current(1) #modificamos textos l0.line(u"Marcelo") l1.line(u"Ah, de pana igual") if parrafo.renderizado and parrafo.contador == 18: parrafo.void() marcelo.current(1) marmota.current(0) #modificamos textos l0.line(u"Jesucristo") l1.line(u"Si, ser Allighieri es entrete") #paso a la siguiente pantalla if parrafo.contador == 20: running = False s5.main() #actualizacion de objetos en pantalla bg.update() marcelo.update() marmota.update() barra.update() parrafo.update() if not(running): bgmusic.stop() #actualizamos la pantalla if running: pygame.display.flip() settings.reloj.tick(60)