def __init__(self, mapsize=(100, 100), tilesize=(5, 5), waterlevel=0.1): #Creating game map self.worldmap = worldmap.Map(mapsize, tilesize, waterlevel) self.creatures = [] self.zoo = zoo.Zoo() # all the brain subclasses self.brains = brain.Brain.__subclasses__() # all the brain subclasses self.numberOfBrains = len(self.brains) self.hueValues() #current number of alive creatures on the map self.noOfCreatures = 0 #minimum necessary number of alive creatures on the map self.lowerNoOfCreatures = 1 #max number of creatures that each brain class can have at the beginning of each round self.upperNoOfCreatures = 10 self.highScoreCreatures = {} self.highScoreThreshold = 0 self.keepTopK = 10
def __init__(self, mapsize=None): if not mapsize: mapsize = settings.MAP_SIZE self.AI = [] self.units = { } # instead of a list, it will point to the unit's attributes. self.all_units = { } # instead of a list, it will point to the unit's attributes. self.under_attack = set() self.mapSize = mapsize self.map = worldmap.Map(self.mapSize) self.currentTurn = 0 self.events = set() self.unitevents = defaultdict(set) self.unitstatus = defaultdict(object) self.buildings = {} #self.eventQueue = EventQueue(self.events, self.mapSize) self.unitfullpaths = defaultdict(bool) self.unitpaths = {} self.bulletpaths = {} self.bullets = {} self.died = [] self.dead_units = {} self.oldbullets = [] self.bullet_endings = defaultdict(bool) self.bulletRange = self.mapSize / 8 self.bulletSpeed = self.mapSize / 10
def __init__(self, **specArgs): self.movable_characters = [] self.map = worldmap.Map(30, 15) self.font = pygame.font.SysFont("couriernew", 24) cmntBlock = game_objects.CommentBlock() cmntBlock.setComment("Insert code below.") self.main_player = game_objects.MainPlayer( name="P1", load_function=pygame.image.load, # The sprite for the bot will just be the up picture for placeholder.." list_of_bots=[ game_objects.GenericBot("Stefan's Bot", "res/main_player/up.png", pOwned=True, queue_of_code_blocks=[cmntBlock]) ], directional_sprites=[ "res/main_player/up.png", "res/main_player/right.png", "res/main_player/down.png", "res/main_player/left.png" ], x=1, y=1, ) botBlocks = [] botSays = game_objects.SayBlock() botSays.setMessage("Beep boop") botBlocks.append(botSays) botBlocks.append(game_objects.FireballBlock(10, 5)) enemyLocations = self.map.getEnemyLocations() numEnemies = len(enemyLocations) for x in range(0, numEnemies): position = enemyLocations[x] xLoc = position[0] yLoc = position[1] self.enemy_player = game_objects.EnemyPlayer( name="AI-" + str(x), load_function=pygame.image.load, list_of_bots=[ game_objects.GenericBot("enemy's Bot", "res/main_player/up.png", queue_of_code_blocks=botBlocks, speed=8) ], directional_sprites=[ "res/main_player/up.png", "res/main_player/right.png", "res/main_player/down.png", "res/main_player/left.png" ], x=xLoc, y=yLoc) self.enemy_player.change_direction( self.enemy_player.current_direction, override_opt=True) self.movable_characters.append(self.enemy_player) self.main_player.change_direction(self.main_player.current_direction, override_opt=True) self.movable_characters.append(self.main_player) self.renderMenu = False self.activity = None self.menuIndex = 0
def setUp(self): self.map = wm.Map(100)
def setUp(self): self.map = worldmap.Map(100)
def __init__(self, mapsize=None): if not mapsize: mapsize = map_settings.MAP_SIZE self.mapSize = mapsize self.wt = worldtalker.WorldTalker(self) self.AI = [] # Map a unit or AI to a team self.teams = {} # Maps a team to its AI self.team_map = {} self.ai_cycler = itertools.cycle(self.AI) self.ai_profiles = {} self.units = {} # instead of a list, it will point to the unit's attributes. self.all_units = {} # instead of a list, it will point to the unit's attributes. self.end_game_units = None # number of units alive at end of game self.under_attack = set() map_settings.MAP_SIZE = mapsize self.map = worldmap.Map(map_settings.MAP_SIZE) self.currentTurn = 0 self.events = set() self.unitevents = defaultdict(set) self.unitstatus = defaultdict(object) self.ai_units = defaultdict(set) self.ai_new_units = defaultdict(set) self.ai_dead_units = defaultdict(set) self.ai_lost_buildings = defaultdict(set) self.ai_new_buildings = defaultdict(set) self.ai_highlighted_regions = defaultdict(set) self.ai_highlighted_lines = defaultdict(set) state = random.getstate() random.seed(map_settings.SEED) self.map_state = random.getstate() random.setstate(state) self.execution_times = defaultdict(lambda: defaultdict(int)) self.buildings = {} self.units_per_base = {} # These contain the amount of time left for a building to spawn a unit self.spawn_counters = defaultdict(int) self.spawn_points = defaultdict(int) # contains how many units are left per building self.spawn_resources = defaultdict(int) if map_settings.SPAWN_POINTS: for coord in map_settings.SPAWN_POINTS: if not isValidSquare(coord, self.mapSize): continue b = mapobject.Building(self.wt) self.buildings[b] = None self.spawn_points[b] = None self.map.placeObject(b, coord) if map_settings.BUILDINGS: for coord in map_settings.BUILDINGS: if not isValidSquare(coord, self.mapSize): continue b = mapobject.Building(self.wt) self.buildings[b] = None self.map.placeObject(b, coord) log.info('Adding %s buildings to map', map_settings.ADDITIONAL_BUILDINGS) for i in xrange(map_settings.ADDITIONAL_BUILDINGS): self.buildings[self.placeRandomBuilding()] = None self.unitfullpaths = defaultdict(bool) self.endpaths = defaultdict(object) self.unitpaths = {} self.bulletpaths = {} self.bullets = {} self.died = {} self.corpses = {} self.collisions = defaultdict(int) self.survivors = {} self.dead_units = {} self.oldbullets = [] self.bullet_endings = defaultdict(bool) self.bulletRange = map_settings.MAP_SIZE/map_settings.BULLET_RANGE_MODIFIER self.bulletSpeed = map_settings.MAP_SIZE/map_settings.BULLET_SPEED_MODIFIER self.__initStats() self.visibleunits = defaultdict(set) self.visiblebuildings = defaultdict(set) self.__calcVisibility()