def test_populate_area(self): self.c.add_area([(0, 0), (100, 0), (100, 100)]) creature1 = creature.Creature() creature2 = creature.Creature() # Initially an area is empty self.assertEqual(self.c.area.population(), 0) self.c.area.add_resident(creature1) self.assertEqual(self.c.area.population(), 1) self.c.area.add_resident(creature2) self.assertEqual(self.c.area.population(), 1)
def spawnCreature(self, brain): position = np.array([ random.randint(0, self.worldmap.mapsize[0] - 1), random.randint(0, self.worldmap.mapsize[1] - 1) ]) #spawn position should be on the land, until find a suitable place, we repeat while True: if self.worldmap.worldframe[:, :, self.worldmap.LAYERID_WATERDEPTH][ position[0], position[1]] == 0: break position = np.array([ random.randint(0, self.worldmap.mapsize[0] - 1), random.randint(0, self.worldmap.mapsize[1] - 1) ]) #creating new random positioned creature newCreature = creature.Creature(position) #setting fresh new brain worldViewShape = (newCreature.sight * 2 + 1, newCreature.sight * 2 + 1, self.worldmap.LAYERS) newCreature.setBrain( self, brain(numberOfActions=newCreature.numberOfActions, creatureStatsShape=newCreature.creatureStatsShape, worldViewShape=worldViewShape), worldmap=self.worldmap) self.creatures.append(newCreature) self.noOfCreatures += 1
def collect_data(population, generation): length = num_groups * creatures_per_group tot_fit = 0 max_fit = 0 num_foods_eaten = 0 best_creature = creature.Creature(0, (100, 100), sizes, 0, 0) for creature_set in population: for c in creature_set: tot_fit += c.nom if c.nom > max_fit: best_creature = c max_fit = c.nom num_foods_eaten += c.num_foods_eaten avg_fit = tot_fit / length print('GENERATION', str(generation)) print('Fittest creature:', best_creature.ID) print('Max fitness:', best_creature.nom) print('Average fitness:', avg_fit) print('Number of foods eaten total:', num_foods_eaten) print('Foods eaten by fittest creature:', best_creature.num_foods_eaten) print() return best_creature, avg_fit
def test_pay_upkeep(self): self.c.add_area([(0, 0), (100, 0), (100, 100)]) starting_coins = self.c.current_coins() creature = creature.Creature() self.c.area.add_resident(creature) self.c.pay_upkeep() first_payment = starting_coins - self.c.current_coins() self.assertTrue(payment > 0) # Matching creatures are free self.c.change_element("FIRE") creature.change_element("FIRE") self.c.pay_upkeep() matching_payment = starting_coins - first_payment - self.c.current_coins( ) self.assertTrue(matching_payment == 0) # Opposite creatures pay more creature.change_element("WATER") self.c.pay_upkeep() opposite_payment = starting_coins - first_payment - self.c.current_coins( ) self.assertTrue(opposite_payment > first_payment) # Creatures will leave if they can't be paid while creature.where_do_i_live() == self.c: self.c.pay_upkeep() self.assertNotEqual(creature.where_do_i_live(), self.c)
def generate_free_camera(): """ Generates free camera at (0, 0) """ camera = creature.Creature("camera", False, team=None, walk_through_tile=True) free_camera = entity.Entity(0, 0, "camera", creature=camera) return free_camera
def __init__(self, mutationRate, eq, num): self.mutationRate = mutationRate self.eq = eq self.population = [] for i in range(num): self.population.append(creature.Creature(eq)) self.computeFitness() self.matingPool = [] self.finish = False #finish evolving?? self.generations = 0 #number of generation
def test_fight(self): self.c.add_area([(0, 0), (100, 0), (100, 100)]) friendly_creature = creature.Creature() self.c.area.add_resident(friendly_creature) non_enemy_country = country.Country() non_enemy_country.add_area([(0, 0), (100, 0), (100, -100)]) non_enemy_creature = creature.Creature() non_enemy_country.area.add_resident(non_enemy_creature) # Can't fight non-enemy countries self.assertIsNone(self.c.fight(non_enemy_country)) enemy_country = country.Country() enemy_country.add_area([(20, 50), (70, 30), (60, 100)]) enemy_creature = creature.Creature() enemy_creature.strength -= 2 enemy_country.area.add_resident(enemy_creature) self.assertEqual(self.c.fight(enemy_country), self.c) self.assertEqual(self.c.strength(), 2)
def test_strength(self): self.c.add_area([(0, 0), (100, 0), (100, 100)]) self.assertEqual(self.c.strength(), 0) creature1 = creature.Creature() self.c.area.add_resident(creature1) normal_creature_strength = self.c.strength() self.assertTrue(normal_creature_strength > 0) # A creature gives less strength if the country element doesn't match self.c.change_element("FIRE") self.assertTrue(normal_creature_strength > self.c.strength() > 0) # But gives more if the element does match creature1.change_element("FIRE") self.assertTrue(normal_creature_strength < self.c.strength())
def list_possible_genotypes(self): #Actually returns a list of creatures, one with each possible genotype possible_creatures = [creature.Creature()] for gene in self.genes: new_possible_creatures = [] for allele in self.genes[gene]: for cre in possible_creatures: creature_copy_plus_allele = deepcopy(cre) creature_copy_plus_allele.alleles[gene] = allele new_possible_creatures.append(creature_copy_plus_allele) possible_creatures = new_possible_creatures return possible_creatures
def reproduce(i): if(Fishes[i].health > reprod_health): Fishes[i].health -= reprod_cost W_i = Fishes[i].W mnd.mutateW(W_i) p_x = Fishes[i].posX + 20.0*(random.random()-0.5) p_y = Fishes[i].posY + 20.0*(random.random()-0.5) or_ = 6.29*random.random() vel_ = vMax*random.random() ship_i = creat.Creature(W_i, p_x, p_y, vel_, or_) #windowX*0.5 + 240*(random.random()-0.5) ship_i.color = Fishes[i].color ship_i.size = Fishes[i].size*(1.0+0.1*(random.random()-0.5)) if(ship_i.size < minSize): ship_i.size = minSize ship_i.species = Fishes[i].species ship_i.herbivore = Fishes[i].herbivore ship_i.carnivore = Fishes[i].carnivore Fishes.append(ship_i) fitness.append(10000) set_XY(-1) points = [Fishes[-1].posX, Fishes[-1].posY, Fishes[-1].X_2, Fishes[-1].Y_2, Fishes[-1].X_3, Fishes[-1].Y_3, Fishes[-1].X_4, Fishes[-1].Y_4, Fishes[-1].X_5, Fishes[-1].Y_5, Fishes[-1].X_3, Fishes[-1].Y_3, Fishes[-1].X_6, Fishes[-1].Y_6] color_outline = 'black' if(Fishes[i].carnivore == 1): color_outline = 'red' if(Fishes[i].herbivore == 1): color_outline = 'green' if(Fishes[i].carnivore == 1 and Fishes[i].herbivore == 1): color_outline = 'white' Shapes.append(canvas.create_polygon(points, outline=color_outline, fill=Fishes[i].color, width=2))
def defineFishes(): #Definir los peces al comienzo for i in range(np): W_i = [] mnd.setW(W_i) ship_i = creat.Creature(W_i, windowX*random.random(), windowY*random.random(), vMax*(random.random())**2, 6.28*random.random()) #windowX*0.5 + 240*(random.random()-0.5) ship_i.color = random_color() ship_i.size = 0.75*(random.random()**2)+minSize ship_i.species = i herb = random.random() carn = random.random() if(herb < herb_rate): ship_i.herbivore = 1 if(carn < carn_rate): ship_i.carnivore = 1 ship_i.size *= 2.0 Fishes.append(ship_i) fitness.append(10000) set_XY(i) points = [Fishes[i].posX, Fishes[i].posY, Fishes[i].X_2, Fishes[i].Y_2, Fishes[i].X_3, Fishes[i].Y_3, Fishes[i].X_4, Fishes[i].Y_4, Fishes[i].X_5, Fishes[i].Y_5, Fishes[i].X_3, Fishes[i].Y_3, Fishes[i].X_6, Fishes[i].Y_6] color_outline = 'black' if(Fishes[i].carnivore == 1): color_outline = 'red' if(Fishes[i].herbivore == 1): color_outline = 'green' if(Fishes[i].carnivore == 1 and Fishes[i].herbivore == 1): color_outline = 'white' if(not (Fishes[i].carnivore == 1) and not (Fishes[i].herbivore == 1)): color_outline = 'black' fish = Fishes[i] Shapes.append(canvas.create_polygon(points, outline=color_outline, fill=ship_i.color, width=2))
def createCreature(self, num=99999, name="bug"): cre = creature.Creature(num) cre._name = name cre._article = "a" cre._singledesc = name cre._pluraldesc = name + "s" cre._longdesc = "It's a long " + name cre._level = 1 cre._hostile = False cre._itemCatalog = ["Armor/1", "Weapon/1"] cre._numOfItemsCarried = [1, 2] cre.setHitPoints(20) cre.autoPopulateInventory() cre.setEnterRoomTime() assert cre.isValid() return cre
def test_creature_class(): x_ord = 10 y_ord = 15 creature = crt.Creature(x_ord, y_ord) assert creature.x == 10 assert creature.y == 15 assert creature.attack == 0 assert creature.move_speed == 0 assert creature.health == 0 x_ord = 15 y_ord = 20 test_skeleton = crt.Skeleton(x_ord, y_ord) assert test_skeleton.x == x_ord assert test_skeleton.y == y_ord assert test_skeleton.health == 25 assert test_skeleton.attack == 5 assert test_skeleton.move_speed == 1
def _generate_skeleton(x, y): """ Generates skeleton at coords (x, y) Args: x (int): x coord to generate monster at y (int): y coord to generate monster at """ ai_gen = ai.ChaseAI() creature_gen = creature.Creature("skeleton", True, "enemy", level=config.CURRENT_FLOOR) generated_enemy = entity.Entity(x, y, "skeleton", creature=creature_gen, ai=ai_gen) return generated_enemy
def populateInventory(self, iList): for itemName in iList: iType, iNum = itemName.split("/") if object.isObjectFactoryType(iType.lower()): # Objects logger.debug("In " + __class__.__name__ + ": creating obj " + str(iType) + ":" + str(iNum)) item = object.ObjectFactory(iType, iNum) item.load() self.addToInventory(item) elif iType == "Creature": # Creatures item = creature.Creature(iNum) logger.debug("In " + __class__.__name__ + ": creating cre " + str(iType) + ":" + str(iNum)) item.load() self.addToInventory(item) else: logger.debug("In " + __class__.__name__ + ": unknown " + str(iType) + " in " + str(object.ObjFactoryTypes)) print("Unknown Item type") return None
def generate_player(tree, player_class): """ Generates player in random room Args: player_class (String): Name of player class tree (BSP tree): Tree representing rooms """ room = random.choice(tree.root.child_room_list) x1, y1, x2, y2 = room.coords x = random.randint(x1, x2) y = random.randint(y1, y2) player_container = container.Container(inventory=[]) player_com = creature.Creature(player_class, team="player", load_equip_scheme=True) player = entity.Entity(x, y, player_class, creature=player_com, container=player_container) return player
def setUp(self): self.banner("start", testName=__class__.__name__) # Create one character of each classtype. # Store them in a dict with classname as the keys self.charDict = {} for oneClass in self.characterClasses: charObj = character.Character(acctName=self._testAcctName) charObj.setName("test" + oneClass.capitalize()) charObj.setGender("male") charObj.setClassName(oneClass) charObj.setAlignment("neutral") charObj.setMana(10000) charObj.setLevel(10) charObj.intelligence = 20 self.charDict[oneClass] = charObj # Set up targets for the spells self.targetCharObj = charObj self.targetCreaObj = creature.Creature(self.testCreatureNumber) self.targetDoorObj = object.Door(self.testObjNumber) self.roomObj = room.Room(99999)
def simulate(self): self.creatures = [] #clear creatures each time so one population #object can be used to generate multiple sets of #sim data print('Simulating ' + self.name) num = 1 if isinstance(self.initial_creatures, int): for i in range(self.initial_creatures): cre = creature.Creature() #Creature with default alleles cre.birthday = 0 cre.name = cre.alleles['color'] + " " + \ cre.alleles['shape'] + " " + str(num) self.creatures.append(cre) num += 1 elif isinstance(self.initial_creatures, list): for cre in self.initial_creatures: cre.birthday = 0 cre.name = cre.alleles['color'] + " " + \ cre.alleles['shape'] + " " + str(num) self.creatures.append(cre) num += 1 #self.apply_updates(0) #Catches any gene property changes at time 0 self.duration = int(self.duration) #Might be a float if calculated, idk. for t in range(0, self.duration): self.apply_updates(t) self.death(t) self.replicate(t) self.spontaneous_birth(t) #Make sure all creatures die at the end. :( #This makes things smoother elsewhere by ensuring deathday is a number for cre in self.creatures: if cre.deathday == None: cre.deathday = self.duration + 1 print("There are " + str(len(self.creatures)) + " creatures total in " + \ self.name)
def defineShips(): #Definir las naves al comienzo for i in range(np): W_i = [] mnd.setW(W_i) ship_i = creat.Creature( W_i, windowX * 8 / 10, windowY * 8 / 10, v_init, angle_init) #windowX*0.5 + 240*(random.random()-0.5) Ships.append(ship_i) fitness.append(10000) teta = Ships[i].orientation points = [ Ships[i].posX, Ships[i].posY, Ships[i].X_2, Ships[i].Y_2, Ships[i].X_3, Ships[i].Y_3 ] Shapes.append( canvas.create_polygon(points, outline='gray', fill='red', width=1)) rotationKillCounter.append(0)
def create_creatures(self): positions = [] i = 0 genes_this_run = self.gene_pool[self.run_num * 10:self.run_num * 10 + 10] new_genes = [] while i < 10: r = random.randint(0, 3895) pos = 0 if r <= 1198: pos = (r + 1, 0) elif r <= 1947: pos = (1199, r - 1198) elif r <= 3146: pos = (r - 1947, 749) elif r < 3896: pos = (0, r - 3146) c = creature.Creature(pos, genes_this_run[i], self.lock) flag = False for p in positions: if r - 50 < p < r + 50: flag = True if not flag: positions.append(r) self.creatures.append(c) new_genes.append(c.genes) else: i -= 1 i += 1 self.gene_pool[self.run_num * 10:self.run_num * 10 + 10] = new_genes
import creature from creature import Actions c = creature.Creature("HEUBERK THROPP", lvl=9) c.traits("UNIQUE", "LE", "MEDIUM", "HUMAN", "HUMANOID") c.perception("+14;") c.languages("Common, Dwarven, Elven, Gnoll, Halfling") c.skills("Athletics +16", "Deception +21", "Diplomacy +15", "Intimidation +19", "Mercantile Lore +16", "Society +16", "Thievery +16") c.attrs("Str +3", "Dex +2", "Con +3", "Int +1", "Wis +1", "Cha +4") c.item("dagger(3),") c.item("keys to manacles,") c.item("leather armor,") c.item("+1 striking mace,", magic=True) c.item("average manacles(marked with the symbol of the Scarlet Triad),") c.item("spellbook,") c.item("infiltrator’s thieves tools") c.ac("28") c.saves("Fort +21", "Ref +15", "Will +18") c.hp("155") c.reactive_ability( "Timely Distraction", Actions.REACTION, trigger= "A creature Heuberk can see within his melee reach misses him with a melee Strike.", effect= "Heuberk attempts to Feint the creature. If it’s not Heuberk’s turn and he gets a success, the effect applies on his next turn." ) c.speed("25 feet")
import creature from creature import Actions c = creature.Creature("Spawn of Dahak", lvl=8) c.traits("Rare", "CE", "SMALL", "CHARAU-KA", "DRAGON", "FIRE", "HUMANOID") c.perception("+16; darkvision, scent(imprecise) 30 feet") c.languages("Draconic, Mwangi") c.item("+1 striking warhammer", magic=True) c.skills("Arcana +12", "Athletics +18", "Crafting +10", "Intimidation +17", "Religion +14", "Stealth +15", "Survival +14") c.attrs("Str +6", "Dex +3", "Con +5", "Int +0", "Wis +4", "Cha +1") c.ac("27") c.saves("Fort +19", "Ref +13", "Will +16") c.hp("135") c.immunities("fire, paralyzed, sleep") c.reactive_ability("Tail Swipe", action=Actions.REACTION, trigger="A creature within reach of spawn of Dahak’s tail uses a move action or leaves a square during a move action it’s using.", effect="The spawn of Dahak makes a tail Strike at the creature with a –2 penalty. If it hits, it disrupts the creature’s action.") c.speed("30 feet, climb 30 feet") c.melee("warhammer +21 (magical, shove)", action=Actions.ONE, damage="2d8+9 bludgeoning (plus 1d5 fire if red-hot)") c.melee("jaws + 20", action=Actions.ONE, damage="2d8+9 piercing plus 2d4 fire") c.melee("claw + 20 (agile)", action=Actions.ONE, damage="2d8+9 slashing") c.melee("tail + 20 (reach 10 feet)", action=Actions.ONE, damage="2d8+9 slashing") c.ranged("thrown rock + 17 (deadly 1d6, thrown 20 feet)", action=Actions.ONE, damage="2d6+9 bludgeoning") c.offensive_ability("Breath Weapon", action=Actions.TWO, desc="The spawn of Dahak breathes flames that deals 9d6 fire damage to all creatures in a 30-foot cone(DC 26 basic Reflex save). It can’t use Breath Weapon again for 1d4 rounds.") c.offensive_ability("Draconic Frenzy", action=Actions.TWO, desc="The spawn of Dahak makes two claw Strikes and one bite Strike in any order.")
black = 0,0,0 green = 0,255,0 blue = 0,0,255 red = 255,0,0 white = 255,255,255 screen = pg.display.set_mode((0,0),pg.FULLSCREEN) screen_size = width, height = screen.get_size() mutation_rate = .01 tests = [] for i in range(6): c = [] for j in range(10): c.append( creature.Creature(5, 30, screen_size, [8,2], 0, i, simple=True) ) tests.append(c) clock = pg.time.Clock() GUI.main_menu(screen, screen_size) for generation in range(10000): for creature_set, i in zip(tests,range(len(tests))): creaturelocs = [i.headbody for i in creature_set] env = GUI.Environment(200, 30, (15,15), creaturelocs, screen_size) for timer in range(500): font = pg.font.SysFont('Comic Sans MS', 30) string = "Gen: " + str(generation) + ", group: " + str(i+1) string += ", timer: " + str(500 - timer) fontsurf = font.render(string, False, black) startrect = fontsurf.get_rect(topleft=(0,0)) pg.event.pump()
import creature import equipment testCreature = creature.Creature("Philllip", 1, 5, 7, 3, 20, 5, 7, 3, 20, None, None, 2, None, 3) print("No equipment:") print(testCreature) testAxe = equipment.Equipment("Axe of Axiness", None, None, 2, 0, 0, 0, 0, 0, 0, 0) testBoots = equipment.Equipment("Boots of Made-For-Walking", None, None, 0, 1, 3, 0, 0, 0, 0, 0) testCreature.equip(testAxe) testCreature.equip(testBoots) print("With equipment:") print(testCreature) print("Double-equip:") testCreature.equip(testAxe) testCreature.unequip(testBoots) print(testBoots) print("\nUnequipped boots:") print(testCreature) print(testBoots) print("Double-unequip:")
def spawn_creature(self, num): """spawns num creatures""" for _ in range(num): x_pos = random.randrange(1, 700) y_pos = random.randrange(1, 700) self.all_ctr.append(creature.Creature(x_pos, y_pos))
import creature from creature import Actions c = creature.Creature("SCARLET TRIAD SNEAKS", lvl=6) c.traits("UNCOMMON", "CE", "MEDIUM", "HUMAN", "HUMANOID") c.perception("+12") c.languages("Common") c.skills("Acrobatics +14", "Athletics +10", "Deception +12", "Intimidation +10", "Stealth +16", "Thievery +14") c.attrs("Str +2", "Dex +4", "Con +2", "Int +0", "Wis +0", "Cha +2") c.item("bloodseeker beak (affixed to rapier),", magic=True) c.item("dagger(3),") c.item("keys to manacles,") c.item("leather armor,") c.item("average manacles (marked with the symbol of the Scarlet Triad),") c.item("+1 rapier,", magic=True) c.item("thieves’ tools") c.ac("25") c.saves("Fort +10", "Ref +14", "Will +12") c.hp("95") c.reactive_ability( "Nimble Dodge", Actions.REACTION, requirements="A sneak can’t use this reaction while encumbered.", trigger= "The sneak is hit by an attack made by a creature the sneak can see.", effect= "The sneak gains a +2 circumstance bonus to their Armor Class against the triggering attack."
import creature from creature import Actions c = creature.Creature("Nessian Warhound (Elite)", lvl=10) c.traits("LE", "LARGE", "BEAST", "FIEND", "FIRE") c.perception("+21; darkvision, scent(imprecise) 120 feet") c.languages("Infernal(can’t speak any language)") c.skills("Acrobatics +20", "Athletics +21", "Stealth +20", "Survival +22 (+24 to Track)") c.attrs("Str +6", "Dex +5", "Con +5", "Int –2", "Wis +4", "Cha –2") c.ac("30") c.saves("Fort +23", "Ref +21", "Will +18") c.hp("170") c.immunities("fire") c.weaknesses("cold 10") c.reactive_ability("Hellish Revenge", action=Actions.REACTION, trigger="The Nessian warhound is critically hit by any Strike.", effect="The Nessian warhound’s Breath Weapon recharges. It can immediately use it as part of this reaction.") c.speed("40 feet") c.melee("jaws + 23 (magical)", action=Actions.ONE, damage="2d8+8 piercing plus 1d6 evil and 2d6 fire") c.offensive_ability("Breath Weapon", action=Actions.ONE, desc="(divine, evocation, fire) The warhound breathes flames that deal 11d6 fire damage to all creatures in a 15-foot cone (DC 30 basic Reflex save.) The warhound can’t use Breath Weapon again for 1d4 rounds. If the Nessian warhound would take fire damage or be targeted by a fire effect, its Breath Weapon recharges.")
import creature from creature import Actions c = creature.Creature("Kelleni (Elite Night Hag)", lvl=10) c.traits("NE", "Medium", "Fiend", "Hag", "Humanoid") c.perception("+20 darkvision") c.languages("Abyssal, Aklo, Celestial, Common, Infernal") c.skills("Arcana +20", "Deception +20", "Diplomacy +20", "Intimidation +16", "Occultism +22", "Religion +22") c.attrs("Str +5", "Dex +4", "Con +6", "Int +4", "Wis +5", "Cha +3") c.ability_modifier( "Coven", desc= "A night hag adds dominate, nightmare, scrying, and spellwrack to her coven’s spells." ) c.ability_modifier( "Nightmare Rider", desc= "When a night hag rides a nightmare, the nightmare also gains the night hag’s status bonus to saves against magic, and both the hag and rider benefit when the night hag uses her heartstone’s ethereal jaunt innate spell." ) c.item("heartstone", magic=True) c.ac("30") c.saves( "Fort +21", "Ref +19", "Will +20;", desc= "+2 status to all saves vs. magic, –2 to all saves if the night hag does not have her heartstone" )
def draw_best(self): bflg = self.best_from_last_gen if not isinstance(bflg, type(None)): self.lock.acquire() pygame.draw.rect(self.win, (255, 255, 255), pygame.rect.Rect(500, 385, 200, 112)) large_text = pygame.font.Font('freesansbold.ttf', 24) text_surf, text_rect = large_text.render("Best of last gen:", True, (0, 0, 0)), \ large_text.render("Best of last gen:", True, (0, 0, 0)).get_rect() text_rect.center = (600, 402) self.win.blit(text_surf, text_rect) self.lock.release() c = creature.Creature((600, 440), bflg, self.lock, True) for p in c.parts: p.determine_rotation(True) c.draw(self.win, False) self.lock.acquire() mid_text = pygame.font.Font('freesansbold.ttf', 13) text_surf, text_rect = mid_text.render("Fitness: " + str(int(getattr(bflg, "fitness"))), True, (0, 0, 0)),\ mid_text.render("Fitness: " + str(int(getattr(bflg, "fitness"))), True, (0, 0, 0)).get_rect() text_rect.center = (540, 450) self.win.blit(text_surf, text_rect) i = 0 for s in self.species.values(): for v in s: if v.fitness == bflg.fitness: n = i i += 1 text_surf, text_rect = mid_text.render("Species: " + str(n), True, (0, 0, 0)), \ mid_text.render("Species: " + str(n), True, (0, 0, 0)).get_rect() text_rect.center = (540, 470) self.win.blit(text_surf, text_rect) self.lock.release() self.lock.acquire() mid_text = pygame.font.Font('freesansbold.ttf', 18) text_surf, text_rect = mid_text.render("Gen# " + str(self.gen_num + 1) + ", Run# " + str(self.run_num), True, (255, 255, 255)), \ mid_text.render("Gen# " + str(self.gen_num + 1) + ", Run# " + str(self.run_num), True, (255, 255, 255)).get_rect() text_rect.center = (520, 512) self.win.blit(text_surf, text_rect) text_surf, text_rect = mid_text.render("# Species: " + str(100 if len(self.species) is 0 else len(self.species)), True, (255, 255, 255)), \ mid_text.render("# Species: " + str(100 if len(self.species) is 0 else len(self.species)), True, (255, 255, 255)).get_rect() text_rect.center = (680, 512) self.win.blit(text_surf, text_rect) self.lock.release()
import creature from creature import Actions c = creature.Creature("Coalgnasher (Elite Nightmare)", lvl=7) c.traits("NE", "Large", "Beast", "Fiend") c.perception("+16; darkvision") c.languages("Abyssal, Daemonic, Infernal") c.skills("Acrobatics +15", "Athletics +18", "Intimidation +16", "Survival +14") c.attrs("Str +6", "Dex +3", "Con +3", "Int +1", "Wis +4", "Cha +2") c.interaction_ability("Smoke", desc="(aura) 15 feet. The nightmare continually exhales black smoke that creates concealment in an aura around it. Nightmares and their riders can see through this smoke. A creature that begins its turn in the area becomes sickened 2 (DC 25 Fortitude negates) and is then temporarily immune to sickness from the smoke for 1 minute. The nightmare, its rider, any creature currently holding its breath (or that does not need to breathe), and any creature immune to poison are immune to the aura’s sickened effect, but not the concealment.") c.ac("26") c.saves("Fort +17", "Ref +17", "Will +14") c.hp("120") c.resistances("fire 10") c.speed("40 feet, fly 90 feet") c.melee("jaws +18 [+13/+8](evil, magical)", Actions.ONE, damage="2d10+8 piercing plus 1d6 evil") c.melee("hoof +18 [+14/+10](agile, evil, fire, magical)", Actions.ONE, damage="1d8+8 bludgeoning plus 1d6 evil and 1d8 fire") sg = c.spell_group("Divine Innate Spells", dc="26") sp = sg.spells(7) sp.spell("plane shift", desc="(self and rider only)", id="222") c.offensive_ability("Flaming Gallop", Actions.TWO, desc="(fire) The nightmare Strides or Flies up to triple its Speed. Its hooves burst with intense flame, dealing 3d6+2 fire damage (DC 26 basic Reflex save) once to each creature other than the nightmare’s rider that the nightmare moves adjacent to during its gallop.")