Food Supply

In case xienwolf pokes back, I figured out a workaround.

Stock Check grants In Stock to slaves.

In Stock randomly applies Importing Food with 100% chance.

Importing Food requires the promotion In Stock and is bMustMaintain .

The issue is that there will be a turn when you are In Stock but not Importing Food. During this turn the Food importers will be able to spend experience to gain Importing Food.

You need to randomly apply Importing Food. Using bAutoAquire will also cause an issue.
 
New Promotions

Spoiler :
Stock Check
Spoiler :
Auto Aquire, Must Maintain
Requires Food Trader (U), In City, in Own Territory, City has at least break even food.
Grants "Food Importer" to Minion units


Food Importer
Spoiler :
Gives +2 food per turn to the city you're standing in
Grants "Food Exporter" to the unit's master.
Increases maintenance cost by 3:gold:


Food Exporter
Spoiler :
Gives -2 Food per turn to the city you're standing in
Promotion can be aquired multiple times


Prolong Life
Spoiler :
Increases unit's duration by +1 per turn (used to make temporary summons permanant)

Pretty sure these won't work:

If the Master unit's city no longer has excess food, he loses the MustMaintain Stock Check promotion. This means he no longer applies Food Importer to his Slaves. This means they no longer grant Food Exporter to the Master.

So by changing 1 citizen to work another tile and accidentally causing yourself to be losing food, the entire trade network unravels itself. Maybe that is what you want though, but it introduces considerable potential frustration.

Instead, you could have it so that the Master imports the food, and the Slaves export the food. This works better for pooling lots of minor excesses into a single city, yours works better for having one mega-city pumping out food to lots of smaller developing cities.

With Master on importation, you have the same promotions, but using the feedback in the other direction now. Then when the city with an exporter (slave) goes negative gain, the slave loses his export promotion, the Master loses a single Import promotion. The remainder of the traderoutes remain established.




With the exec Versus eval contemplation, can you just pass "result" in with the argslist to the function and have it set result? Some languages local changes to variables won't hold on return, haven't tested with python. Could also set result as a global variable which is cleared to false before you execute the python function, then let the writer of the function set the global result to what he needs.
 
If the Master unit's city no longer has excess food, he loses the MustMaintain Stock Check promotion. This means he no longer applies Food Importer to his Slaves. This means they no longer grant Food Exporter to the Master.

So by changing 1 citizen to work another tile and accidentally causing yourself to be losing food, the entire trade network unravels itself. Maybe that is what you want though, but it introduces considerable potential frustration.

Note that the life prolonging promotion is seperate. The idea here is that the entire trade system would be suspended if it seems like the city is struggling for food. the importers would remain in place, just not importing food, so all it'd take is to sort out the food situation and everything would start working again
 
You aren't quite seeing how the logic flows, which is fine because I also missed a piece of it. This wouldn't just be a nuisance, but actually an infinite loop.


City 1 has 5 extra food:
Exporter summons an Importer, Importer moves to City 2

Now City 1 has 3 Extra food:
Exporter summons an Importer, Importer moves to City 2

Now City 1 has 1 Extra food:
Exporter summons an Importer, Importer moves to City 2

Now City 1 has a 1 Food Deficit:
Exporter Loses Stock Check
Start Loop to remove Food importer from all slaves
  • Slave 1 loses Food Importer
    • Master loses Food Exporter
    • City 1 now has 1 Extra food
      • Re-apply Stock Check to Master
        • Start Loop to apply Food Importer to all Slaves
          • Slave 1 gains Food Importer
          • City now has 1 food Deficit (Infinite Loop established). Note that we are in the first step of TWO loops which require we hit the other slaves still)
 
Personally, I don't see why we can't just let them go down to losing food per turn. If a player wants to do things stupidly enough that he's starving his citizens to death in an exporting town, then that's his choice. (Alternatively, he wants to eliminate unhappy people) That'll also prevent the death of them if he's rearranging workers. Maybe there should be a warning of some sort. That way, you could just have it so that the checking for allowed promotions checks for an actual amount of food income of at least two.

