Esempio n. 1
0
    async def buy(
        self,
        ctx,
        arg='list'
    ):  # A command to buy an specific item, if argument is not passed, it's returns a list with available items.

        economy = Economy(self.bot)

        listed_items = self.getItems(ctx)

        if arg == 'list':
            if not listed_items:
                await ctx.channel.send('Not available articles in server')
                return
            else:
                await ctx.channel.send('Available items: ')
                for item in listed_items:
                    await ctx.channel.send(f"{item}: ${listed_items[item]}")
        else:
            if arg in listed_items:
                boolean = economy.checkWallet(ctx, listed_items[arg])
                if boolean is True:
                    await ctx.channel.send('Purchased %s' % (arg))
                else:
                    await ctx.channel.send(
                        "You don't have enough money to buy this article")
                pass
            else:
                ctx.channel.send('Error 404: Item not found')
def EvaluateMap(chromosome=[0.00, 0.10, 0.10, 0.00], economy=Economy(50)):
    # Init economy and map

    economy = Economy(50)
    gameMap = gamemap.GameMap(economy, 10, 10, *chromosome)
    output = Output()
    times = 30
    mapcopy = copy.deepcopy(gameMap)

    armies = [
        Game.selectArmy(
            economy,
            mapcopy,
            armyColor="white",
            output=Output(),
            aUnitPool=['SoldierClass', 'TechnicianClass', 'MageClass'])
        for _ in range(times)
    ]

    score = sum(
        [Game(economy, mapcopy, army, output, 0.0).run() for army in armies])

    print(score / times)

    return score / times,
def doMapGenerationComparison():
    # Init economy
    economy = Economy(500);
    # Init messaging
    output = ConsoleOutput();
    # Set colors
    sAttackerColor = "white";

    gameMap = GameMap(economy, 10, 10, 0.1, 0.1, 0.05, 0.05);
    # Create an army
    army = Game.selectArmy(economy, gameMap, "white", output)

    # For this army, create 3 maps (1 easy, 1 average, 1 difficult)
    for pParams in [(0.01, 0.15, 0.01, 0.01, "easy"), (0.05, 0.15, 0.11, 0.08, "medium"),
                    (0.03, 0.01, 0.12, 0.08, "difficult")]:
        gameMap = GameMap(economy, 10, 10, pParams[0], pParams[1], pParams[2], pParams[3]);
        # Run the easy 10 times
        allScores = []
        for iCnt in range(10):
            score = runGameMap(economy, gameMap, army, output)
            allScores += [score]

        os.rename("GameTimeline.json", "GameTimeline%s.json"%(pParams[4]))

        print str(pParams) + ":" + str(allScores)
Esempio n. 4
0
    def __init__(self, data_path, data=None):

        self.default_price = 1

        economy = Economy(data_path)
        self.goods = economy.goods

        self.bids = {}
        self.offers = {}

        if data is None:
            self.prices = {}
            self.momentums = {}
        else:
            self.prices = data['prices']
            if "momentums" in data:
                self.momentums = data['momentums']
            else:
                self.momentums = {}

        for good_name in self.goods:
            if good_name not in self.prices or "coin" in good_name:
                if "default_price" in self.goods[good_name]:
                    self.prices[good_name] = self.goods[good_name][
                        'default_price']
                else:
                    self.prices[good_name] = self.default_price
            if good_name not in self.momentums:
                self.momentums[good_name] = 0
def printMap(params):
    economy = Economy(50)
    gameMap = gamemap.GameMap(economy, 10, 10, *params)
    output = ConsoleOutput()
    output.drawMap(gameMap, [], [])

    print(gameMap)
def main():

    random_seed = np.random.randint(4294967295)

    parameters = {
        "random_seed": random_seed,
        "n_generations": 100,
        "n_periods_per_generation": 30,
        "n_goods": 5,
        "n_agents": 100,
        "p_mutation": 0.1,
        "mating_rate": 0.3
    }

    e = Economy(**parameters)

    e.run()
