[DEV] Resources Procurement

Gedemon

Modder
Super Moderator
Joined
Oct 4, 2004
Messages
11,623
Location
France
We now have everything needed to work on, thanks to ruckingit (and everyone involved) :goodjob:


World Maps


Resources Procurement per nation

I drew up a spreadsheet and summarized production data into % of world output for 1939. Some of the numbers are approximations because the data was merged (ex: Japan occupied parts of China).

Spoiler :


1939 Strategic Resource Production by Country

Oil % Coal % Iron % Bauxite %

Africa
Algeria 0.00% 0.00% 2.01% 0.00%
Belgian Congo 0.00% 0.00% 0.01% 0.00%
Egypt 0.23% 0.00% 0.00% 0.00%
French Morocco 0.00% 0.01% 0.26% 0.00%
Spanish Morocco 0.00% 0.00% 0.79% 0.00%
Mozambique 0.00% 0.00% 0.00% 0.00%
Nigeria 0.00% 0.02% 0.00% 0.00%
Southern Rhodesia 0.00% 0.09% 0.00% 0.00%
South Africa 0.00% 1.30% 0.39% 0.00%
Tunisia 0.00% 0.00% 0.53% 0.00%

North America
Canada 0.34% 0.86% 0.06% 0.00%
Newfoundland 0.00% 0.00% 1.10% 0.00%
Mexico 2.30% 0.05% 0.14% 0.00%
US 59.95% 31.11% 33.50% 9.19%
Cuba 0.00% 0.00% 0.17% 0.00%

South America
Argentine 0.93% 0.00% 0.00% 0.00%
Bolivia 0.01% 0.00% 0.00% 0.00%
Brazil 0.00% 0.08% 0.61% 0.42%
British Guiana 0.00% 0.00% 11.21%
Chile 0.00% 0.14% 1.24% 0.00%
Colombia 1.20% 0.03% 0.00% 0.00%
Ecuador 0.11% 0.00% 0.00% 0.00%
Peru 0.63% 0.01% 0.00% 0.00%
Suriname 0.00% 0.00% 11.86%
Trinidad 0.95% 0.00% 0.00% 0.00%
Venezuela 10.71% 0.00% 0.00% 0.00%

Asia
British Borneo 0.33% 0.00% 0.00% 0.00%
China w/o Manchuria 0.00% 1.37% 0.05% 0.00%
Manchuria 0.00% 1.61% 0.00% 0.00%
Indo-China 0.00% 0.20% 0.09% 0.05%
India 0.11% 1.92% 2.50% 0.21%
Burma 0.38% 0.00% 0.00% 0.00%
Iran 3.62% 0.00% 0.00% 0.00%
Iraq 1.34% 0.00% 0.00% 0.00%
Japan & Formosa 0.13% 3.84% 0.00% 0.00%
Korea 0.00% 0.19% 0.00% 0.00%
Malay States 0.00% 0.03% 1.60% 2.17%
Netherlands Indies 2.79% 0.14% 0.00% 5.35%
Philippines 0.00% 0.00% 0.82% 0.00%
Saudi Arabia 0.19% 0.00% 0.00% 0.00%
Bahrein Islands 0.36% 0.00% 0.00% 0.00%
0.00% 0.00% 0.00% 0.00%
USSR 10.63% 11.21% 17.26% 6.26%

Europe
Albania 0.04% 0.00% 0.00% 0.00%
Austria 0.04% 0.02% 1.13% 0.00%
Belgium 0.00% 2.29% 0.08% 0.00%
Bulgaria 0.00% 0.01% 0.02% 0.00%
Czechoslovakia 0.01% 1.06% 0.31% 0.00%
France 0.02% 3.86% 12.68% 18.54%
Hungary 0.05% 0.09% 0.28% 11.59%
Germany 0.23% 14.30% 0.00% 0.00%
Greece 0.00% 0.00% 0.19% 4.33%
Ireland 0.00% 0.01% 0.00% 0.00%
Italy 0.00% 0.16% 0.62% 11.22%
Netherlands 0.00% 0.99% 0.00% 0.00%
Norway 0.00% 0.05% 1.17% 0.00%
Poland 0.18% 2.93% 0.00% 0.00%
Portugal 0.00% 0.02% 0.00% 0.00%
Romania 2.18% 0.02% 0.09% 0.25%
Spain 0.00% 0.51% 1.38% 0.00%
Sweden 0.00% 0.03% 10.49% 0.00%
Switzerland 0.00% 0.00% 0.08% 0.00%
UK 0.00% 18.06% 5.55% 0.00%
Turkey 0.00% 0.21% 0.19% 0.00%
Yugoslavia 0.00% 0.03% 0.41% 7.29%

