Exemplo n.º 1
0
def main():
    build = Building("Math Building", 25)
    build2 = Building("Science Building", 17)
    camp = Campus()
    build.get_info()
    build2.get_info()
    camp.add_building(build)
    camp.add_building(build2)
    camp.get_info()
Exemplo n.º 2
0
Arquivo: main.py Projeto: NOdoff/OOP
def main():
    b = Building("Math Building", 25)
    c = Campus()
    n = Building("Science Building", 17)
    b.get_info()
    n.get_info()
    c.add_building(b)
    c.add_building(n)
    c.get_info()
Exemplo n.º 3
0
def main():
    mb = Building('"Math Building"', 25)
    sb = Building('"Science Building"', 17)
    mb.get_info()
    sb.get_info()

    campus_total = Campus('"Math Building"', 1, 25)
    campus_total.add_building('"Science Building"', 1, 17)
    campus_total.get_info()
    campus_total.name_b()
Exemplo n.º 4
0
def main():
    math_building = Building("Math Building", 25)
    math_building.get_info()

    science_building = Building("Science Building", 17)
    science_building.get_info()

    my_campus = Campus()
    my_campus.add_building(math_building)
    my_campus.add_building(science_building)
    my_campus.get_info()
Exemplo n.º 5
0
 def add_building(self, building_id, building_bag_id, geometry,
                  ground_level, roof_level):
     building = Building(building_id, building_bag_id, geometry,
                         ground_level, roof_level)
     self.buildings[building_id] = building
     self.buildings_geometry.append(building.polygon)
     self.polygon_id_to_building_id[id(building.polygon)] = building_id
Exemplo n.º 6
0
    def build_structure(self, worker, building_type, building_id):
        """
        Build building at tiles position.

        :param tile: hex object
        """
        tile = worker.position
        if tile.building is None and isinstance(worker, Worker)\
                and tile.civ_id == worker.civ_id\
                and self.gold >= Building.buy_cost(building_type)[CurrencyType.
                                                                  GOLD]\
                and self.resources[ResourceType.GEMS] >=\
                Building.buy_cost(building_type)[ResourceType.GEMS]\
                and worker.actions > 0:
            city_id = tile.city_id
            building = Building(building_id, building_type, tile,
                                worker.civ_id, city_id)
            self.gold -= Building.buy_cost(building_type)[CurrencyType.GOLD]
            tile.building = building
            self.cities[city_id].buildings[building_id] = building
            worker.actions -= 1
            return True
        else:
            self._logger.debug("Unable to build structure.")
        return False
Exemplo n.º 7
0
 def test_init(self):
     building = Building(key='csc',
                         name='Computing Science Center',
                         lat=53.526757,
                         lon=-113.529391)
     assert building
     assert isinstance(building, Building)
Exemplo n.º 8
0
def main():
    num_passengers = int(input("How many passengers does the building have?"))
    num_floors = int(input("How many floors does the building have?"))
    strategy = int(input("Which strategy do you want to use? (1 for FIFO, 2 for move-to-max-min)"))
    building = Building(num_passengers, num_floors)
    elevator = Elevator(num_floors)
    passengers = []
    for i in range(num_passengers):
        start_floor = random.choice(range(elevator.n_floors))
        destination_floor = random.choice(range(elevator.n_floors))
        while start_floor == destination_floor:
            destination_floor = random.choice(range(elevator.n_floors))
        passenger = Passenger(start_floor, destination_floor)
        passengers.append(passenger)
        elevator.add_call(passenger.start_floor, passenger.destination, passenger)
    if strategy == 1:
        for passenger in passengers:
            elevator.FIFO()
    else:
        elevator.max_floor_strategy()
    print "\n"
    costs = []
    for passenger in passengers:
        costs.append(passenger.time_cost)

    print "Average cost: ", np.mean(costs), " floors"
    print "Average squared cost: ", np.mean([i**2 for i in costs]), " floors"
    print "Median cost: ", np.median(costs), " floors"
    print "Maximum cost: ", max(costs), " floors"