Esempio n. 7
0
 def setUp(self):
     self.e = Economy(
         'Honolulu',
         'pv', 'wine',
         qy ** sp.Rational(1,2) * qx ** (sp.Rational(1,2)),
         make_ellipsoid_ppf(170,170),
         [0.2, 0.2, 0.2]
     )
Esempio n. 8
0
def main(argv):  # take pkd and int as arguments
    filename = "../savedata/" + argv[1] + ".pkl"
    try:
        with open(filename, "rb") as load_file:
            economy = pickle.load(load_file)
    except FileNotFoundError:
        economy = Economy()
        open(filename, "w+")
    try:
        generations = int(argv[2])
    except ValueError:
        print("Error: Invalid input: " + argv[2])
        return
    while generations > 0:
        economy.pass_generation()
        generations -= 1
    with open(filename, "wb") as save_file:
        pickle.dump(economy, save_file)
def main():
    economy = Economy()
    output = Output()
    curmap = GameMap(economy)
    myevol = RandomUnitEvolution()
    print(
        myevol.evolveEachUnit(
            economy, curmap, Game.selectArmy(economy, curmap, "white",
                                             output)))
Esempio n. 10
0
def doAgentTrainingComparison():
    # Init economy
    economy = Economy(500);
    # Init messaging
    output = ConsoleOutput();
    # Set colors
    sAttackerColor = "white";

    # A medium map
    gameMap = GameMap(economy, 10, 10, 0.05, 0.15, 0.11, 0.08);

    # Create an army
    # Select an army
    army = Game.selectArmy(economy, gameMap, "white", output)

    # Run game on map 10 times
    allScores = []
    for iCnt in range(10):
        score = runGameMap(economy, gameMap, army, output)
        allScores += [score]

    # Record avg performance
    os.rename("GameTimeline.json", "GameTimeline%s.json" % ("Untrained"))
    print str("Scores for Untrained") + ":" + str(allScores)

    # Evolve army RANDOM
    myevol = RandomUnitEvolution()
    myevol.evolveEachUnit(economy, gameMap, army)

    # Reset scores
    allScores = []

    # Run game on map 10 times
    # Record avg performance
    for iCnt in range(10):
        score = runGameMap(economy, gameMap, army, output)
        allScores += [score]

    os.rename("GameTimeline.json", "GameTimeline%s.json" % ("TrainedRandom"))
    print str("Scores for TrainedRandom") + ":" + str(allScores)

    # Reset scores
    allScores = []

    # Evolve army GENETIC
    MapBuilder.unit_evolver.getArmy(army, gameMap, economy)

    # Run game on map 10 times
    # Record avg performance
    for iCnt in range(10):
        score = runGameMap(economy, gameMap, army, output)
        allScores += [score]

    # Record avg performance
    os.rename("GameTimeline.json", "GameTimeline%s.json" % ("TrainedGenetic"))
    print str("Scores for TrainedGenetic") + ":" + str(allScores)
Esempio n. 11
0
def compute(random_seed):

    parameters = {
        "mating_rate": 0.3,
        "max_production": 10,
        "n_agents": 300,
        "n_generations": 10**4,
        "n_goods": 3,
        "n_periods_per_generation": 5,
        "p_mutation": 0.1,
        "production_advantages": [4, 2, 0.5],
        "production_costs": [4, 2, 2],
        "random_seed": random_seed,
        "u": 10
    }

    e = Economy(**parameters)

    return parameters, e.run()
Esempio n. 12
0
    def __init__(self, city, data_path, data=None):

        self.city = city

        self.economy = Economy(data_path)
        self.goods = self.economy.goods
        self.recipes = self.economy.recipes
        self.professions = self.economy.professions

        self.one_round_food = 5
        self.utility_of_money = 0

        if data:
            self.money = data['money']

            self.first_name = data['first_name']
            self.last_name = data['last_name']

            self.skills = data['skills']
            self.affinities = data['affinities']
            self.possessions = data['possessions']

            self.birthdate = data['birthdate']

        else:

            #print("RESTARTING")

            self.money = self.economy.default_money

            name = generate_a_name()
            self.first_name = name['first_name']
            self.last_name = name['last_name']

            self.skills = {}
            self.affinities = {}
            self.possessions = {}

            self.birthdate = random.randrange(20, 100)

        for profession in self.professions:
            if profession not in self.skills:
                self.skills[profession] = random.randrange(0, 101)
        for good_name in self.goods:
            good = self.goods[good_name]
            if good_name not in self.affinities:
                affinity = 0
                if 'function_for_affinity' in good:
                    affinity = rvp_parse(good['function_for_affinity'])
                self.affinities[good_name] = affinity
            if good_name not in self.possessions:
                self.possessions[good_name] = 0

        self.margin = 0