Australia
Australia 0.00% 1.06% 2.17% 0.06%
New Zealand 0.00% 0.08% 0.06% 0.00%

 
Are all of the resources shown going to be used? If not somebody could edit the map to show only what's needed.
 
We only need iron, bauxite, coal and oil.

(and maybe uranium)
 
On map with convoys, gold could be used to spawn a new convoy of the desired types (Material, Personnel or US units for France, U.K., Greece and Material or Personnel for Germany, Italy on the Europe 39-45 map for example), but for the others ?

I honestly have no idea. Maybe it could just be used for upkeep costs? I tried thinking for other uses but then I got thinking about real world money and whether or not it was all an illusion and then my head started hurting :(

What do you think of this map, could it be used for WWII era ? (removing offshore deposit of course...)

It just depends on when the resources were discovered. Like oil in Libya was discovered after ww2 since the Italians never found it and I think Algeria might have been discovered post ww2 as well.
 
Yep, I think you're right about Algeria and Libya.

So a small table to complete and correct:
Resource Type| China | France | Germany | Greece | Italy | Japan | U.K. | U.S.A | U.S.S.R.
Iron|home|home|Sweden, Finland|?|?|home|home (region ?)|home|home|
Bauxite (Aluminium)|?|home|Hungary|?|?|home|British Guiana|home|home|
Coal|home|home, UK|home|?|?|?|home|home|home|
Oil|home|Irak, USA|Romania|?|?|?|Iran, Irak, USA|home|home|
 
Well I know that part of the reason that the Japanese attacked pearl harbour and and invaded the European colonies (mostly Indonesia) was because the US stopped oil shipments to them and they needed a new source (indonesia mostly)
 
Hi Gedemon,

Here is some data that I can contribute given I have done the ground work for this type of system in my mod. This data is only for Eastern Europe nations.

The research of this info took away 6 months of my life! The problem is identifying what existed during wwII versus modern day. The map I see provided here seems to be modern day (some resources or mines were yet to be found at time of war)

Names provided are nearest locations to a city for placement purposes.

USSR (Only western Europe portion of USSR)
Oil
Baku
Makhachkala
Grozny
Maikop
Batumi
Guryev
Syzran
Other fields were brought online during the war around the Volga area (i.e. Kuybyshev, Kazan)

Iron Ore
(Names in brackets are large known minefields at the time of ww2)
Krivoi Rog (Zheltaya, Annovka, Saksagan, Ingulets, Pervomaisk)
Kerch
Zaporozhye (Dneprorudnoye)
Lipetsk
Tula
Nizhny Tagil (Peschanka, Kachkanar, Goroblagodat)
Sverdlovsk (Alapayevsk)
Zlatoust (Bakal, Kusa)
Magnitogorsk
Orsk (Akkermanovka)

Bauxite (Aluminium)
(Names in brackets are large known minefields at the time of ww2)
Sverdlovsk (Kamensk)
Nizhny Tagil (Krasnoturjinsk)
Volkhov (Bauxitorgorsk)
Zlatoust (Novaya Pristan')
Krivoi Rog (Ingulets-Dneprovsk)

Coal
(Names in brackets are large known minefields at the time of ww2)
Stalino
Voroshilovgrad
Dnepropetrovsk
Kirovograd
Zaporozhye
Tula
Novograd (Borovish)
Pechora
Molotov (Kizel)
Chelyabinsk
Orsk (Karaganda)
Sverdlovsk
Sochi

Germany (some cities listed are based on occupation, west of Dortmund not included on my map)
Oil
(The problem with Germany is that it is hard to distinguish limited home output versus processing of imports from Romania)
Hamburg (Nienhagen + Ploesti imports)
Hannover (Rietberg)
Kiel (Heide)
Austria
Cracow

Iron Ore
Kassel
Dortmund
Mannheim
Dresden
Poznan
Graz
Ljubljana
Croatia

Bauxite (Aluminium)
Norway
Munich
Stuttgart
Graz
Croatia
+ occupied French mines of course

Coal
Hanover
Ruhr region
Dortmund
Frankfurt
Liepzig
Ostrava
Cracow
Norway

Romania
Oil
Ploesti
Buzau
Bacau

Iron Ore
Brasov
Timisoara

Bauxite
Arad

Coal
Brasov
Timisoara

Hungary
Oil
Pecs

Iron Ore
Miskolc

Bauxite
Miskolc
Budapest

Coal
Pecs

Finland
Oil
None

Iron Ore
Kemi (north of)

Bauxite
None

Coal
None (Finland relied heavily on wood as fuel or imported it via Germany)

Italy (Northern portion only)
Oil
Milan

Iron Ore
Milan

Bauxite
Verona
Bologda
Trieste

Coal
Verona
 
Hi Gedemon,

[...]

Thank you ! :goodjob:

(from the "quick" search have made the 2 days following my decision to add resources, without much results, I really appreciate the value of your post)

(and now I wonder how much time I will need to get a decent world map...)
 
and now I wonder how much time I will need to get a decent world map...)

Its only taken me 9 months to get mine to a half-decent state! :cringe:

The problem with this type of info is that it is mostly buried deep in academic papers which I stumbled on via random searches. Most readily available info on the interweb is based on post ww2 data. For example, bauxite extraction increased after the war in Eastern Europe but was a very scarse resource during the war.
 
yep thanks, I've used some info from there already but I forgot to bookmark it :D
 
BTW I'm doing more thinking than coding those last days...

I'd really prefer to have a local resource distribution, and apply it to materiel/personnel.

So I may spend more time than I expected on that, but in the other hand that would save me some for my projects related to resources in my other mods...
 
Here is some of my code as food for thought. This is a snippet of a much much larger system for controlling the global supply network.

The below code checks if a city has a specific building and then determines resource output based on hammers and size. Thus larger and more industrious cities have a higher resource output. The buildings output info is setup in a custom table that outlines specific infos (see further below).

The idea is that you loop through all cities for a player and determine output. Then roll this up to a global value like material/personnel.

Code used for resource generating buildings:
Code:
function GetBuildingResourceOutput(playerID, city, buildingType, buildingData, bImpacted)
-- PURPOSE: Get building resource output (steel, aluminium, fuel, power, rail, motor)
-- NOTE: Building output modifiers (i.e. worker quarters, rail yards) are calculated in this code	

	if playerID == nil or buildingType == nil or buildingData == nil or city == nil then
		Dprint("GetBuildingResourceOutput["..GameInfo.Buildings[buildingType].Type.."]: One or more parameters contained a nil value!")
		return
	else
		
		local ceil = math.ceil
		local floor = math.floor
		local random = math.random

		local buildingOutputType = buildingData.ResourceOutputType
		local buildingOutputRate = buildingData.ResourceOutput
		local buildingWorkers = g_PlayerBuildingCounters[playerID][buildingType].TotalWorkers
		local priResource = buildingData.PrimaryResource
		local secResource = buildingData.SecondaryResource 
		local outputModBuilding1 = buildingData.OutputModBuilding1
		local outputModBuilding2 = buildingData.OutputModBuilding2
		local impactedMod = buildingData.OutputImpactedModifier
		local cityID = city:GetID()
		local cityPop = g_CitySupplyData[playerID][cityID].Size
		local cityProd = g_CitySupplyData[playerID][cityID].Production
		local totalOutput = 0
		local prodModifier = 0

		local pResAvailable, pResTotal, pResUsed = 0,0,0
		local sResAvailable, sResTotal, sResUsed = 0,0,0
		local bHasPriResource, bHasSecResource =  false, false
		local seasonalPenalty = 0

		if priResource ~= nil then bHasPriResource = true end;
		if secResource ~= nil then bHasSecResource = true end

		-- Check if building requires primary resource
		if bHasPriResource == true then 
			pResAvailable, pResTotal, pResUsed = GetResourceQuantity(playerID, priResource)
			pResPenalty = CalculatePenalty (playerID, pResUsed, pResTotal)
		end

		-- Check if building requires secondary resource
		if bHasSecResource == true then
			sResAvailable, sResTotal, sResUsed = GetResourceQuantity(playerID, secResource)
			sResPenalty = CalculatePenalty (playerID, sResUsed, sResTotal)
		end

		-- Calculate output
		if buildingOutputType == "Power" then
			-- Power has a flat output rate
			totalOutput = buildingOutputRate
		elseif buildingOutputType == "Rail" or buildingOutputType == "Motor" then
			-- Flat transport points are multipled against city size.
			totalOutput = cityPop * buildingOutputRate
		else
			totalOutput = floor((cityPop ^ buildingOutputRate) * (cityProd/2))
			if bImpacted == true then	-- Building is occupied or isolated (if rail)
				totalOutput = totalOutput - floor((totalOutput * impactedMod) / 100)
			end
		end

		-- Check if city has other production modifier buildings that can boost this buildings output
		if outputModBuilding1 ~= nil then
			if city:IsHasBuilding(GameInfo.Buildings[outputModBuilding1].ID) then
				prodModifier = GetSupplyBuildingValue(outputModBuilding1, "Modifier")
				totalOutput = totalOutput + ceil((totalOutput * prodModifier)/100)
			end
		end
		if outputModBuilding2 ~= nil then
			if city:IsHasBuilding(GameInfo.Buildings[outputModBuilding2].ID) then
				prodModifier = GetSupplyBuildingValue(outputModBuilding2, "Modifier")
				totalOutput = totalOutput + ceil((totalOutput * prodModifier)/100)
			end
		end

		-- Apply primary resource penalty
		if bHasPriResource == true and pResPenalty > 0 then
			totalOutput = totalOutput - floor((totalOutput * pResPenalty) / 100)
		end

		-- Apply secondary resource penalty
		if bHasSecResource == true and sResPenalty > 0 then
			totalOutput = totalOutput - floor((totalOutput * sResPenalty) / 100)
		end

		-- Apply seasonal penalty
		local seasonalPenalty = g_CitySupplyData[playerID][cityID].SeasonalFoodPenalty
		if seasonalPenalty > 0 then
			totalOutput = totalOutput - floor((totalOutput * seasonalPenalty) / 100)
		end

		-- Update Production Resource Counters
		g_CitySupplyData[playerID][cityID][buildingOutputType.."_Output"] = g_CitySupplyData[playerID][cityID][buildingOutputType.."_Output"]	+ totalOutput			
		g_GlobalSupplyCounters[playerID][buildingOutputType].TotalOutput = g_GlobalSupplyCounters[playerID][buildingOutputType].TotalOutput + totalOutput
		
		local current, flux = GetTotalsCounters(playerID, buildingOutputType)
		current = current + totalOutput
		flux = flux + totalOutput
	
		UpdateTotalsCounters(playerID, buildingOutputType, current, flux , 0)

		return totalOutput
	end
end

SQL for resource production buildings:
Code:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- RESOURCE/TRANSPORT PRODUCING BUILDINGS
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
INSERT INTO EF_SupplyBuildings (Type, BaseWorkerModifier, BaseEvacRailPointsRequired, RailInput, FoodRequired, RailRequired, ResourceOutputType, ResourceOutput, PrimaryResource, SecondaryResource, OutputImpactedModifier, OutputModBuilding1, OutputModBuilding2)
--		Type									BaseWorkerMod	EvacRP	RIn		FRq		RRq		ResourceType	ResOutput	PrimaryRes			SecondaryRes		ImpactedModifier	OutputModBuilding1				OutputModBuilding2	
SELECT	'SUPPLY_BUILDING_STEEL_MILL',				0.97,		40,		0,		0,		1,		'Steel',		3.017,		'RESOURCE_IRON',	'RESOURCE_COAL',		50,				'BUILDING_WORKERS_QUARTERS',	NULL			UNION ALL
SELECT	'SUPPLY_BUILDING_ALUMINIUM_PLANT',			0.84,		40,		0,		0,		1,		'Aluminium',	0.7,		'RESOURCE_ALUMINUM','RESOURCE_COAL',		50,				'BUILDING_WORKERS_QUARTERS',	NULL			UNION ALL

Hope this helps in getting your creative ideas flowing :)
 
