AI/Auto Traders and Promotions

Those last two sound like a good idea.

I would be wary of using click and double-click comboes, as sometimes getting the computer to detect the right kind of click gets frustrating, especially when you are trying to do things quickly!

My request idea was for an 'action' that sets the import/export/trader value to = 1 cargo slot capacity (which changes with game speed) so you can quickly set a transport system to take 1 load 2 load etc. with the click of a button.
 
What are all our current Yield Option:
...
Consumption Multiplier (which btw, sounds like a really cool addition)
Consumption Multiplier is set for each city, not each yield. It makes little sense to place it in a yield specific window.

I agree that single click and double click doing different actions might not be the best solution. At least it shouldn't be doing something horrible, like doubleclick empties the warehouse.

I once had a mouse, which suddenly came up with the idea to double click when I clicked the left mouse button once. It was annoying and once it got more frequent, I had no choice but to discard the mouse. That made me think about doubleclick and how user unfriendly it can be.

I also suffered from the opposite problem once. The computer lagged so heavily that it wasn't possible to doubleclick as the two clicks would be handled too far apart to be considered a doubleclick.
 
My request idea was for an 'action' that sets the import/export/trader value to = 1 cargo slot capacity (which changes with game speed) so you can quickly set a transport system to take 1 load 2 load etc. with the click of a button.

So, what your saying is a something like an Alt-Click = +"1 Cargo slot Capacity"?

Consumption Multiplier is set for each city, not each yield. It makes little sense to place it in a yield specific window.

I just took all the options that where in the import/export popup menu and placed them in the Yield Right Click menu. So, instead of having to click the Governor button, then click Import/Export, and then set consumption you can simply right click any yield and the option is there as well. The consumption isn't actually functioning correct? Anyway, we could also add new buttons for this specifically elsewhere. Like the rarely used Emphasize display box could be resized to make room for new Buttons.
 
Like the rarely used Emphasize display box could be resized to make room for new Buttons.
I use it occasionally. Also emphasize is essentially using the AI code and since I plan on improving the AI unit placement code, this feature will be more useful for human players as well.

I don't think we should worry too much about the button placement right now. Instead we should finish the backend for the features we already started working on. However regarding the new GUI stuff.... would you mind pushing it? I would like to see what you did :)
 
So, what your saying is a something like an Alt-Click = +"1 Cargo slot Capacity"?

Yes That is exactly what I am saying :) You nailed it! HIGH FIVES!

It seems to me that when it is finished, that consumption multiplier should have its own button, cause it just seems like it would be really helpful to have!
 
I use it occasionally. Also emphasize is essentially using the AI code and since I plan on improving the AI unit placement code, this feature will be more useful for human players as well.

I don't think we should worry too much about the button placement right now. Instead we should finish the backend for the features we already started working on. However regarding the new GUI stuff.... would you mind pushing it? I would like to see what you did :)

Heh, yeah, I've been meaning to push that all morning, just keep getting distracted:) Doing that now...

Done, it was only Dll changes so nothing else needs pushed.
 
Here is a coding question. What would be the best way to code in the ability for AI traders to buy yields? We would need to save...

-What Yields to Buy
-How much Gold they have to Spend
-What other values?

The Delivery of Yields will be easier to handle as there is code already for this so it isn't really an issue.
The problem is not really "how to code it", but more "what do we want it to do?".

We can store this in CvUnit, CvCity (home city) or CvPlayer.
We can store the data in 3 ways.
  • CvUnit
    Allows for multiple units not doing the same thing.
  • CvCity
    Shared settings for all units having this city as home city
  • CvPlayer
    Shared orders for all units, regardless of home city
One way to do this would be to add two cargo arrays to CvCity.
1: the same as trader threshold, but it's "buy to reach this level"
2: the amount in all traders having this city as home city and are heading home to unload (essentially a cache)

Amount to buy = #1 - city storage - #2

Gold.... presumably some variable or array in CvPlayer. Something like "automatic traders can't make gold drop below this value", possibly with other rules like "don't buy if price is more than X% of a specific trade screen", "never use more than X gold at once" and "never use more than X% of the gold". Stuff like that. I'm not sure what would be best, nor do I know where to put settings like that.

Maybe we should be able to set some yield priority: buy the best price compared to trade screen, buy the one, which is missing the most in reaching the threshold, the one set to high priority by the player. Stuff like that.

Now the big question is if that is what we want from the game. Once we agree on what it should do, we can consider the code. We shouldn't code and see if we like the gameplay result.
 
We shouldn't code and see if we like the gameplay result.