Esempio n. 13
0
def fun(args):

    n_periods_per_generation = int(args[0])
    random_seed = np.random.randint(4294967295)
    # random_seed = 4043318547

    parameters = {
        "random_seed": random_seed,
        "n_generations": 50,
        "n_periods_per_generation": n_periods_per_generation,
        "n_goods": 3,
        "n_agents": 1000,
        "p_mutation": 0.05
    }

    e = Economy(**parameters)

    backup = e.run()

    return np.mean(backup["production_diversity"][-10:])
Esempio n. 14
0
    def __init__(self, data_path, city_data):

        self.data_path = data_path

        self.file_name = data_path + city_data['file']
        self.name = city_data['name']
        self.default_population = city_data['default_population']

        self.economy = Economy(data_path)

        self.history = None

        self.potentials = {}

        for profession in self.economy.professions:
            self.potentials[profession] = 50
        for potential in city_data['potentials']:
            self.potentials[potential] = city_data['potentials'][potential]

        if os.path.isfile(self.file_name):
            self.load()
        else:
            self.init()
Esempio n. 15
0
from economy import Economy
economy = Economy(
    id="MISTAH_KURTZ",
    numeric_id=3,
    # as of May 2015 the following cargos must have fixed positions if used by an economy:
    # passengers: 0, mail: 2, goods 5, food 11
    # keep the rest of the cargos alphabetised
    # bump the min. compatible version if this list changes
    cargos=[
        'passengers', 'alcohol', 'mail', 'building_materials', 'cassava',
        'goods', 'chemicals', 'clay', 'coffee', 'copper', 'copper_ore', 'food',
        'diamonds', 'edible_oil', 'engineering_supplies', 'farm_supplies',
        'fruits', 'livestock', 'lumber', 'maize', 'manganese', 'nuts', 'oil',
        'petrol', 'phosphate', 'rubber', 'sand', 'stone', 'wood'
    ])
Esempio n. 16
0
# coding: utf-8
import locale
from discord.ext import commands
from base import DISCORD_LOCALE, DISCORD_OPERATOR, DISCORD_TOKEN
from condorcet import Condorcet
from birthday import HappyBirthday
from rolemanager import RoleManager
from economy import Economy

if __name__ == '__main__':
    locale.setlocale(locale.LC_ALL, DISCORD_LOCALE)
    bot = commands.Bot(command_prefix=DISCORD_OPERATOR)
    bot.add_cog(Condorcet(bot))
    bot.add_cog(HappyBirthday(bot))
    bot.add_cog(RoleManager(bot))
    bot.add_cog(Economy(bot))
    bot.run(DISCORD_TOKEN)