Alternatively, make it so that the food exporter promotion can only be acquired if the city has at least two food growth, and remove it with a negative food growth. That'd at least prevent the infinite acquire/remove loop, ne?
 
If you allow them to have a negative yield per turn, you have to make it possible to have a city be destroyed by starving to death at population 1, or just block the spell from functioning to export from a population 1 city. Otherwise you can have a city of size 1 running at -20000 food per turn to fuel your empire.

And requiring 2 food growth would stop this example, but not the issue. What if I had 2 food growth, cast the spell, so now have 0 food growth, then I change my Floodplains/Farm working citizen to be a Engineer specialist? Now I am at -5 food per turn, and the infinite loop kicks in.
 
With the exec Versus eval contemplation, can you just pass "result" in with the argslist to the function and have it set result? Some languages local changes to variables won't hold on return, haven't tested with python. Could also set result as a global variable which is cleared to false before you execute the python function, then let the writer of the function set the global result to what he needs.

I don't quite understand the question...

There is no function that it makes sense to pass in result. I'm guessing you're talking about exec. exec is actually a statement, and it is by default executed in the local namespace. That is if you write "exec pythonCode" it will work exactly as if you replaced the exec statement with the code in the pytonCode object.

It is possible to execute the exec in separate namespaces, but I see no reason to. The global namespace needs the civ modules, and the local namespace of canCast exists for the sole purpose of executing the PyRequirement. Malicious code will be able to change the global namespace, but malicious code will always be malicious.

Or maybe you're thinking that PyRequirement is a function. It isn't, it's just loose code, that gets executed inside the canCast function.

When the exec is done, you have access to all names the PyRequirement used. So the only problem is figuring out which name binds to the information you're interested in. A convention of using the name "result" would solve that.

