Skip to content

Commit

Permalink
(Aegis) WIP: tropical
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyangyi committed Nov 20, 2023
1 parent 60b020c commit 1ccc576
Show file tree
Hide file tree
Showing 4 changed files with 218 additions and 14 deletions.
3 changes: 3 additions & 0 deletions agrf/parameters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def add(self, g, s):
def index(self, name):
return [i for i, p in enumerate(self.parameters) if p.name == name][0]

def __getitem__(self, name):
return self.parameters[self.index(name)]


class SearchSpace:
def __init__(self, choices, parameter_list):
Expand Down
24 changes: 11 additions & 13 deletions industry/aegis_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
import grf
import struct
import argparse
from industry.economies import vanilla_temperate, vanilla_subarctic, vanilla_subtropical, firs_temperate, firs_arctic
from industry.lib.parameters import parameter_choices
from industry.economies import (
vanilla_temperate,
vanilla_subarctic,
vanilla_subtropical,
firs_temperate,
firs_arctic,
firs_tropical,
)
from industry.lib.parameters import parameter_list, parameter_choices
from industry.lib.validator import validate


all_economies = [vanilla_temperate, vanilla_subarctic, vanilla_subtropical, firs_temperate, firs_arctic]
all_economies = [vanilla_temperate, vanilla_subarctic, vanilla_subtropical, firs_temperate, firs_arctic, firs_tropical]
all_industries = []
all_cargos = []

Expand Down Expand Up @@ -81,16 +88,7 @@ def initialize_metadata():
for i, meta_economy in enumerate(all_economies):
for variation in parameter_choices.iterate_variations():
economy = meta_economy.get_economy(variation)
index = (
{
# FIXME
0: "VANILLA_TEMPERATE",
1: "VANILLA_SUBARCTIC",
2: "VANILLA_SUBTROPICAL",
3: "BASIC_TEMPERATE",
4: "BASIC_ARCTIC",
}[i],
) + tuple(
index = (parameter_list["ECONOMY"].enum[i],) + tuple(
variation[i]
for i in (
"POLICY",
Expand Down
203 changes: 203 additions & 0 deletions industry/economies/firs_tropical.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
from industry.lib.economy import (
MetaEconomy,
Economy,
PrimaryIndustry,
WorkerYard,
FreePort,
SecondaryIndustry,
TertiaryIndustry,
Town,
)
from industry.cargos import (
alcohol,
beans,
chemicals,
china_clay,
coffee,
copper,
copper_ore,
engineering_supplies,
explosives,
farm_supplies,
fertiliser,
fish,
food,
fruit,
grain,
livestock,
mail,
nitrates,
oil,
paper,
passengers,
peat,
phosphate,
potash,
pyrite_ore,
sulphur,
timber,
tired_workers,
water,
wood,
wool,
workers,
zinc,
)
from industry.industries import (
nitrate_mine,
chemical_plant,
clay_pit,
fish_farm,
fishing_grounds,
fishing_harbor,
forest,
general_store,
herding_coop,
paper_mill,
peatlands,
phosphate_mine,
port,
potash_mine,
power_station,
pyrite_mine,
pyrite_smelter,
sawmill,
towns,
trading_centre,
water_supply,
water_tower,
wharf,
worker_yard,
)


class TheEconomy(MetaEconomy):
def __init__(self):
super().__init__("BASIC_TROPICAL")

def get_economy(self, parameters):
ret = Economy(
{
nitrate_mine: PrimaryIndustry(nitrates),
clay_pit: PrimaryIndustry(china_clay),
peatlands: PrimaryIndustry(peat),
phosphate_mine: PrimaryIndustry(phosphate),
potash_mine: PrimaryIndustry(potash),
pyrite_mine: PrimaryIndustry(pyrite_ore),
fish_farm: PrimaryIndustry(fish),
fishing_grounds: PrimaryIndustry(fish),
forest: PrimaryIndustry(wood),
herding_coop: PrimaryIndustry(food),
pyrite_smelter: SecondaryIndustry(pyrite_ore, (sulphur, zinc)),
sawmill: SecondaryIndustry(wood, timber),
chemical_plant: SecondaryIndustry(
(phosphate, sulphur, nitrates, potash),
(explosives, fertiliser),
),
fishing_harbor: SecondaryIndustry(fish, food),
paper_mill: SecondaryIndustry((wood, sulphur, china_clay), paper),
power_station: TertiaryIndustry(peat),
general_store: TertiaryIndustry((explosives, fertiliser, zinc, timber)),
towns: Town(passengers, mail, food, paper),
},
parameters,
)
if parameters["POLICY"] == "SELF_SUFFICIENT":
ret.graph[port] = FreePort((zinc, fertiliser, paper), (china_clay, nitrates))
ret.graph[wharf] = FreePort((peat, timber, explosives), potash)
del ret.graph[general_store] # FIXME
elif parameters["POLICY"] in ("FREE_TRADE", "EXPORT"):
ret.graph[port] = FreePort((zinc, fertiliser, paper), (china_clay, nitrates))
ret.graph[wharf] = FreePort((peat, timber, explosives), potash)
del ret.graph[general_store] # FIXME
del ret.graph[potash_mine]
del ret.graph[nitrate_mine]
del ret.graph[clay_pit]

if parameters["PRIMARY_INDUSTRY_GROWTH"] == "UNIVERSAL_SUPPLIES":
if nitrate_mine in ret.graph:
ret.graph[nitrate_mine].boosters = engineering_supplies
if clay_pit in ret.graph:
ret.graph[clay_pit].boosters = engineering_supplies
if potash_mine in ret.graph:
ret.graph[potash_mine].boosters = engineering_supplies
ret.graph[peatlands].boosters = engineering_supplies
ret.graph[phosphate_mine].boosters = engineering_supplies
ret.graph[pyrite_mine].boosters = engineering_supplies

ret.graph[fish_farm].boosters = engineering_supplies
ret.graph[forest].boosters = engineering_supplies
ret.graph[herding_coop].boosters = engineering_supplies

if parameters["POLICY"] in ("SELF_SUFFICIENT", "FREE_TRADE", "EXPORT"):
ret.graph[port].produces += (engineering_supplies,)
ret.graph[wharf].produces += (engineering_supplies,)
else:
ret.graph[paper_mill].produces += (engineering_supplies,)

elif parameters["PRIMARY_INDUSTRY_GROWTH"] == "GENERIC_SUPPLIES":
if nitrate_mine in ret.graph:
ret.graph[nitrate_mine].boosters = engineering_supplies
if clay_pit in ret.graph:
ret.graph[clay_pit].boosters = engineering_supplies
if potash_mine in ret.graph:
ret.graph[potash_mine].boosters = engineering_supplies
ret.graph[peatlands].boosters = engineering_supplies
ret.graph[phosphate_mine].boosters = engineering_supplies
ret.graph[pyrite_mine].boosters = engineering_supplies

ret.graph[fish_farm].boosters = farm_supplies
ret.graph[forest].boosters = farm_supplies
ret.graph[herding_coop].boosters = farm_supplies

if parameters["POLICY"] in ("SELF_SUFFICIENT", "FREE_TRADE", "EXPORT"):
ret.graph[port].produces += (engineering_supplies, farm_supplies)
ret.graph[wharf].produces += (engineering_supplies, farm_supplies)
else:
ret.graph[paper_mill].produces += (engineering_supplies,)
ret.graph[chemical_plant].produces += (farm_supplies,)

if parameters["WORKFORCE"].startswith("YETI"):
if parameters["WORKFORCE"] == "YETI":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(paper, zinc))
elif parameters["WORKFORCE"] == "YETI_PASSENGERS":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(paper, zinc, passengers))
elif parameters["WORKFORCE"] == "YETI_MAIL":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(paper, zinc, mail))
elif parameters["WORKFORCE"] == "YETI_TIRED":
ret.graph[worker_yard] = WorkerYard(workers, boosters=(paper, zinc, tired_workers))