Esempio n. 17
0
economy = Economy(
    id="BETTER_LIVING_THROUGH_CHEMISTRY",
    numeric_id=2,
    # as of May 2015 the following cargos must have fixed positions if used by an economy:
    # passengers: 0, mail: 2, goods 5, food 11
    # keep the rest of the cargos alphabetised
    # bump the min. compatible version if this list changes
    cargos=[
        "passengers",
        "alcohol",
        "mail",
        "aluminium",
        "ammonia",
        "ammonium_nitrate",
        "chlorine",
        "cleaning_agents",
        "copper",
        "electrical_parts",
        "engineering_supplies",
        "food",  # must be in slot 11
        "ethylene",
        "explosives",
        "farm_supplies",
        "fish",
        "food_additives",
        "furniture",
        "glass",
        "grain",
        "hydrochloric_acid",
        "limestone",
        "livestock",
        "lumber",
        "lye",
        "milk",
        "methanol",
        "naphtha",
        "oil",
        "packaging",
        "paints_and_coatings",
        "petrol",
        "phosphate",
        "phosphoric_acid",
        "plant_fibres",  # should be cotton?
        "plastics",
        "potash",
        "propylene",
        "rubber",  # includes synthetic rubber, export only
        "salt",
        "sand",
        "soda_ash",
        "steel",
        "sulphur",
        "sulphuric_acid",
        "textiles",
        "tinplate",
        "urea",
        "vehicles",
    ],
)
Esempio n. 18
0
        army[index].strategy.riskiness = {
            "SoldierClass": evolvedParams[2],
            "TrapClass": evolvedParams[3],
            "TowerClass": evolvedParams[4]
        }
        # Base probability to get closer to interact
        army[index].strategy.fasting = evolvedParams[5]
        # Base probability to return if hungry
        army[index].strategy.greed = evolvedParams[6]
        for u in army[:5]:
            print u.strategy.curiosity

    # scores.sort(reverse=True)
    # for score in scores[:5]:
    #     print(score)
    return army


if __name__ == "__main__":

    economy = Economy()
    output = Output()
    curmap = gamemap.GameMap(economy)

    army = Game.selectArmy(
        economy,
        curmap,
        armyColor="white",
        output=Output(),
        aUnitPool=['SoldierClass', 'TechnicianClass', 'MageClass'])