Gedemon, ww2commander, I'm curious how both your projects evolve, and it's good to see you supporting each other.

It's also a good thing, in my opinion, for R.E.D. to include strategic resources. For it's well known, that many decisions on both the Allied and Axis side were driven by resource considerations, and not only concerning the obvious oil and iron ore, but also the less obvious but underestimated natural rubber (for gaskets) and wool or cotton (for uniforms). I didn't kow, that as early as in 1916 oil was already regarded so important, that the Germans occupied the Romanian oil fields right after the Romanians joined the Allied side. If oil possession was already such a big deal in the days of static warfare, how much more valued it must have been in the days of mobile warfare and big scale aerial warfare.

Italy (Northern portion only)
I found this modern day economic geography map on my hard drive:

Spoiler :


(Erdöl = oil
Steinkohle = coal
Eisen = iron)

No big improvement to the other map posted earlier, but a few more iron, coal and bauxit deposits marked in Central Europe, that can be trusted, like the coal near St. Etienne, for example. There's also oil in Southern Sicily, but a quick internet search only shows, that they started to develop these sites in the late thirties, with no hint, whether they really mattered in WW II.
 
Keinpferd, you actually highlighted one of my main problems when trying to figure out oil production, what was an oilfield vs an oil processing point (ie received imported oil).

