def breed( self, fac1, fac2 ): #start with first factions values as defaults f = faction.faction( **fac1.__dict__ ) for k in fac.ideal_values.keys(): if random.random > 0.5: fac.ideal_values[k] = fac2.ideal_values[k]
#create the factions factions = [] for ident in range( info.num_factions ): area = world.get_random_unclaimed_area() area.faction_control[ ident ] = 100 citypos = world.get_city_location( area ) newcity = world.cities[ citypos ] newcity.faction_ident = ident newcity.population = 100 fac = faction.faction( ident, out, name = info.faction_names[ ident ], cities = [ newcity ], potential_cities = world.linearize_cities(), areas = world.linearize_areas() ) fac.preprocess() factions.append( fac ) genes = geneticist.genetic( factions ) running = True while running: #poll input event = pygame.event.poll() while event.type != pygame.NOEVENT:
out = output.output( screen, 14 ) world = grid.grid( out, screen, (64,64), random_generator(36, 64) ) #create the factions area = world.get_area_at( 0, 0 ) area.faction_control[0] = 100 Thragg = world.cities[0] = city.city(area.pos, out, faction_ident=0, population=100, name="Thragg", area=area) orcs = faction.faction( 0, out, name = "orcs", cities = [ Thragg ], areas = world.linearize() ) orcs.preprocess() area = world.get_area_at( world.tile_dim[0]-1, world.tile_dim[1]-1 ) area.faction_control[1] = 100 Detroit = world.cities[ len(world.cities)-1 ] = city.city(area.pos, out, faction_ident=1, population=100, name="Detroit", area=area) humans = faction.faction( 1, out, name = "humans", cities = [ Detroit ], areas = world.linearize() )