Esempio n. 19
0
economy = Economy(
    id="BASIC_ARCTIC",
    numeric_id=1,
    # as of May 2015 the following cargos must have fixed positions if used by an economy:
    # passengers: 0, mail: 2, goods 5, food 11
    # keep the rest of the cargos alphabetised
    # bump the min. compatible version if this list changes
    cargos=[
        "passengers",
        "ammonia",
        "mail",
        "engineering_supplies",
        "explosives",
        "farm_supplies",
        "fertiliser",
        "fish",
        "kaolin",
        "logs",
        "lumber",
        "food",
        "paper",
        "peat",
        "phosphate",
        "potash",
        "pyrite_ore",
        "sulphur",
        "zinc",
    ],
    # as of March 2021 this cargoflow tuning is a temporary patch up, might need more work
    cargoflow_graph_tuning={
        "group_edges_subgraphs": [],
        "ranking_subgraphs": [
            ("sink", ["T_town_industries", "T_towns_food"]),
        ],
        "clusters": [
            # {"nodes": [], "rank": "", "color": ""},
        ],
    },
)
Esempio n. 20
0
economy = Economy(
    id="STEELTOWN",
    numeric_id=5,
    # as of May 2015 the following cargos must have fixed positions if used by an economy:
    # passengers: 0, mail: 2, goods 5, food 11
    # keep the rest of the cargos alphabetised
    # bump the min. compatible version if this list changes
    cargos=[
        "passengers",
        "acid",
        "mail",
        "alloy_steel",
        "aluminium",
        "vehicles",  # no goods?
        "carbon_black",
        "carbon_steel",
        "cast_iron",
        "cement",
        "chlorine",
        "food",
        "cleaning_agents",
        "coal",
        "coal_tar",
        "coke",
        "electrical_parts",
        "engineering_supplies",
        "farm_supplies",
        "ferrochrome",
        "glass",
        "iron_ore",
        "limestone",
        "lye",
        "manganese",
        "oxygen",
        "paints_and_coatings",
        "pig_iron",
        "pipe",
        "plastics",
        "quicklime",
        "rubber",
        "salt",
        "sand",
        "scrap_metal",
        "slag",
        "soda_ash",
        "stainless_steel",
        "steel_sections",
        "steel_sheet",
        "steel_wire_rod",
        "sulphur",
        "tyres",
        "vehicle_bodies",
        "vehicle_engines",
        "vehicle_parts",
        "zinc",
        "potash",
    ],
    # as of April 2021 this cargoflow graph is really as optimised as can be
    # the pacemaker is the salt -> chlor-alkali -> acid chain which requires 15 steps in horizontal rank
    # this limits how big the font / industry images can be
    # I've tried using vertical edges or reversed edges to cut the number of steps, but it makes the overall flow less legible
    cargoflow_graph_tuning={
        "group_edges_subgraphs": [
            ["basic_oxygen_furnace", "electric_arc_furnace"],
            ["pig_iron"]  # groups edges can be set for a single node
        ],
        "ranking_subgraphs": [
            ("source", ["potash_mine", "quarry", "farm", "coal_mine"]),
            ("same", ["chlor_alkali_plant", "lime_kiln", "cryo_plant"]),
            ("same", ["wire_and_section_mill", "sheet_and_pipe_mill"]),
            ("same", ["cleaning_agents", "zinc", "cement"]),
            (
                "same",
                [
                    "component_factory",
                    "body_plant",
                    "engine_plant",
                    "tyre_plant",
                ],
            ),
            (
                "same",
                [
                    "plastics",
                    "alloy_steel",
                    "stainless_steel",
                    "glass",
                    "sulphur",
                    "aluminium",
                ],
            ),
            ("sink", [
                "assembly_plant", "vehicles", "T_town_industries",
                "T_towns_vehicles"
            ]),
        ],
        "clusters": [
            {
                "nodes": ["blast_furnace", "pig_iron", "basic_oxygen_furnace"],
                "rank": "same",
            },
            {
                "nodes": ["oxygen", "quicklime"],
                "rank": "same",
                "color": "white"
            },
            {
                "nodes": ["junk_yard", "scrap_metal", "electric_arc_furnace"],
                "rank": "same",
            },
            {
                "nodes": ["quarry", "limestone_mine"],
                "rank": "source",
                "color": "white",
            },
            {
                "nodes": ["bulk_terminal", "food", "chlorine", "potash"],
                "color": "white",
            },
            {
                "nodes": ["pipe", "steel_sections", "cement", "lye"],
                "rank": "same",
                "color": "white",
            },
            {
                "nodes": ["coal", "coal_mine", "coke_oven"],
                "rank": "same"
            },
            {
                "nodes": ["carbon_steel", "acid"],
                "rank": "same",
                "color": "white"
            },
            {
                "nodes": ["coal_tar", "carbon_black_plant", "carbon_black"],
                "rank": "source",
            },
            {
                "nodes": [
                    "stainless_steel",
                    "alloy_steel",
                    "plastics",
                    "electrical_parts",
                ],
                "color":
                "white",
            },
            {
                "nodes": ["glass", "paints_and_coatings", "steel_sheet"],
                "rank": "same",
                "color": "white",
            },
            {
                "nodes": ["sulphur", "rubber", "steel_wire_rod"],
                "rank": "source",
                "color": "white",
            },
            {
                "nodes": ["aluminium", "cast_iron"],
                "rank": "source",
                "color": "white",
            },
            {
                "nodes": [
                    "assembly_plant",
                    "vehicle_parts",
                    "tyres",
                    "vehicle_engines",
                    "vehicle_bodies",
                ],
                "color":
                "white",
            },
        ],
    },
)
Esempio n. 21
0
def main() :
  print("We can run the economy, Captain!")

  start_time = time.time()

  # TODO: create list of cities

  data_path = "dat/"

  with open(data_path + "economy.json") as json_file:
    economy_raw = json.load(json_file)
    json_file.close()
  cities_raw = economy_raw['cities']
  
  history_file = "history.json"

  cities = []
  histories = []
  if os.path.isfile(history_file) :
    if "reset" not in sys.argv:
      with open(history_file, "r") as fd:
        histories = json.load(fd)
        fd.close()

  for city_data in cities_raw:
    if "reset" in sys.argv:
      filename = data_path + city_data['file']
      if os.path.isfile(filename):
        os.remove(filename)
    city = City(data_path, city_data)
    if city.name in histories:
      city.history = histories[city.name]
    cities.append(city)


  days_to_simulate = 1
  for arg in sys.argv:
    try:
      days_to_simulate = int(arg)
    except:
      pass

  stop_up_time = time.time()
  print("start up % 6ld s" % (stop_up_time - start_time))

  
  for i in range(days_to_simulate):

    for city in cities:

      print("%s Day %d" % (city.name, city.day))
      start_inner_time = time.time()
      city.advance_day()
      stop_inner_time = time.time()
      print("city cycle %d % 6ld s" % (i, stop_inner_time - start_inner_time))


    end_time = time.time()
    seconds = end_time - start_time


    millis = seconds * 1000
    minutes = seconds / 60
    hours = minutes / 60

    millis %= 1000
    seconds %= 60
    minutes %= 60

    print("%02d:%02d:%02d.%03d" % (hours, minutes, seconds, millis))

  histories = {}
  for city in cities:
    city.save()
    histories[city.name] = city.history

  with open("prices.json", "w") as fd:
    city_prices = {}
    for city in cities:
      city_prices[city.name] = city.market.prices

    json.dump(city_prices, fd)
    fd.close()
  
  with open(history_file, "w") as fd:
    #json.dump(histories, fd, indent=2)
    json.dump(histories, fd)

  economy = Economy(data_path)
  economy.reset()