It's funny you should say that because that is normally how I roll ;) But, I had a feeling this was going to get complicated compared to simply selling a unit's cargo.

Now the big question is if that is what we want from the game.

Well, let's talk it out. If I am deciding I want to set up an AI Trader to buy "specific" things for me what will be the best way to set that up. Normally I am going to want Yields for a Certain city, like if I have a City that is a poor area to farm Barley, but yet I want to start a Rum factory there I will need to supply said city with Barley. The commands could then be placed in the city where we set a Trader Buy Threshold, but what would this Threshold represent? Normally you would want to keep enough Barley in order to keep your current Rum production working at its peak. Therefore, could we simply tell the AI Trader to "keep Rum production up" and then the AI will buy Barley enough to keep the Rum run going, up to max storage? It could actually get technical with this in that in factors how much Barley is being used each turn, how many turns will his venture take, and therefore how much Barley he should buy. Like if the City is nearly full of Barley, but in the 12 turns it will take to buy more and return with it the City will be 50% depleted so therefor plan for the city only having 150 Barley.

We could want the AI Traders to like, buy up Tools and spread them around to several cities, but to keep things simply we should just allow the existing Trade Route logistics to work this part. Our AI Traders then should simply Buy Tools for its Home City, keeping it well stocked so that our Supply Trains can move the Tools around.

We would then need two array settings in City(may can use existing), a Well Stocked Yield array, and a Maintain Production Array. Units will then have two commands for its Home City, one to Keep a City Well Stocked (buy until full, idle, and buy more if stocks start to dwindle), and Maintain Production where the Unit will seek to keep a Yield Stocked to match its production, factoring in travel times, distance, and things like the quickest amount he can get compared to how fast the Yield is being consumed. Like if you has enough Barley for 4 turns of production, but yonder City has more Barley to buy, but if he goes there your City will run out of Barley, so first he drops off his current load before setting out to buy more.

The Gold settings could be something we figure out with testing as I am not sure how that will effect things. Perhaps a command could be setup where you can set a Spending Threshold where once your Gold reserves get to a certain point, Traders are no long allowed to buy, but will sit Idle waiting for the Gold to return to ample amounts.
 
I have the Units Buying Yields now. It is very rudimentary currently as it only buys Yields it already is carrying. Like if it is carrying Grapes it will buy more Grapes and return to unload them at his home city, but it is a start and soon as we come up with a means to assign Yields to Buy it can easily be adapted. As a side note, currently I am attempting to use the exact same rates and rules as if the Player was doing the deals manually. At some point we can add promotions that will make AI Traders better than the Player.

It may be cool to add new Trading Diplomacies where the Player can Haggle for prices. Depending on certain factors, he has so many chances to Haggle before you tick off the potential buyer and he refuses to make deals with you lol.
 
Night's Consumption multiplier function will most likely be useful for this, as it will give a ground work for the AI to work out the 'buy for production' option.

I think you are right when you said traders should only buy for 1 city, then the transport units can spread them out.

For gold maybe there could be two methods

1. That gives direct access to the treasury (Take gold till treasury reaches Y amount i.e. the treasury must have more than 1000 gold)

2. Give the Unit X gold and it will trade until the gold is gone, return to home, unload, then ask if you want to repeat the order.
 
I think what we need is this:
  • domestic import
  • domestic export
  • foreign import
  • foreign export
All of them human controllable.

The domestic is like it is now, except it could make sense to split it into two. Import to reach 100, but do not export until it goes over 150.

Foreign settings:
The cargo the trader loads in the home city is the surplus according to foreign export.
The trader sells the entire load whenever it reaches a foreign city.
The trader buy whatever cargo it can to fill up the home city to make it reach foreign import.

Fairly simple and highly customizable. It will be possible to set tools to foreign import to 200 while it domestically exports when it reaches 100. This will make the trader import continuously to fill to 200 while the domestic transports will spread the tools to all other cities. Once all your cities stops importing due to feeder service settings, the home city will reach 200 tools and the trader will stop importing.

Night's Consumption multiplier function will most likely be useful for this, as it will give a ground work for the AI to work out the 'buy for production' option.
Most likely, but for now I want to make it work with a 100% human controlled value. Once that is working, we can consider some automation in the value setting.
 
Yeah, what I meant was we could pair the 'buying for production' with your 'consumption multiplier' system (as in code used) to allow the player to set a trader to buy X turns of yield, or rather buy to keep X turns of yield in storage.

This way as you expand your local businesses the traders would automatically ramp up buying to accomadate the increased consumption. Which would be quite cool!
 
I think what we need is this:
  • domestic import
  • domestic export
  • foreign import
  • foreign export
