Пример #1
0
    def __init__(self, manager, initial_hex, ancestor=None):
        super(self.__class__, self).__init__()
        self.manager = manager
        self.id = unique_id('co')

        self.name = random_word()

        # ancestor country (mother country)
        # The country this country was formed out of
        self.ancestor = ancestor

        # hexes this country controls
        # create a province
        capital = Province(self.manager, initial_hex, self, is_capital=True)
        self.provinces = [capital]
        self.capital = capital

        # Vassal countries under this country
        self.vassals = []
        self.is_vassal = False

        # tuple of Country, relation int
        self.relations = []

        map_color, border_color = random_country_colors()
        self.display = {
            'map_color': map_color.hex,
            'border_color': border_color.hex
        }

        self.group_provinces = []
Пример #2
0
    def __init__(self, manager, initial_hex, ancestor=None):
        super(self.__class__, self).__init__()
        self.manager = manager
        self.id = unique_id('co')

        # ancestor country (mother country)
        # The country this country was formed out of
        self.ancestor = ancestor

        # hexes this country controls
        # create a province
        capital = Province(self.manager, initial_hex, self, is_capital=True)
        self.provinces = [capital]
        self.capital = capital
        self.manager.logger.log(self, {
            'capital': capital.id
        })
        self.manager.logger.log(self, {
            'provinces': capital.id
        }, LogAction.extend)

        # Vassal countries under this country
        self.vassals = []
        self.is_vassal = False

        # tuple of Country, relation int
        self.relations = []

        map_color, border_color = random_country_colors()
        self.display = {
            'map_color': map_color.hex,
            'border_color': border_color.hex
        }

        self.name = ''
Пример #3
0
    def __init__(self, province, pop_type, population):
        """
        Creates a new Pop.
        manager  (Historia)
        province (SecondaryDivision)
        culture  (Culture)
        religion (Religion)
        language (Language)
        job      (Job)
        """
        self.bankrupt_times = 0
        self.province = province
        self.id = unique_id('po')

        self.population = population
        self.population_yesterday = 0

        self.pop_type = pop_type

        # ECONOMY
        self.money = 10
        self.money_yesterday = 0
        self.bankrupt = False

        # set inventory and ideal amounts
        self.inventory = Inventory(150)
        for item in self.pop_type.start_inventory:
            self.inventory.add(item['good'], item['amount'])

        self.update_ideal_inventory()

        # a dictionary of Goods to PriceRanges
        # represents the price range the agent considers valid for each Good
        self.price_belief = {}

        # a dictionary of Goods to price list
        # represents the prices of the good that the Pop has observed
        # during the time they have been trading
        self.observed_trading_range = {}

        self.successful_trades = 0
        self.failed_trades = 0


        # make some fake initial data
        for good in Good.all():
            avg_price = self.market.avg_historial_price(good, 15)
            # fake trades
            self.observed_trading_range[good] = [
                avg_price * 0.5,
                avg_price * 1.5
            ]
            # generate fake price belief
            self.price_belief[good] = PriceRange(avg_price * 0.5, avg_price * 1.5)
Пример #4
0
    def __init__(self, province, pop_type, population):
        """
        Creates a new Pop.
        manager  (Historia)
        province (SecondaryDivision)
        culture  (Culture)
        religion (Religion)
        language (Language)
        job      (Job)
        """
        self.bankrupt_times = 0
        self.province = province
        self.id = unique_id('po')

        self.population = population
        self.population_yesterday = 0

        self.pop_type = pop_type

        # ECONOMY
        self.money = 10
        self.money_yesterday = 0
        self.bankrupt = False

        # set inventory and ideal amounts
        self.inventory = Inventory(150)
        for item in self.pop_type.start_inventory:
            self.inventory.add(item['good'], item['amount'])

        self.update_ideal_inventory()

        # a dictionary of Goods to PriceRanges
        # represents the price range the agent considers valid for each Good
        self.price_belief = {}

        # a dictionary of Goods to price list
        # represents the prices of the good that the Pop has observed
        # during the time they have been trading
        self.observed_trading_range = {}

        self.successful_trades = 0
        self.failed_trades = 0

        # make some fake initial data
        for good in Good.all():
            avg_price = self.market.avg_historial_price(good, 15)
            # fake trades
            self.observed_trading_range[good] = [
                avg_price * 0.5, avg_price * 1.5
            ]
            # generate fake price belief
            self.price_belief[good] = PriceRange(avg_price * 0.5,
                                                 avg_price * 1.5)
Пример #5
0
    def __init__(self, manager, location, owner, is_capital=False):
        super(self.__class__, self).__init__()
        self.manager = manager
        self.id = unique_id('pr')

        self.hex = location
        self.owner = owner
        self.hex.owner = self
        self.is_capital = is_capital

        # economy
        self.market = Market(self.manager, self)
        self.pops = []
        self.RGOs = []

        self.manager.logger.log(self, {'owner': owner.id})
Пример #6
0
    def __init__(self, manager, location, owner, is_capital=False):
        super(self.__class__, self).__init__()
        self.manager = manager
        self.id = unique_id('pr')

        self.hex = location
        self.owner = owner
        self.hex.owner = self
        self.is_capital = is_capital

        # economy
        self.market = Market(self.manager, self)
        self.pops = []
        self.RGOs = []

        self.manager.logger.log(self, {
            'owner': owner.id
        })
Пример #7
0
    def __init__(self, manager, location, owner, is_capital=False):
        super(self.__class__, self).__init__()
        self.manager = manager
        self.id = unique_id('pr')

        self.name = random_word()

        self.hex = location
        self.hex.owner = self
        self.owner = owner
        self.is_capital = is_capital

        self.date_founded = self.manager.current_day

        # economy
        self.market = Market(self.manager, self)
        self.pops = []
        self.RGOs = []
Пример #8
0
    def __init__(self, world_map, data):
        self.id = unique_id('he')
        self.world_map = world_map
        self.x = data.get('x')
        self.y = data.get('y')
        self.altitude = data.get('altitude')

        edges = data.get('edges')
        self.map_data = data

        self.biome = Biome[data.get('biome').get('name')]

        self.edge_east = edges.get('east')
        self.edge_north_east = edges.get('north_east')
        self.edge_north_west = edges.get('north_west')
        self.edge_west = edges.get('west')
        self.edge_south_west = edges.get('south_west')
        self.edge_south_east = edges.get('south_east')

        self.edges = [
            self.edge_east,
            self.edge_north_east,
            self.edge_north_west,
            self.edge_west,
            self.edge_south_west,
            self.edge_south_east
        ]

        self.has_river = False
        self.is_coast = False
        for e in self.edges:
            if e.get('is_river'):
                self.has_river = True
            if e.get('is_coast'):
                self.is_coast = True

        self.owner = None
        self._neighbors = None

        self.natural_resources = []
Пример #9
0
 def __init__(self, *args):
     self._list = list(args)
     self.id = unique_id('he')
Пример #10
0
 def __init__(self, space):
     self.inventory = {}
     self.ideal = {}
     self.space = space
     self.id = unique_id('he')