Exemplo n.º 9
0
    def replaceBuilding(self, index, building_proj):
        building = self.buildings[index]
        # vai se tentar construir building no mesmo sitio que o outro estava
        mrow = building.mrow
        mcol = building.mcol

        new_map = removeFromMap(self.map, building)

        # check if new building can replace the one to be replaced
        for prow in range(building_proj.rows):
            for pcol in range(building_proj.cols):
                if building_proj.plan[prow][pcol] == '#':
                    if mrow + prow >= self.city.rows or mcol + pcol >= self.city.cols:
                        return False
                    if new_map[mrow + prow][mcol + pcol] == '.':
                        new_map[mrow + prow][mcol +
                                             pcol] = building.building_id
                    else:
                        return False
        # copiar buildings e substituir building a ser substituito pelo novo mas com o mesmo building_id
        new_buildings = deepcopy(self.buildings)
        new_buildings[index] = Building(building_proj, mrow, mcol,
                                        building.building_id)
        # calcular score usando a mesma cidade, tirando do score o contributo do edificio removido, etc etc e no fim
        # parametro opcional para passar index do novo building na lista dos buildings
        new_score = self.calculateScore(self.city.walk_dist,
                                        self.score - building.score, new_map,
                                        building_proj, mrow, mcol,
                                        new_buildings,
                                        building.building_id - 1)
        new_buildings[index].score = new_score - (self.score - building.score)

        return State(self.city, new_buildings, new_map, new_score)
Exemplo n.º 10
0
  def populate(self):
    if self.has_restarted:
      self.row_offset = self.current_idx
      self.has_restarted = False
    
    self.get_enigma_data()

    for address in self.data:
      building = Building(address)
      building.get_bis()
      if driver.title != DEFAULT_TITLE:
        print("Overworked server. Starting again.")
        while driver.title != DEFAULT_TITLE:
          timer = Timer(1.0, building.get_bis)
          timer.start()
      building.get_bis_data()
      if driver.title != PROPERTY_PROFILE_TITLE:  # listing not found -- move to next index
        print("Listing does not exist in BIS network")
        continue  # exit out of loop and proceed to next entry
      building.get_building_id()
      
      is_duplicate = building.check_if_duplicate()
      if is_duplicate:
        print("Duplicate entry: #{}".format(building.building_id))
        continue
      
      building.get_lat_long_coordinates()
      building.get_complaints_and_violations()      
      building.post_data()
      driver.quit()
Exemplo n.º 11
0
def random_set(num, right, height):
    from random import randint
    for b in range(num):
        one = randint(1, right)
        w = randint(1, 8)
        ht = randint(1, height)
        yield Building(one, one + w, ht)
Exemplo n.º 12
0
 def addBuilding(self, id_, name, latitude, longitude):
     if id_ not in self.buildings:
         build = Building(id_, name, float(latitude), float(longitude))
         self.buildings[build.id] = build
         f = open('buildings.pkl', 'wb')
         pickle.dump(self.buildings, f)
         f.close()
Exemplo n.º 13
0
def main():
    mybuilding = Building(floors=18,
                          floorheight=4.1)
    mybuilding.elevator = Elevator()
    print(mybuilding.elevator)
    mybuilding.populate()
    phys = Physics(building=mybuilding, hours=10)
    print(phys.building.elevator)
Exemplo n.º 14
0
 def test_create_building(self):
     data = ("Екатеринбрг", "улица Тургенева", "4", [])
     build = Building(address=data[1],
                      house_number=data[2],
                      references=data[3],
                      city=data[0])
     self.assertEqual(("Екатеринбрг", "Тургенева", "4"),
                      (build.city, build.address, build.house_number))