Esempio n. 22
0
economy = Economy(
    id="IN_A_HOT_COUNTRY",
    numeric_id=3,
    # as of May 2015 the following cargos must have fixed positions if used by an economy:
    # passengers: 0, mail: 2, goods 5, food 11
    # keep the rest of the cargos alphabetised
    # bump the min. compatible version if this list changes
    cargos=[
        "passengers",
        "alcohol",
        "mail",
        "building_materials",
        "cassava",
        "goods",
        "chemicals",
        "clay",
        "coffee",
        "copper",
        "copper_ore",
        "food",
        "diamonds",
        "edible_oil",
        "engineering_supplies",
        "farm_supplies",
        "fruits",
        "livestock",
        "lumber",
        "maize",
        "manganese",
        "nuts",
        "oil",
        "petrol",
        "phosphate",
        "rubber",
        "sand",
        "stone",
        "wood",
    ],
    cargoflow_graph_tuning={
        "group_edges_subgraphs": [],
        "ranking_subgraphs": [
            ("same", ["port", "goods"]),
            ("sink", ["T_town_industries", "N_force_rank"]),
        ],
        "clusters": [
            #{"nodes": [], "rank": "", "color": ""},
        ],
    },
)
Esempio n. 23
0
def set_up_economy(i):

    print "Please follow us to set up all the details."
    raw_input()
    '''I'm asking the user to determine the 3 important numbers of ECON world.
    These numbers determine the structure of ECON world.'''
    number_of_goods = int(
        input(
            "Please enter the number of goods (the first good will be vaccination):"
        ))
    while not number_of_goods >= 1:
        print 'You should have at least ONE good in economy.'
        number_of_goods = int(
            input(
                "Please enter the number of goods (the first good will be vaccination):"
            ))
    number_of_factors = int(input("Please enter the number of factors:"))
    while not number_of_factors >= 1:
        print 'You should have at least ONE factor in economy.'
        number_of_goods = int(
            input(
                "Please enter the number of goods (the first good will be vaccination):"
            ))
    gamma = float(input("Please enter the gamma of your economy:"))
    while not gamma < 1 or gamma == 0:
        print 'Please make sure gamma is smaller than 1 and not equal to 0.'
        gamma = float(input("Please enter the gamma of your economy:"))
    number_of_types = int(
        input("Please determine how many types of consumers(more than 1):"))
    while not number_of_types >= 1:
        print 'You should have at least ONE type of consumer in economy.'
        number_of_types = int(
            input(
                "Please determine how many types of consumers(more than 1):"))
    number_of_consumers_by_type = []
    for i in range(number_of_types):
        number_of_consumers_by_type.append(
            int(
                input(
                    'Please determine how many consumers(more than 1) in type %s:'
                    % (i))))
    total_number_of_consumers = int(sum(number_of_consumers_by_type))

    print "\n Now let's set the parameters for goods"
    raw_input()
    Goods = [[]] * number_of_goods
    for g in range(number_of_goods):
        if g == 0:
            Goods[g] = Good(
                float(
                    input('Please determine ksi for good %s(more than 1):' %
                          (g))), 'public')
            while not Goods[g] >= 0.0:
                print 'ksi for good should not be smaller than 0.'
                Goods[g] = Good(
                    float(
                        input(
                            'Please determine ksi for good %s(more than 1):' %
                            (g))), 'public')
        else:
            Goods[g] = Good(
                float(
                    input('Please determine ksi for good %s(more than 1):' %
                          (g))), 'private')
            while not Goods[g] >= 0.0:
                print 'ksi for good should not be smaller than 0.'
                Goods[g] = Good(
                    float(
                        input(
                            'Please determine ksi for good %s(more than 1):' %
                            (g))), 'private')

    print "\n Now let's set the parameters for factors"
    raw_input()
    Factors = [[]] * number_of_factors
    for f in range(number_of_factors):
        Factors[f] = Factor(
            float(
                input('Please determine theta for factor %s(more than 1):' %
                      (f))))
        while not Factors[f] >= 0.0:
            print 'Theta should be greater than 0.'
            Factors[f] = Factor(
                float(
                    input(
                        'Please determine theta for factor %s(more than 1):' %
                        (f))))

    print "\n Now let's set the parameters for consumers"
    raw_input()
    alphas = [[]] * number_of_types
    betas = np.zeros(number_of_types)
    for ty in range(number_of_types):
        para = np.array(
            input('Please enter the alphas and beta for consumer type %s:' %
                  (ty)))
        while len(para) != number_of_goods + 1:
            para=np.array(input("Make sure you enter %s parameters. \n" \
                                "Please enter the alphas and beta for consumer type %s:" %(number_of_goods+1,ty)))
        alphas[ty] = np.array(para[0:number_of_goods])
        betas[ty] = para[number_of_goods]
        while not np.all(alphas[ty] > 0.0) or not np.sum(
                alphas[ty]) == 1.0 or not betas[ty] >= 0.0:
            print 'Make sure that alphas and beta are positive or that sum of alpha equals to 1.'
            para = np.array(
                input(
                    'Please enter the alphas and beta for consumer type %s:' %
                    (ty)))
            alphas[ty] = np.array(para[0:number_of_goods])
            betas[ty] = para[number_of_goods]

    print "\n Now let's set the parameters for producers"
    raw_input()
    psis = [[]] * number_of_goods
    for g in range(number_of_goods):
        psis[g] = np.array(
            input('Please enter the psis for the production of good %s:' %
                  (g)))
        while not np.all(psis[g] > 0):
            print 'Make sure psis be positive.'
            psis[g] = np.array(
                input('Please enter the psis for the production of good %s:' %
                      (g)))

    ECO = Economy(gamma, number_of_goods, number_of_factors, number_of_types,
                  number_of_consumers_by_type, total_number_of_consumers,
                  Goods, Factors, alphas, betas, psis)

    return ECO
