def main(): b1 = building.Building("Math Building", 25) b2 = building.Building("Science Building", 17) b1.get_info() b2.get_info() #this is pretty cool, so I can create an empty list with [], and append it with #other objects as a parameter!! WHAHAHAHA c = campus.Campus([], 0, 0) c.get_info() #wanted to see output of campus with nothing in it c.add_building(b1) c.add_building(b2) c.get_info()
def add_floating_building(self, city_id): floating_building = building.Building() floating_building.special_floating(city_id) connector = db_connector.Building_Connector(self.loader) new_building_id = connector.write_to_db(floating_building) connector.close_session()
def add_building(self, building_dict, auto_populate, core_character=None, in_city_id='selected'): if in_city_id == 'selected': city_id = self.get_selected_city_id() else: city_id = in_city_id in_city = self.get_cities_from_db('id', city_id) in_city = in_city[0] new_building = building.Building(in_city) try: new_building.set_from_dialog(building_dict) except: raise Exception new_building.set_city_id(city_id) connector = db_connector.Building_Connector(self.loader) new_building_id = connector.write_to_db(new_building) connector.close_session() if auto_populate: # construction_info = catalogs_character.profession[new_building.kind][new_building.subkind] new_populator = populator.Populator(core_character, new_building, new_building_id, in_city, city_id, self.loader) new_populator.populate() self.query_buildings_name(city_id)
def generate_idf_string(unsafe_user_inputs): cleaned_inputs = validation.Validation().cleaned_inputs(unsafe_user_inputs) unicode_idf_file = unicode( IDF(idf_list=building.Building( _geometry_configurations(cleaned_inputs), cleaned_inputs).output_EP_list())) return unicode_idf_file
def __init__(self, size_x: int, size_y: int, heuristic: bool = True): pg.init() self.screen = pg.display.set_mode([size_x, size_y], pg.DOUBLEBUF) self.display = pg.display.set_caption("Deep Lift") self.clock = pg.time.Clock() self.bd = building.Building(self, self.screen) self.heuristic = heuristic self.total_reward = 0 self.display = True
def load_from_db(self, filter_by, filter_value): # return complete Building objects building_list = [] loaded_buildings = self.session.query(base.Building).filter( getattr(base.Building, filter_by) == filter_value).all() for select in loaded_buildings: new_building = building.Building() new_building.set_from_db(select) building_list.append(new_building) return building_list
def __init__(self, level): self.game_over = False self.level = level self.pause = False self.life_counter, self.coin_counter = game_data.player_stat[level] self.wave_agent = None self.wave_counter = 0 self.wave_max = len(game_data.waves[level]) self.monsters = [] self.projectiles = [] self.buildings = [] self.game_gui = gui.GameGUI(level) self.game_gui.score_life.update_score(str(self.life_counter)) self.game_gui.score_coin.update_score(str(self.coin_counter)) for pos in game_data.buildings_locations[level]: b = building.Building(pos) self.buildings.append(b) self.game_gui.add(b) self.clk = pygame.time.Clock()
def __init__(self): self._cloud_game = gl.Game(10, 10, 9, 5) self.screen_width = _INITIAL_WIDTH self.screen_height = _INITIAL_HEIGHT self._block_width = _INITIAL_WIDTH/10 self._block_height = _INITIAL_HEIGHT/10 self._game_size = 10 self._time = 15 self._drop_control = 8 self._running = True self._surface = None self._cat = octocat.Octocat() self._lightning = lightning.Lightning() self._building = building.Building() self._building_images = list() self.setup_building() self._block_dictionary = {gl.LIGHTNING: self._lightning.get_lightning(), gl.ON_FIRE: self._building.get_fire(), gl.EMPTY: None, gl.BUILDING: self._building.get_dict(), gl.CLOUD: self._cat.get_cloud(), gl.CAT: self._cat.get_cat(), gl.ELECTROCUTED_CAT: self._cat.get_electrocuted_cat()}
def generate_building_models(dict_raw_utility, cached_weather): # This function may take several minutes, print the progress v_building_ID = list(dict_raw_utility.keys()) v_EUI = np.empty(0) v_Model = np.empty(0) v_beta_base = np.empty(0) v_beta_betc = np.empty(0) v_beta_beth = np.empty(0) v_beta_cdd = np.empty(0) v_beta_hdd = np.empty(0) i = 0 for bldg_id in v_building_ID: i += 1 print('----------------------------------------------------') print("Fitting change-point model for all buildings.") print("Building ID: " + str(bldg_id)) bldg_name = str(bldg_id) + '_dummy_name' bldg_address = dict_raw_utility[bldg_id][0] bldg_area = dict_raw_utility[bldg_id][1] bldg_type = dict_raw_utility[bldg_id][2] currency = dict_raw_utility[bldg_id][3] utility_type = 'electricity' if dict_raw_utility[bldg_id][ 4] == 1 else 'fossil fuel' utility_temp = dict_raw_utility[bldg_id][5] if (hasattr(utility_temp, "df_raw_data")): # Proceed only if there is utility data for the current building building_temp = building.Building(bldg_id, bldg_name, bldg_address, bldg_type, bldg_area, currency) weather_temp = weather.Weather(building_temp.coord) building_temp.add_utility(utility_temp) building_temp.add_weather(cached_weather, weather_temp) has_fit = building_temp.fit_inverse_model() if (has_fit): v_EUI = np.append(v_EUI, np.nan) v_Model = np.append(v_Model, str(bldg_id)) v_beta_base = np.append( v_beta_base, building_temp.im_electricity.coeffs['base']) v_beta_betc = np.append( v_beta_betc, building_temp.im_electricity.coeffs['ccp']) v_beta_beth = np.append( v_beta_beth, building_temp.im_electricity.coeffs['hcp']) v_beta_cdd = np.append( v_beta_cdd, building_temp.im_electricity.coeffs['csl']) v_beta_hdd = np.append( v_beta_hdd, building_temp.im_electricity.coeffs['hsl']) print(str(i) + '/' + str(len(v_building_ID)) + " completed.") else: print( "No " + utility_type + " utility data found for current building, ", str(i) + '/' + str(len(v_building_ID)) + " completed.") d_bench_coeffs = { 'EUI': v_EUI, 'Model': v_Model, 'beta_base': v_beta_base, 'beta_betc': v_beta_betc, 'beta_beth': v_beta_beth, 'beta_cdd': v_beta_cdd, 'beta_hdd': v_beta_hdd } df_bench_coeffs = pd.DataFrame(d_bench_coeffs) return df_bench_coeffs
def load(self, filename): # If there is a mission loaded already close it if (self.is_loaded() == True): self.close() self.loaded = True self.mouseIsDown = False self.mouseRect = pygame.Rect(0, 0, 0, 0) self.selection = [] # Get stuff from wrapper self.wrapper = missionwrapper.Wrapper() self.wrapper.load(filename) terrainList = self.wrapper.GetMap() playerList = self.wrapper.GetPlayer() unitList = self.wrapper.GetUnits() objectiveList = self.wrapper.GetObjective() #Construct the list of Objectives for objtive in objectiveList: self.objectiveList.append(objective.Objective(objtive)) # Initialize the terrain grid holder = [] for line in terrainList: for char in line: #don't add the trailing newline if (char == '\n'): continue #append the char to the end of the list 'holder' holder[len(holder):] = [char] #all chars in 'line' are in holder self.terrainGrid.append(holder) #set holder to empty holder = [] # Initialize the Player objects index = 0 for player in playerList: player.replace('\n', '') aiA = "" strType = '' res1 = 1 res2 = 3 aiA, strType, res1, res2 = player.split() self.playerIdMap[index] = Player() self.playerIdMap[index].ai = aiA self.playerIdMap[index].type = strType self.playerIdMap[index].resource = (res1, res2) index = index + 1 # Load in and spawn units for units in unitList: units.replace('\n', '') playerObject = self.playerIdMap[0] #print self.playerIdMap #print playerObject #read each individual unit's line xA = 1 yA = 1 unitId = 1 playerId = 0 xA, yA, unitId, playerId = units.split() xA = float(xA) yA = float(yA) unitId = int(unitId) playerId = int(playerId) if (unitId == 3): unitObject = building.Building(self.playerIdMap[playerId], xA * 32, yA * 32, self.colorMap[playerId]) else: unitObject = soldier.Soldier(xA * 32, yA * 32, None, self.colorMap[playerId]) playerObject = self.playerIdMap[playerId] if (self.unitTable.get(playerObject) == None): self.unitTable[playerObject] = [] self.unitTable[playerObject].append(unitObject)
def __init__(self, *args, **kwargs): super(World, self).__init__(*args, **kwargs) self.scale = 1.0 self.pos = (0, 0, 0) self.fov = 75 self.render_distance = 100.0 self.window_x = 1080 self.window_y = 720 self.on_resize(self.window_x, self.window_y) glClearColor(1.0, 1.0, 1.0, 0.0) glEnable(GL_DEPTH_TEST) self.file_path = resource_path('textureImages') self.textures = self.load_textures() import random seed = random.randrange(1000, 9999) print 'seed ', seed shape = TerrainShape(seed=seed, island_location=(0, 0), size=4, height=.5) sand = Terrain(self.textures[0], shape, size=(20, 20), resolution=1) self.sand = sand self.draw_ables = [] self.update_ables = [] self.control_ables = [] self.point_ables = [] self.draw_ables_2d = [] self.loading = loading.Fact(self) self.update_ables.append(self.loading) self.loading_time_total = 10.0 self.loading_time = 0.0 fort = building.Building(sand, 1, 1, .1) fort_2 = building.Building(sand, 2, 1, .1) fort_3 = building.Building(sand, 1, 2, .2) fort_4 = building.Building(sand, 2, 2, .1) fort_outpost = building.Building(sand, -2, -2, .07) fort_king = building.Building(sand, 0, 0, .25) self.map = map.Map(self.textures[1], sand) self.update_ables.append(self.map) self.map.add_building(fort) self.map.add_building(fort_2) self.map.add_building(fort_3) self.map.add_building(fort_4) self.map.add_building(fort_outpost) self.map.add_building(fort_king) self.sky = sky.Sky(self.sand, self.textures[4]) self.draw_ables.append(self.sky) self.control_able_index = 0 self.default_controllable_index = 0 self.camera = FpsCamera(self, self.sand) self.control_ables.append(self.camera) noob = noobie.Noob(self, self.sand, self.map.get_buildings()) self.draw_ables.append(noob) self.update_ables.append(noob) # self.sprite = sprite.Sprite(self, self.map.land) # self.control_ables.append(self.sprite) # self.draw_ables.append(self.sprite) # self.update_ables.append(self.sprite) # self.point_ables.append(self.sprite) self.selector = selector.Selector(shape=sand, window=self) self.draw_ables.append(self.selector) self.update_ables.append(self.selector) self.input_handler = inputHandler.InputHandler() self.push_handlers(self.input_handler) self.c_bumped = self.input_handler.add_bumped(pyglet.window.key.C) self.v_bumped = self.input_handler.add_bumped(pyglet.window.key.V) self.b_bumped = self.input_handler.add_bumped(pyglet.window.key.B) self.n_bumped = self.input_handler.add_bumped(pyglet.window.key.N) self.b_switch = False self.period_bumped = self.input_handler.add_bumped( pyglet.window.key.PERIOD) self.comma_bumped = self.input_handler.add_bumped( pyglet.window.key.COMMA) self.reset_control() self.draw_number = 0 # the first rendered frame is 1 pyglet.clock.schedule_interval(self.update, 1 / 60.0)
def addBuilding(self, name, size, address): newBuilding = building.Building(name, size, address) self._buildings.append(newBuilding)
def load(self): levels = self.get_levels() if self.level_id > len(levels) - 1: self.app.set_state(main.WIN) self.app.score_manager.save() else: self.app.gui_manager.set_state(gui_manager.FADE_IN) self.app.game_manager.clear_level() self.level_name = levels[self.level_id] self.app.gui_manager.update_times( self.app.score_manager.run_scores.get( util.get_filename(self.mode, self.level_name), 0), self.app.score_manager.get_record(self.mode, self.level_name)) # map_data = levels.levels[self.level_id]() if self.mode == 0: directory = 'levels' elif self.mode == 1: directory = 'survival' with open('{}/{}.dat'.format(directory, self.level_name), 'rb') as f: map_data = pickle.load(f) scene = self.app.renderer.scene model_name, texture = map_data['terrain'] self.app.game_manager.terrain = terrain.Terrain( self.app, model_name, texture) scene.add(self.app.game_manager.terrain.canvas) self.app.game_manager.player.spawn(map_data['spawn_pos']) if self.mode == 0: self.app.game_manager.goal.spawn(map_data['goal_pos']) elif self.mode == 1: self.app.game_manager.goal.despawn() for data in map_data['buildings']: b = building.Building(self.app, building.Building.data[data[0]], data[1:4], data[4]) # b = building.Building(self.app, building.Building.data[data[0]], data[1:4], 0) self.app.game_manager.game_objects.add(b) scene.add(b.canvas) for data in map_data['platforms']: if data[0] == 0: platform.Hedge(self.app, data[1:4]) elif data[0] == 1: platform.InvisiblePlatform(self.app, data[1:4]) elif data[0] == 2: platform.LavaPlatform(self.app, data[1:4]) elif data[0] == 3: platform.Trampoline(self.app, data[1:4]) for data in map_data['elevators']: e = elevator.Elevator(self.app, data[1:4], data[4]) self.app.game_manager.game_objects.add(e) # spawn later scene.add(e.canvas) for data in map_data['powerups']: if data[0] == 0: e = powerup.Fuel(self.app, data[1:4]) self.app.game_manager.game_objects.add(e) # spawn later scene.add(e.canvas) elif data[0] == 1: e = powerup.Health(self.app, data[1:4]) self.app.game_manager.game_objects.add(e) # spawn later scene.add(e.canvas) elif data[0] == 2: e = powerup.SlowTime(self.app, data[1:4]) self.app.game_manager.game_objects.add(e) # spawn later scene.add(e.canvas) for data in map_data['vehicles']: if data[0] == 0: v = car.Car(self.app) elif data[0] == 1: v = helicopter.Helicopter(self.app) v.spawn(data[1:4]) for data in map_data['enemies']: if data[0] == 0: enemy.Turret(self.app, data[1:4]) elif data[0] == 1: enemy.Bee(self.app, data[1:4]) elif data[0] == 2: enemy.BowlSpawner(self.app, data[1:4]) elif data[0] == 3: enemy.InvisibleEnemy(self.app, data[1:4]) self.app.game_manager.set_state(self.mode)
def run_single(bldg_id=1, saving_target=2, anio=3, r=4, space_type='Office', cached_weather=True, write_fim=True, write_model=True, return_data=False, use_default_benchmark_data=True, df_user_bench_stats_e=None, df_user_bench_stats_f=None): # Set paths s_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) data_path = s_path + '/Data/' report_path = s_path + '/outputs/' # Create an outputs directoty if there isn't one. if not os.path.exists(report_path): os.makedirs(report_path) # Initialize a portfolio instance p = portfolio.Portfolio('Test') # p.read_raw_data_from_xlsx(data_path + 'portfolio.xlsx') p.read_raw_data_from_xlsx(data_path + 'portfolio.xlsx') # Get building data from the portfolio building_id = bldg_id building_info = p.get_building_info_by_id(building_id) if (building_info == None): return False, None else: building_test = building.Building(building_id, *building_info, saving_target) # Get utility data from portfolio df_raw_electricity = p.get_utility_by_building_id_and_energy_type( building_ID=building_id, energy_type=1, anio=anio) df_raw_fossil_fuel = p.get_utility_by_building_id_and_energy_type( building_ID=building_id, energy_type=2, anio=anio) df_raw_utility_e = df_raw_electricity df_raw_utility_f = df_raw_fossil_fuel utility_test_e = utility.Utility('electricity', df_raw_utility_e) utility_test_f = utility.Utility('fossil fuel', df_raw_utility_f) building_test.add_utility(utility_test_e, utility_test_f) weather_test_e = weather.Weather(building_test.coord) weather_test_f = weather.Weather(building_test.coord) building_test.add_weather(cached_weather, weather_test_e, weather_test_f) # Fit inverse model and benchmark has_fit = building_test.fit_inverse_model() # Continue only if there is at least one change-point model fit. if has_fit: if (use_default_benchmark_data): building_test.benchmark() building_test.ee_assess() else: # Note: the benchmark data sets are generated from the portfolio spreadsheet. # 1 ~ electricity; 2 ~ fossil fuel dict_raw_electricity = p.get_portfolio_raw_data_by_spaceType_and_utilityType( space_type, utility_type=1) dict_raw_fossil_fuel = p.get_portfolio_raw_data_by_spaceType_and_utilityType( space_type, utility_type=2) # Generate the benchmark stats from the user provided data in the portfolio spreadsheet if df_user_bench_stats_e is None: df_user_bench_stats_e = p.generate_benchmark_stats_wrapper( dict_raw_electricity, cached_weather) if df_user_bench_stats_f is None: df_user_bench_stats_f = p.generate_benchmark_stats_wrapper( dict_raw_fossil_fuel, cached_weather) building_test.benchmark( use_default=False, df_benchmark_stats_electricity=df_user_bench_stats_e, df_benchmark_stats_fossil_fuel=df_user_bench_stats_f) building_test.ee_assess( use_default=False, df_benchmark_stats_electricity=df_user_bench_stats_e, df_benchmark_stats_fossil_fuel=df_user_bench_stats_f) building_test.calculate_savings() building_test.plot_savings() building_test.disaggregate_consumption_wrapper() # Output to files # Save FIM to csv #if (hasattr(building_test, 'FIM_table_e')): #if write_model: building_test.coeff_out_e.to_csv(report_path + 'bldg_' + str(building_test.bldg_id) + "_Electricity Coeffs_out.csv") #if write_fim: building_test.FIM_table_e.to_csv(report_path + 'bldg_' + str(building_test.bldg_id) + "_Electricity FIM_recommendations.csv") #if (hasattr(building_test, 'FIM_table_f')): #if write_model: building_test.coeff_out_f.to_csv(report_path + 'bldg_' + str(building_test.bldg_id) + "_Fossil Fuel Coeffs_out.csv") #if write_fim: building_test.FIM_table_f.to_csv(report_path + 'bldg_' + str(building_test.bldg_id) + "_Fossil Fuel FIM_recommendations.csv") if r == 1: # Generate static HTML report report_building = report.Report(building=building_test) report_building.generate_building_report_beta(report_path) return True, building_test else: cont = 0
def loadBuilding(fileName): document = xml.dom.minidom.parse(fileName) element = document.childNodes[0] return building.Building(element)
def main(): """Entry point of program. Parameters: None Returns: None """ # 1.0 GET CSV DATA path = 'wright_buildings.csv' data = read_csv(path) print(f"\n {data}") # 1.1 CREATE BUILDING # Import building classes above # Fallingwater, Frank Lloyd Wright (1935) # 1491 Mill Run Rd, Mill Run, PA 15464 # https://fallingwater.org/ building = bld.Building('Fallingwater', 39.906431, -79.467943) # 1.2 PRINT BUILDING TYPE IRI AND ID print( f"\n{building.name}\niri = {building.type_iri}\nid = {building.id_}\n") # 1.2 SUBCLASS CHECK print( f"Building subclass of Zone = {issubclass(bld.Building, bld.Zone)}\n") # 1.3 INSTANCE CHECK print( f"building instance of Building = {isinstance(building, bld.Building)}\n" ) # 1.4 ADD FLOORS AND ROOMS FROM CSV DATA building = add_stories_and_spaces(building, data) # 1.5 UNCOMMENT COUNT NUM ROOMS PER FLOOR for story in building.stories: print(f"{story.name} rooms = {story.num_spaces()}") print('\n') # padding # 1.6 PRINT TO SCREEN BUILDING FLOORS AND ROOMS print(building) # 1.7 WRITE BUILDING TO FILE path = f"{building.name.replace(' ', '_').lower()}.txt" # dynamic file naming write_file(path, building.__str__()) # 2.0 PROCESS OTHER BUILDING INFO # Meyer May House, Frank Lloyd Wright (1908-09) # Wright's "Prairie School era Masterpiece" # 450 Madison Ave SE, Grand Rapids, MI 49503 # https://meyermayhouse.steelcase.com/ building = bld.Building('Meyer May House', 42.954387, -85.658782) building = add_stories_and_spaces(building, data) path = f"{building.name.replace(' ', '_').lower()}.txt" write_file(path, building.__str__()) # Palmer House, Frank Lloyd Wright (1950) # 227 Orchard Hills Dr, Ann Arbor, MI 48104 # http://flwpalmerhouse.com/ building = bld.Building('Palmer House', 42.278714, -83.715812) building = add_stories_and_spaces(building, data) path = f"{building.name.replace(' ', '_').lower()}.txt"
def update(self, delta_time): if self.loading_time <= self.loading_time_total: self.loading_time += delta_time self.loading.update(delta_time) return if self.v_bumped.get_bumped(): self.increment_control() if self.c_bumped.get_bumped(): self.reset_control() if self.b_bumped.get_bumped(): self.b_switch = not self.b_switch if self.b_switch: self.camera.point_at(self.sprite) else: self.camera.cancel_pointing() if self.n_bumped.get_bumped(): insert_sprite = boat.BeachAble(self, self.map.land, random_xy=True) self.control_ables.append(insert_sprite) self.draw_ables.append(insert_sprite) self.update_ables.append(insert_sprite) self.point_ables.append(insert_sprite) if self.period_bumped.get_bumped(): x, y = self.selector.get_mat_selection() if self.map.try_delete(x, y): pass else: import building import random scale = random.uniform(.05, .15) insert_building = building.Building(scale=scale, shape=self.sand, x=x, y=y) self.map.add_building(insert_building) if self.comma_bumped.get_bumped(): x, y = self.selector.get_mat_selection() if self.map.try_delete(x, y): pass else: import building import random scale = random.uniform(.2, .35) insert_building = building.Turret( self.sand, x, y, scale, pointer_pointer=self.point_ables) self.map.add_building(insert_building) self.camera.update(delta_time) i = 0 # looks through each element and deletes or updates while i < len(self.update_ables): if self.update_ables[i].clean(): del self.update_ables[i] else: self.update_ables[i].update(delta_time) i += 1 i = 0 # looks through other list while i < len(self.point_ables): if self.point_ables[i].clean(): del self.point_ables[i] else: i += 1