I don't think the northern portion of Italy on my map is 100% correct. There was a concentration of oil storage and processing near Turin (from memory) so I decided to just make it an oil resource on my map. :shifty:
 
thanks both of you, and great map :D

I'm pondering the separation of oil production and oil processing too, but I'm unsure if that's needed. Storage will be a part of the mod, that's sure.

On the coding side, I think I'll do the following, at the start of each player turn:
- Create groups of cities linked by friendly territory starting by the Capital city.
- Get resources procurement, and create a "pool" of the total resources (stock+ current turn procurement) for each group
- Get which cities group provide a supply line for each unit
- Provide reinforcement to units as it is done currently, but limited to the linked group resources pool
- Check oil needed by all units linked to one cities group, if there is not enough apply a penalty "promotion" (there'll be an "elite" promotion that you can choose for level 4 units and will give them priority for resources assignment) based on a "rationing level" (3 or 4 level based on the oil stock left, or if I can do more calculation here, the game's turns left before reaching 0 with the current linked units need...)
- dispatch the remaining resources in all cities of a group, based on their relative stock capacity (a captured city will give the stocked resources to the enemy)
 
Having tried various methods, I would suggest breaking it down to the individual city level. My approach loops through each players cities and keeps a track of various supply info (g_CityData). This way you can hover over a city and get an accurate tooltip of what it is contributing to the economy.

The rule of thumb I used was to restrict myself to a single city and unit loop each turn in order to speed things up. The city loop checks rail network status, regional information, production resource output, equipment/personnel output. The unit loop checks supply status, morale, promotions and resupply.

EDIT: And where possible I try to inheret common data from a city for a unit. This way the two object types are not performing the same searches and calculations.
 
yes, it will be shown at city level (for city/buildings production and stock), but I've the feeling that it will be faster to group the resources before "sending" them to units (smaller loops in the code)
 
Yes of course.

I should have clarified that....units are resupplied via the global counters and not by individual cities. The city connection is just a status thing for the player to make sense of where the supply line is broken.
 
Top Bottom