Esempio n. 24
0
from economy import Economy

economy = Economy(
    id="BASIC_TEMPERATE",
    numeric_id=0,
    # as of May 2015 the following cargos must have fixed positions if used by an economy:
    # passengers: 0, mail: 2, goods 5, food 11
    # keep the rest of the cargos alphabetised
    # bump the min. compatible version if this list changes
    cargos=[
        "passengers",
        "alcohol",
        "mail",
        "chemicals",
        "coal",
        "goods",
        "engineering_supplies",
        "farm_supplies",
        "fish",
        "fruits",
        "iron_ore",
        "food",
        "kaolin",
        "livestock",
        "milk",
        "sand",
        "scrap_metal",
        "steel",
    ],
)
Esempio n. 25
0
economy = Economy(id = "FIRS",
                  numeric_id = 2,
                  # as of May 2015 the following cargos must have fixed positions if used by an economy:
                  # passengers: 0, mail: 2, goods 5, food 11
                  # keep the rest of the cargos alphabetised
                  # bump the min. compatible version if this list changes
                  cargos = ['passengers',
                            'alcohol',
                            'mail',
                            'bauxite',
                            'building_materials',
                            'goods',
                            'chemicals',
                            'clay',
                            'coal',
                            'engineering_supplies',
                            'farm_supplies',
                            'food',
                            'fish',
                            'fruits',
                            'grain',
                            'iron_ore',
                            'livestock',
                            'lumber',
                            'packaging',
                            'metal',
                            'milk',
                            'oil',
                            'petrol',
                            'plant_fibres',
                            'recyclables',
                            'sand',
                            'scrap_metal',
                            'stone',
                            'sugar_beet',
                            'wood',
                            'wool'])