(The nature of Python variables is simple. Python doesn't have variables.:p

Python works sufficiently different from C/C++/Ada/etcetera variables that using different names is warranted. Many innocent electrons have been tortured with discussions about this in Python newsgroups, for instance. It's more similar to Java, only consistent.

It's not very important.)

And requiring 2 food growth would stop this example, but not the issue. What if I had 2 food growth, cast the spell, so now have 0 food growth, then I change my Floodplains/Farm working citizen to be a Engineer specialist? Now I am at -5 food per turn, and the infinite loop kicks in.

The problem is that the food export is an all or nothing deal. A master with seven slaves needs to be able to export 14 food, or it can't export any. Having the slaves export food like xienwolf said would avoid this, since each slave can gain or lose exporting food independently. The promotion would still need to have a 2:food: gap between gaining and losing itself though, to prevent it from taking away so much :food: that it causes itself to be lost.

And importing food from several cities to a single city sure seems like a more common use case.
 
... For some reason, I thought that having starvation at 1 population would destroy the city. I remember that was the case in older civ games, so I never had it come up in Civ 4.

As for the other point, you're right. Couldn't that issue be fixed by just having it be a set of buildings, then, and avoid units all together, except perhaps in the instance of making the buildings? You could still have the cost for routes by having the ability cast in the city give a promotion to increase the maintainance as now; Simply have it like the wall of stone-type spells so that it only exists if a caster for it is in the city.
 
I'll just return to hating python for the time being :p I pretty much follow the gist of things though at this point. Plenty of more important things to tweak, so it's mostly just cool to know we can do one-line code snippets instead of always calling a function.


Buildings wouldn't be as clean or desireable as units. And certainly wouldn't be possible to do with just XML like people are wanting to do here.
 
Hm, forgive me, for I know not the code. Just from looking at various features from around FF as well as some ideas conceived in this thread: What if you made a national unit-1- exporter whom had -lets say- five button-promotions that would override each other -in the manner of the ship configuration promotions(skeleton crew, fighter crew)- with various increments of food, once a number has been selected then, per turn, the city with the importer unit would receive that increment into their food stores. Mind you, different techs could allow for another exporter/importer; in this way, only one food trade route may be established early on, and multiples later. The promotions that do the exporting might also cost money depending on the bulk of transport being done -as a balancing/realism factor-. Also, an afterthought occurs, what if the one -or more- of the exporters promotions would import? Then you could use the commander -formally notated as the 'exporter'- to both export and import depending on the needs of the player.

Though, if you allowed the promotion based increment to reduce the export city down a population, there would be potential exploits resulting from the granaries overflow bonus and the like. For example, if one were to drop a city down a pop, then change the exporter's increment to allow growth, once the city has regained it's pop then the overflow from the granary would shoot food into the city, this food can then be used as exported food with no immediate harm to the exporter city. Therefore, if one were to put any type of food manipulation system into place, the system should never allow for a city to lose a population point, as then the system would be exploitable via the means above.

I hope this isn't non-sense-making blather or some infeasible idea -due to coding-, and do hope this might help the potential mod this thread is about.

This mod sounds rather useful/flavorful/realistic.
 
City 1 has 5 extra food:
Exporter summons an Importer, Importer moves to City 2

Now City 1 has 3 Extra food:
Exporter summons an Importer, Importer moves to City 2

Now City 1 has 1 Extra food:
Exporter summons an Importer, Importer moves to City 2
Ah, but this is where it stops. I had anticipated this. I was plannign to make the Summon Importer spell require at least two surplus food, rather than at least any surplus foood

Still, I'm a bit unsure of what direction to take this now. Your importer-centric idea sounds better for some situations, but not others.


I kind of envision an empire having one or two massive food producing cities, places situated around floodplain farms and such. If the number of places you want to export from is small, then my exporter centric model would be better

T'is hard to think about
 
Ah, but this is where it stops. I had anticipated this. I was plannign to make the Summon Importer spell require at least two surplus food, rather than at least any surplus foood

But after some well meaning citizen shuffling the city will only have 3:food: total to export.

Since export is an all or nothing affair, the exporter will panic and cancel all deals.

But look, there is 3:food: available for exports, let start up the export again.

Aargh, now the city loses 3:food:, I must immediately cancel all trades!

Hmm, those surplus 3:food: look mighty tasty, lest start exporting again.


With an export centric system, you have to look that the is slaves*2:food: available before allowing export, since that is the amount of :food: you will drain.
 
There is also the security implications. Though considering how easy it is now to use nothing but xml to erase your harddrive, download the communist manifesto and write insulting e-mails to your mother, that's not really a downgrade.

And what's wrong with that?
 
I had a passing Idea.

It's an idea that supports growth, rather than supports large cities, but I still would like to pass it along here.

A unit, produced only from Food (hammers providing no construction to it) that is worth One settleable pop in a city.

This would atleast be useful for growing up fringe cities so they may support themselves, or for growing central cities enough to Support themselves AND be profitable. (One issue with large cities is getting there. It may be possible to plant a size 16 city here in Advanced Start, but if the blight crushes it to size 3, gaps in feasbility of growth can prevent even climbing above size 8)

There is also the question of if it would have a national unit cap (to prevent just suddenly popping a city somewhere), and if it could be used on foreign cities (for Gold like trade missions, or for Diplomatic bonuses)
 
My problem honestly isn't getting the pop to grow in the first place, it's say, feeding a city I want to work eight tiles when it's completely surrounded by plains hills. Trying to do THAT sucks.

And then I have a city 5 tiles away that's got eight or nine food resources, and constantly wants to grow over the happy cap by like four people... Ivan's idea doesn't fix that issue, and that's the one I wanted to fix.
 
The reason I am posting this is to encourage whomever has the time to make this mod reality. I myself am not working on the mod -just encouraging-. Hope this in some way helps.

At Festivals, Trade, or Currency-up to the maker to choose-; allow access to a National Unit -limit 1- Trade Merchant.

These Trade Merchants start with a spell called summon assistant. Using the spell would summon a -duration permanent- unit named Trade Assistant at the cost of some gold -you are employing him after all-. The trade assistant should be directed to city B by the player -if The Trade Merchant is in A-.

The conditionally available promotions of the Trade Merchant: The trade merchant should have say 3 export options and 3 import options, each option being different increments.

--Note: Now, most of the theory of implementation deals with taking food from the exporter city's stores and chucking it at the import city; I don't like that. So this logic will deal with bypassing both cities' stores and modifying the food income instead.


The Possible(?) Logic
[ignore everything entirely if it would be to hard to code for FF; also, this is logic -alone- without knowledge of how to implement it into FF code.]
-----------------------------------------------------------------------------------------------------------
Passive Logic:

Run This (At start of turn, after using a trade promotion, after merchant/assistant move):

{If: Trade Merchant or Trade Assistant are not in a city
Then: Disallow all promotions
Else:

{If: [city of trade merchant]: income food - unhealthiness is equal/lessthan 0
Then: Disallow all export promotions and end any pertaining export promotions if any are in effect.
Else:

{If: [city of trade merchant]: income food - unhealthiness - increment #1 is equal/lessthan 0
Then: Disallow export #1 promotion and end export #1 promotion if active.
Else: Allow export #1 promotion if not active.}

{If: [city of trade merchant]: income food - unhealthiness - increment #2 is equal/lessthan 0
Then: Disallow export #2 promotion and end export #2 promotion if active.
Else: Allow export # 2 promotion if not active.}

{If: [city of trade merchant]: income food - unhealthiness - increment #3 is equal/lessthan 0
Then: Disallow export #3 promotion and end export #3 promotion if active.
Else: Allow export # 3 promotion if not active.}
}

{If: [city of trade assistant] income food - unhealthiness is equal/lessthan 0
Then: Disallow all import promotions -of the trade merchant- and end any pertaining import promotions if any are in effect.
Else:

{If: [city of trade assistant]: income food - unhealthiness - increment #1 is equal/lessthan 0
Then: Disallow import #1 promotion and end import #1 promotion if active.
Else: Allow import #1 promotion if not active.}

{If: [city of trade assistant]: income food - unhealthiness - increment #2 is equal/lessthan 0
Then: Disallow import #2 promotion and end import #2 promotion if active.
Else: Allow import # 2 promotion if not active.}

{If: [city of trade assistant]: income food - unhealthiness - increment #3 is equal/lessthan 0
Then: Disallow import #3 promotion and end import #3 promotion if active.
Else: Allow import # 3 promotion if not active.}
}
}

-----------------------------------------------------------------------------------------------
Active Logic(i=increment):

Export #1 Promotion: -[i1] from food income of [trade merchant city], +[i1] to food income of [trade assistant city], -2x[i1] gold per turn, end all other trade promotions other than this one

Export #2 Promotion: -[i2] from food income of [trade merchant city], +[i2] to food income of [trade assistant city], -2x[i2] gold per turn, end all other trade promotions other than this one

Export #3 Promotion: -[i3] from food income of [trade merchant city], +[i3] to food income of [trade assistant city], -2x[i3] gold per turn, end all other trade promotions other than this one

**

Import #1 Promotion:-[i1] from food income of [trade assistant city], +[i1] to food income of [trade merchant city], -2x[i1] gold per turn, end all other trade promotions other than this one

Import #2 Promotion:-[i2] from food income of [trade assistant city], +[i2] to food income of [trade merchant city], -2x[i2] gold per turn, end all other trade promotions other than this one

Import #3 Promotion: -[i3] from food income of [trade assistant city], +[i3] to food income of [trade merchant city], -2x[i3] gold per turn, end all other trade promotions other than this one

-----------------------------------------------

Edit to WK: Any progress is great, thanks for your time! -I Didn't wanna bump the thread just to say thanks, but I did want to say it-
 
I'm currently working on it as a module, going with xienwolf's importer centric concept instead. Slowly, due to limited time, but I'll get there hopefully...

the various logic you outline above, would probably take some DLL work, or at least python beyond my abilities. But using unit yields, it can be done easily within a mostly xml based module.
 
Spoiler :
I find that programming is much easier if I actually read the source code, rather than look at the first character and guess what the rest is. :(



No the line actually was just a single line. The reason it didn't work is because eval was used, not exec . eval evaluates and returns an expression, I tried to use statements.

Anyway, as an example, here is Vitalize from my module, modified to not need changing of CvSpellInteface.py :
Code:
<SpellInfo>            <!-- Vitalize -->
    <Type>SPELL_VITALIZE</Type>
    <Description>TXT_KEY_SPELL_VITALIZE</Description>
    <Civilopedia>TXT_KEY_SPELL_VITALIZE_PEDIA</Civilopedia>
    <Help>TXT_KEY_SPELL_VITALIZE_HELP</Help>
    <PromotionPrereq1>PROMOTION_NATURE3</PromotionPrereq1>
    <bAllowAI>1</bAllowAI>
    <bDisplayWhenDisabled>1</bDisplayWhenDisabled>
    <bHasCasted>1</bHasCasted>
    <iDelay>7</iDelay>
    <PyResult>__import__('odmod').spellVitalize(pCaster)</PyResult>
    <PyRequirement>__import__('odmod').reqVitalize(pCaster)</PyRequirement>
    <Effect>EFFECT_VITALIZE</Effect>
    <Sound>AS3D_SPELL_SANCTIFY</Sound>
    <Button>Art/Interface/Buttons/Spells/Vitalize.dds</Button>
</SpellInfo>
Spoiler :
The relevant code is __import__('odmod').reqVitalize(pCaster). (And ditto for PyResult.)

The original was odmod.reqVitalize(pCaster), which requires an import odmod in CvSpellInterface.py.

The python module odmod, id est the file odmod.py , still needs to be somewhere civ IV looks for it of course, I stuck it in the python folder.

I don't know if this will cause horrible performance issues. Imports are normally cached by python, so the second and subsequent times the __import__('odmod') should be quick.

In this example, I take it that odmod.spellVitalize(pCaster) is the code that actually transforms the terrain, and not the XML. If that is the case, what are the limitations of imported functions called in this manner? Can you do essentially anything a spell can do?

(Sorry for the OT, but this is pretty cool stuff!)
 
I've always found it annoying I can't ship food from my "about to explode into the third unhappy citizen population" cities to my "surrounded by plains hills tiles with 2 pop" cities. Do this so it's not horrifically micromanagement intensive, and I will love you.


Well, if it's strictly a unit ability...it will most undoubtebly end up being a pretty tedious micromanagement issue...Try to go for a transfer food button on the cities screen if you can, otherwise, half your turn will be spent shipping food from one place to another.

I personally like the idea of a mega-city sucking up all the food from smaller local "farm towns" because it adds a little realism, but I recon a lot of people are going to get burned fiercely by this when an opponent starts attacking soft targets (like farm towns)
 
If you want to go with minimal micromanagement, I would propose you just rewrite the game mechanic to pool ALL food not required for current population in a communal storage, and whenever there is enough food in storage for any city to grow, that city claims the food it needs and grows. Whatever it has left over from Granary and other such savings is returned to the communal dump. Any city which is starving feeds out of the communal pile to maintain their population. Then you can have the "Avoid Growth" button prevent a city from claiming food for growth, and add another "Stockpile Food" button which will claim as much food from the communal pile as possible without making itself grow (so either all stocked food, or 1 under that required for growth). You would use the second option to maintain local "starvation buffers" in each city, since your communal buffer is continually depleted by random small cities growing.
 
Top Bottom