def Main_Window(self): self.display = pygame.display.set_mode((1280,720)) manager = ResManager() pygame.display.set_icon(manager.get_image('icon.png')) pygame.display.set_caption("War for cookies") self.map_type = self.core.load_file(self.map_name,self.file) self.display.fill((220,220,250)) pygame.display.flip() i = 0
def Main_Window(self): self.display = pygame.display.set_mode((1280,720)) manager = ResManager() pygame.display.set_icon(manager.get_image('icon.png')) pygame.display.set_caption("Map Editor") self.display.fill((220,220,250)) pygame.display.flip() i = 0
def Main_Window(self): self.display = pygame.display.set_mode((1280, 720)) manager = ResManager() pygame.display.set_icon(manager.get_image('icon.png')) pygame.display.set_caption("Map Editor") self.display.fill((220, 220, 250)) pygame.display.flip() i = 0
def __init__(self, width = 1280, height = 720, color = (255,255,255), fps = 40, scene = None, manager = ResManager()): pygame.init() self.set_display(width, height) self.fps = fps self.__manager = manager self.scene = scene # self.__display.fill(color) pygame.display.flip()
def __init__(self): self.manager = ResManager()
class Resources(): def __init__(self): self.manager = ResManager() def textures(self): textures = [] texture = self.manager.get_terrain("grass.png") texture = pygame.transform.scale(texture, (50, 50)) textures.append(texture) texture = self.manager.get_terrain("sand.png") texture = pygame.transform.scale(texture, (50, 50)) textures.append(texture) texture = self.manager.get_terrain("dirt.png") texture = pygame.transform.scale(texture, (50, 50)) textures.append(texture) texture = self.manager.get_terrain("water.png") texture = pygame.transform.scale(texture, (50, 50)) textures.append(texture) texture = self.manager.get_terrain("tree.png") texture = pygame.transform.scale(texture, (50, 50)) textures.append(texture) texture = self.manager.get_terrain("rock.png") texture = pygame.transform.scale(texture, (50, 50)) textures.append(texture) texture = self.manager.get_terrain("lava.png") texture = pygame.transform.scale(texture, (50, 50)) textures.append(texture) texture = self.manager.get_terrain("farm.png") texture = pygame.transform.scale(texture, (50, 50)) textures.append(texture) texture = self.manager.get_terrain("mine.png") texture = pygame.transform.scale(texture, (50, 50)) textures.append(texture) texture = self.manager.get_terrain("base_blue.png") texture = pygame.transform.scale(texture, (50, 50)) textures.append(texture) texture = self.manager.get_terrain("base_red.png") texture = pygame.transform.scale(texture, (50, 50)) textures.append(texture) return textures def colours(self): colour = [] for i in range(11): if i == 0: colour.append((0, 204, 0)) elif i == 1: colour.append((255, 204, 0)) elif i == 2: colour.append((153, 102, 51)) elif i == 3: colour.append((51, 51, 255)) elif i == 4: colour.append((51, 102, 51)) elif i == 5: colour.append((204, 204, 153)) elif i == 6: colour.append((204, 204, 102)) elif i == 7: colour.append((225, 225, 102)) elif i == 8: colour.append((0, 0, 0)) elif i == 9: colour.append((255, 51, 0)) elif i == 10: colour.append((51, 0, 255)) return colour def arrows(self): textures = [] for i in range(4): texture = self.manager.get_image("free-go" + str(i + 1) + ".png") texture = pygame.transform.scale(texture, (50, 50)) textures.append(texture) for i in range(4): texture = self.manager.get_image("enemy-go" + str(i + 1) + ".png") texture = pygame.transform.scale(texture, (50, 50)) textures.append(texture) return textures
class Resources(): def __init__(self): self.manager = ResManager() def textures(self): textures = [] texture = self.manager.get_terrain("grass.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("sand.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("dirt.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("water.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("tree.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("rock.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("lava.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("farm.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("mine.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("base_blue.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("base_red.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) return textures def colours(self): colour = [] for i in range(11): if i == 0: colour.append((0,204,0)) elif i == 1: colour.append((255,204,0)) elif i == 2: colour.append((153,102,51)) elif i == 3: colour.append((51,51,255)) elif i == 4: colour.append((51,102,51)) elif i == 5: colour.append((204,204,153)) elif i == 6: colour.append((204,204,102)) elif i == 7: colour.append((225,225,102)) elif i == 8: colour.append((0,0,0)) elif i == 9: colour.append((255,51,0)) elif i == 10: colour.append((51,0,255)) return colour def arrows(self): textures = [] for i in range(4): texture = self.manager.get_image("free-go"+str(i+1)+".png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) for i in range(4): texture = self.manager.get_image("enemy-go"+str(i+1)+".png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) return textures def textures_for_army(self): textures = [] fraction = ['neutral','red','blue'] type_units=['','_infantry','_marines','_btr','_tank','_artillery'] for i in range(len(fraction)): for j in range(len(type_units)): texture = self.manager.get_units(fraction[i]+type_units[j]+".png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) return textures def textures_for_battle_gialog_window(self): textures = [] names = ['dialog','buttom'] for i in range(len(names)): if i == 1: for j in range(3): texture = self.manager.get_menu(names[i]+'_'+str(j+1)+".png") textures.append(texture) else: texture = self.manager.get_menu(names[i]+".png") textures.append(texture) return textures def textures_for_menu(self): textures = [] for j in range(4): texture = self.manager.get_menu('0'+str(j+1)+".png") textures.append(texture) return textures
def main(): #************************** PARAMETERS ***************************** fileCollectionSimilarities = "./CollectionSimilarities/dbToDb.gov2.formattedExp" fileCollectionRanks = "./CollectionRanks/ranks_gov2_crcs_clustfuse_ideal_50_50_0.0_701-850" fileCollectionRanksUpd = "./CollectionRanks/ranks_gov2_crcs_clustfuse_ideal_50_50_0.0_701-850_upd" clusteringType = "online" fileCollectionRanksColumns = 3 clusterSize = 3 collectionRerankCutoff = 10 collectionSearchCutoff = 5 #******************************************************************* # compute clusters clustering = Clustering() clustering._readSimilarities(fileCollectionSimilarities) if clusteringType == OFFLINE_CLASTERING: clustering.computeOfflineClusters(fileCollectionSimilarities, clusterSize) #clustering.printClusters() # read collection scores resManager = ResManager() resManager.clean() resManager.readResults(fileCollectionRanks, fileCollectionRanksColumns) # open output stream otp = open(fileCollectionRanksUpd, 'w') # compute scores for query in resManager.getQueries(): if clusteringType == ONLINE_CLASTERING: initialCollectionSet = resManager.getDocs(query, collectionRerankCutoff) clustering.computeOnlineClusters(initialCollectionSet, clusterSize) print query, clustering.clusters.keys() print query, clustering.clusters scoreFunction = GeometricScoreFunction() clusterScores = scoreFunction.scoreClusters(clustering, resManager, query) # prepare result collection ranking boost = 100 rerankedCollections = scoreFunction.scoreCollections( clustering, resManager, clusterScores, query, boost) print query, rerankedCollections # check if number of re-ranked collections satisfies collection cutoff # if it does not, then append more collections to the end of the list if len(rerankedCollections) < collectionSearchCutoff: initialCollectionIds = resManager.getDocs(query) initialCollectionScores = resManager.getScores(query) pos = 0 while pos < len(initialCollectionIds) and len( rerankedCollections) < collectionSearchCutoff: collectionId = initialCollectionIds[pos] if not rerankedCollections.has_key(collectionId): rerankedCollections[ collectionId] = initialCollectionScores[pos] pos += 1 # save results to a file for collection in sorted(rerankedCollections.iteritems(), key=itemgetter(1), reverse=True): otp.write(" ".join([query, collection[0], str(collection[1])]) + '\n') otp.close() print "ready"
class Resources(): def __init__(self): self.manager = ResManager() def textures(self): textures = [] texture = self.manager.get_terrain("grass.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("sand.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("dirt.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("water.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("tree.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("rock.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("lava.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("farm.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("mine.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("base_blue.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) texture = self.manager.get_terrain("base_red.png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) return textures def colours(self): colour = [] for i in range(11): if i == 0: colour.append((0,204,0)) elif i == 1: colour.append((255,204,0)) elif i == 2: colour.append((153,102,51)) elif i == 3: colour.append((51,51,255)) elif i == 4: colour.append((51,102,51)) elif i == 5: colour.append((204,204,153)) elif i == 6: colour.append((204,204,102)) elif i == 7: colour.append((225,225,102)) elif i == 8: colour.append((0,0,0)) elif i == 9: colour.append((255,51,0)) elif i == 10: colour.append((51,0,255)) return colour def arrows(self): textures = [] for i in range(4): texture = self.manager.get_image("free-go"+str(i+1)+".png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) for i in range(4): texture = self.manager.get_image("enemy-go"+str(i+1)+".png") texture = pygame.transform.scale(texture,(50,50)) textures.append(texture) return textures