Esempio n. 26
0
        # Get rid of deep map copy
        del mapInstance

        # Actually render
        pygame.display.flip()


def saveToFile(self, sFilename):
    fOut = open(sFilename, 'w')
    fOut.write(self.msg)
    fOut.close()


if __name__ == "__main__":
    # Init economy and map
    economy = Economy(5000)
    gameMap = gamemap.GameMap(economy, 20, 20)
    output = Output()
    # Init  army
    # Set colors
    sAttackerColor = (255, 255, 255)
    army = Game.selectArmy(
        economy,
        gameMap,
        sAttackerColor,
        output,
        [
            "AssassinClass",
            "BarbarianClass",
            "DruidClass",
            "EnchanterClass",
Esempio n. 27
0
from economy import Economy
economy = Economy(id = "BASIC_TEMPERATE",
                  numeric_id = 0,
                  # as of May 2015 the following cargos must have fixed positions if used by an economy:
                  # passengers: 0, mail: 2, goods 5, food 11
                  # keep the rest of the cargos alphabetised
                  # bump the min. compatible version if this list changes
                  cargos = ['passengers',
                            'alcohol',
                            'mail',
                            'chemicals',
                            'clay',
                            'goods',
                            'coal',
                            'engineering_supplies',
                            'farm_supplies',
                            'fish',
                            'fruits',
                            'food',
                            'iron_ore',
                            'livestock',
                            'milk',
                            'sand',
                            'scrap_metal',
                            'steel'])
Esempio n. 28
0
import sys

from economy import Economy
from reverse_polish import rvp_parse

data_path = "dat/"
economy = Economy(data_path)

recipes = economy.recipes

max = 0
max_action = ""


def draw_function():

    for recipe in recipes:
        if "mine gold" in recipe['action']:
            break

    print(recipe)

    line = "% 4s | " % ("")
    for skill in range(0, 101, 2):
        line += str("% 3d" % (skill))
    print(line)
    line_length = len(line)
    line = ""
    for i in range(line_length):
        line += "-"
    print(line)
Esempio n. 29
0
from economy import Economy
economy = Economy(id = "BASIC_TROPIC",
                  numeric_id = 4,
                  # as of May 2015 the following cargos must have fixed positions if used by an economy:
                  # passengers: 0, mail: 2, goods 5, food 11
                  # keep the rest of the cargos alphabetised
                  # bump the min. compatible version if this list changes
                  cargos = ['passengers',
                            'alcohol',
                            'mail',
                            'beans',
                            'chemicals',
                            'goods',
                            'coffee',
                            'copper',
                            'copper_ore',
                            'engineering_supplies',
                            'farm_supplies',
                            'food', # has to be out of order for compatibility
                            'fish',
                            'fruits',
                            'grain',
                            'livestock',
                            'nitrates',
                            'oil',
                            'wool'])
Esempio n. 30
0
from economy import Economy
economy = Economy(
    id="BASIC_ARCTIC",
    numeric_id=1,
    # as of May 2015 the following cargos must have fixed positions if used by an economy:
    # passengers: 0, mail: 2, goods 5, food 11
    # keep the rest of the cargos alphabetised
    # bump the min. compatible version if this list changes
    cargos=[
        'passengers', 'kaolin', 'mail', 'engineering_supplies',
        'farm_supplies', 'goods', 'paper', 'pyrite_ore', 'alcohol', 'lumber',
        'phosphate', 'food', 'explosives', 'zinc', 'fish', 'sulphur',
        'fertiliser', 'wood', 'peat'
    ])