Exemplo n.º 15
0
 def __init__(self, x, y, node_type):
     Location.__init__(self, x, y)
     self.important = False
     if node_type == 'N' or node_type == 'M':
         self.owner = PlayerColor.NEUTRAL
         self.building = Building(BuildingType.EMPTY, UnitType.EMPTY)
         self.important = node_type == 'M'
     elif node_type == 'B':
         self.owner = PlayerColor.BLUE
         self.building = Building(BuildingType.HOME, UnitType.PIKEMAN)
         self.important = True
     elif node_type == 'R':
         self.owner = PlayerColor.RED
         self.building = Building(BuildingType.HOME, UnitType.PIKEMAN)
         self.important = True
     self.spawn_timer = 0
     self.exit_direction = {PlayerColor.RED: None, PlayerColor.BLUE: None}
     self.unit_in_loc = self.unit_in_loc
Exemplo n.º 16
0
 def execute_build_building(self, node, building_type):
     if node and node.owner is self.color:
         if node.building and node.building.type is building_type:
             return
         if self.gold >= util.BUILDING_COST:
             node.building = Building(building_type, self.unit_pref)
             self.gold -= util.BUILDING_COST
             if node.building.can_spawn_unit():
                 self.unit_pref = UnitType.get_next(self.unit_pref)