All of them human controllable.

The domestic is like it is now, except it could make sense to split it into two. Import to reach 100, but do not export until it goes over 150.

Foreign settings:
The cargo the trader loads in the home city is the surplus according to foreign export.
The trader sells the entire load whenever it reaches a foreign city.
The trader buy whatever cargo it can to fill up the home city to make it reach foreign import.

Fairly simple and highly customizable. It will be possible to set tools to foreign import to 200 while it domestically exports when it reaches 100. This will make the trader import continuously to fill to 200 while the domestic transports will spread the tools to all other cities. Once all your cities stops importing due to feeder service settings, the home city will reach 200 tools and the trader will stop importing.

This is the setup I will shoot for and I'll do the Foreign Settings first as it ties directly into AI Traders. The spit of domestic import/export, how would that effect feeder service (which I am still confused about how it works, I keep forgetting exactly what it does :crazyeye:)?

Edit: Should the new getTraderThreshold(YieldTypes eYield) code be used here and we add an additional commands and variables for say, getTraderExport() and covert the other to say, getTraderImport ?
 
I think generally the feeder service is the same as setting import and export on the same yield, it just 'thinks better' to over come certain flaws in the original programming.

Presumably feeder service would need modifying to fit in with the new design, (we can let night worry abot that! :p) but the idea of having of having some 'flex' between import and export thresholds is a good one.
 
The spit of domestic import/export, how would that effect feeder service (which I am still confused about how it works, I keep forgetting exactly what it does :crazyeye:)?
Essentially the game relies on vanilla import and export. Feeder service is an addon, which makes automated transports ignore traderoutes if the destination have more yields stored than the threshold.

Say you have 2 cities without any forests. You set both of them to import lumber with a threshold of 100 and then export to ensure equal sharing. If you have enough lumber, your transports can pick up from one, go to the other, unload and then load to go back to the first. In other words the transports can get stuck in a loop.

If the cities import lumber using feeder service, they disallow importing lumber when they have enough, hence no import when they both have enough and no loop. This is precisely the case feeder service is designed to handle, though we have expanded a bit on the original concept.

Edit: Should the new getTraderThreshold(YieldTypes eYield) code be used here and we add an additional commands and variables for say, getTraderExport() and covert the other to say, getTraderImport ?
It's two different arrays, hence the need for two different access functions. I will code it shortly.
 
It's two different arrays, hence the need for two different access functions. I will code it shortly.

I have already added a getTraderExport command and variables just copied what you did with getTraderThreshold. Sorry I couldn't wait to start teaching the AI to trade:eek:.

However, I am not using the getTraderExport stuff yet instead using the getTraderThreshold to tell the AI what yields to buy.

I do have a question, what exactly is the TRADER_THRESHOLD_NO_TRADING used for and why is it set to 500?

I will have to teach the AI to Buy and Sell in the same code, this will be fun;)
 
I do have a question, what exactly is the TRADER_THRESHOLD_NO_TRADING used for and why is it set to 500?
The idea is that the trader will pick up yields, which exceeds the trader threshold (which I think we should rename to "trader export" since we came up with imports as well). This mean if it is set to 100 and there are 173, the trader will pick up 73. That way it will export the surplus, but not everything.

There is no great explanation for why it is set to 500. The idea is that if you turn it off, it is set to a value, which mean off. Usually that is -1, but I had the idea that if it is always higher than what the city will contain, then game logics would be easier to handle. Back to the example. We have 173 stored and we export more than 500. Since 173 < 500, it will know there is nothing to pick up. In other words it will not need more code than figuring out that 173 < 200, which mean there will not be an "off" code when picking up yields.

Why is it 500? I planned on 30k, but since it writes the number in the spinbutton, 30k would be really silly. I made a define to be able to change it quickly because I'm unsure of which number to use.


Also I can't see that you wrote any new array code. Maybe you didn't push it?
 
Ok, yeah I haven't pushed it yet. I was toying with the initial AI and making sure it wasn't going to crash. My saved game still works, yay :) Anyway, I'll change getTraderThreshold to getTraderExport and push those changes.

Well, one thing about the 500 it can be confusing to Players when they look at the value that is set and it says "500". Player's want understand the logic used there so perhaps we need to make this 0 or some other solution.
 
I'll change getTraderThreshold to getTraderExport and push those changes.
Wouldn't getTraderExportThreshold() be better? We can then turn it into 4 get functions using the same patten, switching import/export and domestic/trader (should trader become foreign?).

Maybe it would be best to just push and then we rename later. Who knows how many times we want to rename from now on until it's working.
 
Top Bottom