# FIXME: remove PRESET; support SECONDARY
if parameters["WORKER_PARTICIPATION"] in ("PRESET", "NONE"):
ret.graph[fishing_grounds].boosters = workers
if parameters["WORKFORCE"] == "YETI_TIRED":
ret.graph[fishing_grounds].produces += (tired_workers,)
if parameters["WORKER_PARTICIPATION"] in ("PRIMARY_INDUSTRY", "SECONDARY_INDUSTRY", "BOTH"):
for i in [
nitrate_mine,
clay_pit,
potash_mine,
peatlands,
phosphate_mine,
pyrite_mine,
fish_farm,
forest,
herding_coop,
]:
if i in ret.graph:
ret.graph[i] = ret.graph[i].to_secondary(workers)
if parameters["WORKFORCE"] == "YETI_TIRED":
ret.graph[i].produces += (tired_workers,)

if port in ret.graph:
if parameters["SEA_INDUSTRY"] == "LAND_ONLY":
ret.graph[trading_centre] = ret.graph[port]
del ret.graph[port]
elif parameters["SEA_INDUSTRY"] == "BOTH":
ret.graph[trading_centre] = ret.graph[port]

if parameters["TOWN_GOODS"] == "FOOD_AND_WATER":
ret.graph[water_supply] = PrimaryIndustry(water)
ret.graph[water_tower] = TertiaryIndustry(water)

return ret
2 changes: 1 addition & 1 deletion industry/lib/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
2: "VANILLA_SUBTROPICAL",
3: "BASIC_TEMPERATE",
4: "BASIC_ARCTIC",
5: "BASIC_TROPICAL",
# ?: "TOYLAND",
# ?: "BASIC_SUBTROPICAL",
},
),
Parameter(
Expand Down

0 comments on commit 1ccc576

Please sign in to comment.