Exemplo n.º 17
0
    def __init__(self, screenSize):
        self.done = False
        self.screen = pg.display.set_mode(screenSize)
        pg.display.set_caption("Widget Factories!")
        self.clock = pg.time.Clock()
        self.fps = 60
        self.bgColour = pg.Color("gray5")

        # group to hold background clouds
        self.clouds = pg.sprite.Group()
        # Create initial random clouds and add to sprite groups
        i = 0
        while i < WORLD_WIDTH:
            newCloud = Cloud((i, randint(0, GROUND - 100)))
            self.clouds.add(newCloud)
            ALL_SPRITES.add(newCloud, layer=0)  # clouds = layer 0
            i += randint(200, 400)

        # Create custom events for moving clouds, and adding a new cloud
        self.moveCloud = pg.USEREVENT + 1
        pg.time.set_timer(self.moveCloud, 3000)
        self.addCloud = pg.USEREVENT + 2
        pg.time.set_timer(self.addCloud, randint(30000, 40000))

        # add buildings
        newShop = Building(SHOP_FILENAME, (WORLD_WIDTH // 2, GROUND))
        BUILDINGS.add(newShop)
        ALL_SPRITES.add(newShop, layer=1)  # buildings = layer 1

        # Set up players (with personal camera)
        self.players = pg.sprite.Group()

        if SINGLE_PLAYER:
            self.isSplitScreen = False
            self.player1 = Player(TRUCK_FILENAME, (50, GROUND),
                                  screenSize,
                                  P1_MAP,
                                  colour=pg.Color('sienna2'))
            self.players.add(self.player1)
            ALL_SPRITES.add(self.player1, layer=2)  # players = layer 2
        else:
            self.isSplitScreen = True
            splitCamSize = (screenSize[0] // 2, screenSize[1])
            self.player1 = Player(TRUCK_FILENAME, (50, GROUND),
                                  splitCamSize,
                                  P1_MAP,
                                  colour=pg.Color('sienna2'))
            self.player2 = Player(
                TRUCK_FILENAME, (WORLD_WIDTH - 100, GROUND),
                splitCamSize,
                P2_MAP,
                orientation="LEFT",
                colour=pg.Color('blue'))  # player2 starts from right
            self.players.add(self.player1, self.player2,
                             layer=2)  # players = layer 2
            ALL_SPRITES.add(self.player1, self.player2, layer=2)
Exemplo n.º 18
0
def main():
    """Driver code."""
    try:
        floors = int(input('Number of floors: '))
        customers = int(input('Number of customers: '))
        building = Building(floors, customers)

    except ValueError:
        print('Not a valid integer.')
        main()
Exemplo n.º 19
0
 def _get_buildings(self):
     self.cur.execute(
         """SELECT gid, z, ST_X(ST_Centroid(geom)), ST_Y(ST_Centroid(geom))  FROM {0}
                         WHERE geom && ST_MakeEnvelope({1}, {2}, {3}, {4}, {5})
                     """.format(self.osm_table, self.working_area[0],
                                self.working_area[1], self.working_area[2],
                                self.working_area[3], self.srid))
     self.buildings = []
     for b in self.cur:
         self.buildings.append(Building(b))
Exemplo n.º 20
0
 def test_getters(self):
     building = Building(key='csc',
                         name='Computing Science Center',
                         lat=53.526757,
                         lon=-113.529391)
     assert building.get_key() == 'csc'
     assert building.get_name() == 'Computing Science Center'
     assert building.get_lat() == 53.526757
     assert building.get_lon() == -113.529391
     assert building.get_coords() == (53.526757, -113.529391)
Exemplo n.º 21
0
 def __init__(self, vision, controller, window):
     self.vision = vision
     self.controller = controller
     self.window = window
     self.current_resource = 2
     self.train_troops = 0
     self.state = State(vision, controller, window)
     self.gather = Gather(vision, self.state, controller)
     self.building = Building(vision, self.state, controller, window)
     self.quest = Quest(vision, controller)
     self.last_inf_check = 0
     self.last_shelter_check = 0
Exemplo n.º 22
0
 def refresh_units(self):
     logging.info("Refreshing units")
     for building in self.web.get_buildings():
         if building['id']:
             self.buildings[building['id']] = Building(building)
     for id, building in self.buildings.items():
         units = self.web.get_units_from_building(building.id)
         for unit in units:
             # if (unit['id'] not in self.units):
                 # logging.info('Found unit {} - {} stationed at {} - {}'.format(unit['id'], unit['c'], building.id, building.name))
             self.units[unit['id']] = Unit(unit, building)
             if (unit['fms_real'] == 5):
                 self.web.medical_transport(unit['id'])
Exemplo n.º 23
0
 def save_load_events(self):
     for e in pygame.event.get():
         # quitter le jeu de force
         if e.type == pygame.QUIT:
             self.run = False
             pygame.quit()
         # récupérer les coordonnées de clic de la souris
         if e.type == pygame.MOUSEBUTTONDOWN:
             x = pygame.mouse.get_pos()[0]
             # False to save and True to load
             if x < self.bg.w / 2:
                 self.s_l_choice = False
             else:
                 self.s_l_choice = True
         # vérification du point de relâchement du clic de la souris
         if e.type == pygame.MOUSEBUTTONUP:
             x = pygame.mouse.get_pos()[0]
             # charger les données de sauvegarde
             if self.s_l_choice and x > self.bg.w / 2:
                 infos = decoding()
                 print(infos)
                 self.buildings.empty()
                 self.gold.quantity, self.stuff.quantity = infos[0]
                 self.gold.add(0)
                 self.stuff.add(0)
                 self.bg.x, self.bg.y, self.bg.zoom = infos[1]
                 for b in infos[2]:
                     type = self.dict_loading[b[0][0]]
                     image = self.pictures[type]
                     batiment = Building(image, b[1], b[2], self.bg, type)
                     self.buildings.add(batiment)
                 self.s_l = False
                 self.win.fill((0, 0, 0))
             # sauvegarder les données de sauvegarde
             elif not self.s_l_choice and x < self.bg.w / 2:
                 resources = [self.gold.quantity, self.stuff.quantity]
                 building = []
                 for b in self.buildings:
                     building.append([b.type, b.gap_x, b.gap_y])
                 data = [
                     resources, [self.bg.x, self.bg.y, self.bg.zoom],
                     building
                 ]
                 encode(data)
                 self.s_l = False
                 self.win.fill((0, 0, 0))
         # si la touche escape est pressée, le menu save/load est fermé
         if e.type == pygame.KEYDOWN:
             if e.key == pygame.K_ESCAPE:
                 self.s_l = False
                 self.win.fill((0, 0, 0))
Exemplo n.º 24
0
	def _create_building(self, orientation):
		WELL_OUTER = (Vec3(0,0,0), Vec3(-5,0,-5))
		WELL_CORE = (Vec3(-1,0,-1), Vec3(-4,0,-4))
		WELL_INNER = (Vec3(-2,0,-2), Vec3(-3,0,-3))
		WELL_WIDTH = 6

		WELL_BASE = []
		WELL_BASE.append(BuildingBlock(WELL_CORE[0], block.COBBLESTONE, WELL_CORE[1]))

		WELL_WATER = []
		WELL_WATER.append(BuildingBlock(WELL_CORE[0], block.COBBLESTONE, WELL_CORE[1]))
		WELL_WATER.append(BuildingBlock(WELL_INNER[0], block.WATER, WELL_INNER[1]))

		WELL_GROUND = []
		WELL_GROUND.append(BuildingBlock(WELL_OUTER[0], block.GRAVEL, WELL_OUTER[1]))
		WELL_GROUND.append(BuildingBlock(WELL_CORE[0], block.COBBLESTONE, WELL_CORE[1]))
		WELL_GROUND.append(BuildingBlock(WELL_INNER[0], block.WATER, WELL_INNER[1]))

		WELL_WALLS = []
		WELL_WALLS.append(BuildingBlock(WELL_CORE[0], block.COBBLESTONE, WELL_CORE[1]))
		WELL_WALLS.append(BuildingBlock(WELL_INNER[0], block.AIR, WELL_INNER[1]))

		WELL_SUPPORT = []
		WELL_SUPPORT.append(BuildingBlock(Vec3(-1,0,-1), block.FENCE))
		WELL_SUPPORT.append(BuildingBlock(Vec3(-1,0,-4), block.FENCE))
		WELL_SUPPORT.append(BuildingBlock(Vec3(-4,0,-4), block.FENCE))
		WELL_SUPPORT.append(BuildingBlock(Vec3(-4,0,-1), block.FENCE))
		
		bl = Building(orientation, WELL_WIDTH)
		bl.layers.append(BuildingLayer(WELL_BASE, -3))
		bl.layers.append(BuildingLayer(WELL_WATER, -2))
		bl.layers.append(BuildingLayer(WELL_GROUND, -1))
		bl.layers.append(BuildingLayer(WELL_WALLS, 0))
		bl.layers.append(BuildingLayer(WELL_SUPPORT, 1))
		bl.layers.append(BuildingLayer(WELL_SUPPORT, 2))
		bl.layers.append(BuildingLayer(WELL_BASE, 3))
		
		# set_direction needs to be called after adding layers to building
		bl._set_orientation()

		# rotate offset for test:
		if orientation == Building.EAST:
			self.default_offset.rotateRight()
		elif orientation == Building.SOUTH:
			self.default_offset.rotateRight()
			self.default_offset.rotateRight()
		elif orientation == Building.WEST:
			self.default_offset.rotateLeft()

		return bl
Exemplo n.º 25
0
def run_game():
    #游戏初始化,创建一个屏幕对象
    pygame.init()

    g_settings = Settings()

    screen = pygame.display.set_mode((g_settings.screen_width,g_settings.screen_height),pygame.RESIZABLE)
    pygame.display.set_caption("Flappy Bird")

    bird = Bird(g_settings,screen)

    building = Building(g_settings, screen)

    building1 = Building(g_settings, screen)
    building1.rect1.x = building1.rect1.x + 200
    building1.rect2.x = building1.rect2.x + 200

    building2 = Building(g_settings, screen)
    building2.rect1.x = building1.rect1.x + 400
    building2.rect2.x = building1.rect2.x + 400

    building3 = Building(g_settings, screen)
    building3.rect1.x = building1.rect1.x + 600
    building3.rect2.x = building1.rect2.x + 600

    building4 = Building(g_settings, screen)
    building4.rect1.x = building1.rect1.x + 800
    building4.rect2.x = building1.rect2.x + 800


    while True:
        # 监测键盘事件和鼠标事件
        gf.check_events(bird)

        #屏幕刷新相关函数
        gf.update_screen(screen,g_settings,bird,building,building1,building2,building3,building4)
    def reset(self):
        """
        Initializes/resets the simulation to its initial state
        """
        # Generate a list of passengers based on total number of passengers
        self.passenger_list = [
            Passenger(i, self.num_floors)
            for i in range(1, self.total_passengers + 1)
        ]

        self.elevator = ElevatorFactory.get_elevator(self.num_floors,
                                                     self.elevator_type,
                                                     self.passenger_list,
                                                     self.elevator_capacity)

        self.building = Building(self.num_floors, self.passenger_list)
Exemplo n.º 27
0
def get_buildings_from_file():
    d = pd.read_excel("building_data.xlsx",
                      sheet_name="Sheet1",
                      names=[
                          "date_added", "occupancy", "lease_signed",
                          "building", "building_class", "city", "deal_size",
                          "tenant", "new_renewal_expansion", "term",
                          "base_rent", "rent_structure", "esc", "t_i",
                          "rent_abatement", "tenant_broker", "ll_broker",
                          "t_o", "comments"
                      ])
    od = d.where((pd.notnull(d)), None).to_dict(orient="index",
                                                into=OrderedDict)
    buildings = []
    for i in range(len(od)):
        building = Building(**od[i])
        buildings.append(building)
    return buildings
Exemplo n.º 28
0
 def renderBuilding(self, screen):
     # отрисовка окружения поля
     for y in range(self.size[1]):
         for x in range(self.size[0]):
             # строения
             if self.building[x][y].type != Type(
             ).void and self.building[x][y].type != Type().road:
                 image = self.imageBuilding[self.building[x][y].type -
                                            1][self.building[x][y].team - 1]
                 rect = (int(x * self.plates_size[0]) + self.sideShift,
                         int(y * self.plates_size[1]))
                 screen.blit(image, rect)
             # дорога
             elif self.building[x][y].type == Type().road:
                 # матрица с ситуацией на поле
                 piece = [[False, False, False], [False, True, False],
                          [False, False, False]]
                 try:
                     if self.building[x][y - 1].type == Type().road:
                         piece[0][1] = True
                 except:
                     pass
                 try:
                     if self.building[x - 1][y].type == Type().road:
                         piece[1][0] = True
                 except:
                     pass
                 try:
                     if self.building[x + 1][y].type == Type().road:
                         piece[1][2] = True
                 except:
                     pass
                 try:
                     if self.building[x][y + 1].type == Type().road:
                         piece[2][1] = True
                 except:
                     pass
                 # принимаем тип дороги
                 rect = (int(x * self.plates_size[0]) + self.sideShift,
                         int(y * self.plates_size[1]))
                 screen.blit(
                     self.imageRoad[Building().indexOfRoadPiece(piece)],
                     rect)
Exemplo n.º 29
0
 def init(cls):
     pygame.init()
     cls.buildings.add(Building(-100, 0, 100, cls.height, 1, 1))
     cls.buildings.add(Building(0, 280, 100, 200, 5, 5))
     cls.buildings.add(Building(100, 380, 200, 100, 5, 3))
     cls.buildings.add(Building(300, 330, 150, 150, 10, 10))
     cls.buildings.add(Building(450, 200, 190, 280, 10, 8))
     cls.buildings.add(Building(cls.width, 0, cls.width+100, cls.height, 1, 1))
     cls.player1 = Gorilla(50,50)
     cls.player1.set_vel(10,10)
     cls.player2 = Gorilla(cls.width-50-50,50)
     cls.players.add(cls.player1)
     cls.players.add(cls.player2)
     cls.curr_player = cls.player1
Exemplo n.º 30
0
def run_game():
    #游戏初始化,创建一个屏幕对象
    pygame.init()

    g_settings = Settings()

    screen = pygame.display.set_mode((g_settings.screen_width,g_settings.screen_height),pygame.RESIZABLE)
    pygame.display.set_caption("Flappy Bird")

    bird = Bird(g_settings,screen)

    building = Building(g_settings, screen)


    while True:
        # 监测键盘事件和鼠标事件
        gf.check_events(bird)

        #屏幕刷新相关函数
        gf.update_screen(screen,g_settings,bird,building)