Topic: Target soldier quantity
teppo Topic Opener |
Posted at: 2016-12-29, 12:51
With barracks around (latest trunk, not b19), it should be rather straightforward to implement a target soldier count, similar to beast of burden now. Reasons why player might like limit the headcount of (unassigned) soldiers:
Should we implement a target soldier count? Top Quote |
king_of_nowhere |
Posted at: 2016-12-30, 01:20
yes, absolutely. But, to avoid the ai reaching the target soldier quantity, then stopping the economy, we should also set a note in the AI to increase it when there is nothing else to do. Something like IF (economy has target quantity of soldiers AND has target quantity of all types of weapon and armor AND has target quantity of bread AND (has target quantity of meat OR has target quantity of fish)) THEN raise soldier target quantity by 10 Top Quote |
Tibor |
Posted at: 2016-12-30, 17:49
Just yesterday I noticed that there is that new building in my AI branch and AI is not building it. Productionsites that produce workers is new stuff. Workers (soldiers here) does not have preciousness so AI does not know that its output is even needed and thus the building was not built at all. I changed the logic, barracks is another special building now, with own special code, logic for stopping and starting is just if we have enough soldiers. So if we introduce target amount further changes might be needed. But generally if there are any soldiers "on stock", AI will stop barracks so target will never be reached. AI is not now interested in creating soldiers on stock... but can be changed, of course, just keep in mind that used material can be used elsewhere, even for promotion of existing soldiers... I think this should be as simple as possible... Top Quote |
king_of_nowhere |
Posted at: 2016-12-30, 18:09
yeah, but once all the existing soldiers are promoted to full, then the AI will have nothing to do. The instruction I suggested (which is simple, it's just a check of a few conditions) enters exactly there. if the AI has the target amount of soldiers, and the target amount of weapons, and the target amount of food too, then it means that there are the means to promote soldiers, and they are not being used. Either that, or there are no training sites, but in that case the AI is already instructed to build them, and if it lost them, then making new level 0 soldiers is the best it can do anyway. Top Quote |
Tibor |
Posted at: 2016-12-30, 18:28
Have you ever see this situation where AI had all soldiers promoted to full?
usually AI has to expand and fight - that all means a need of new soldiers
AI is usually out of resources, so the situation you described (all that resources are on target) would be quite rare. So the rules might not be complicated, but it is quite corner case... I prefer something that covers common situation... Top Quote |
king_of_nowhere |
Posted at: 2016-12-30, 18:52
Yes. several times. It happens when something is preventing the AI from fighting. there is an island, and the ai cannot reach the port space, so it will just stay there until it is reached (like in the "large ocean" map). Or maybe the AI is blocked by the terrain, and will not make progress until attacked by a human (like in "to make the desert bloom"). Or maybe the AI was teamed up against a human, and the human had to cleave his way past multiple AIs, and the last one will only be reached after tens of hours of game; in fact, that's a common feature in most of my challenge maps. Or, in the most common case, when a castle/citadel is blocking the path in just the right way that the ai cannot find the way to attack. this can happen in a lot of official maps, from "trident of fire" (where I made my first no metal challenges, and they were based exactly on blocking the AI that way) to "desert tournament", to almost any mountain pass in "dolomites", and I'm sure it can happen in other maps too.
Agreed, it happens very rarely, and generally only if one is trying to make a very specific kind of challenge game. but hey, what's the worst that could happen? it is one line of code. the ai will check it every once in a while, see that its condition is not fulfilled, and move on. in those few specific instances, instead, it will be useful. Do you want to confine widelands to one single way of playing? Top Quote |
Tibor |
Posted at: 2016-12-30, 19:46
Most common situation is:
This is common situation and AI should have some reasonable logic for this And not, it is not one line but perhaps 20, f.e. " has target quantity of all types of weapon and armor" - AI has pick all items that are "weapon and armor" - though there is no hint for individual ware that "I am a weapon", for AI all are just numbers (indexes) or names - but it is not much better, so some string comparison is needed, then the name can change in the future, new weapon/armor can be added sometimes and also this can differ per tribe, so there is bunch of consideration as well... Top Quote |
king_of_nowhere |
Posted at: 2016-12-30, 23:44
AI doesn't need a good logic to deal with the normal situation, because no logic besides making a barrack is already a suitable way to handle it. I mean, we could set a reasonable target quantity of 30 soldiers, so ai will stop making new soldiers when it has 30 in warehouses. which in most games does not happen. if it happens, then all resources are used to promote existing soldiers, which is actually a boon to AI strenght, since now it tends to be wasteful in half-trained soldiers. and this system keeps working, without any additional commands, until all those 30 soldiers in warehouses - plus whatever soldiers are in buildings - are fully promoted. it rarely goes that far. if it goes that far, it needs some new logic. and I came up with something potentially even simpler: "if the military power has not changed in the last 10 minutes, increased the target soldier quantity by 20". if soldiers are being promoted, then military power is growing, and you do not want new soldier until you finished training the old ones. if you are fighting and losing soldiers, you don't need to increase a target quantity you are not meeting anyway. if it stays exactly the same, it means you cannot train further the soldiers you have. this could be implemented logically by checking every minute if the power is equal to the previous minute, and after ten consecutive checks, it would increase target soldiers and restart count; it woud restart count also every time it fails a check. and it would start the count after, say, 2 hours of game. and with all that stuff it looks like it's actually much more complicated than the other that only requires a dozen if-then, so better to stick with the other command. anyway, i don't see why you don't want too add such a line in the code, just because it only applies to some specific situations. it would take less time to write it than to argue that it is not needed Top Quote |
Tibor |
Posted at: 2016-12-31, 00:31
I am afraid that your proposal would lead to barracks always ON and thus the question is why we ever need the building, if it is to be always ON. Maybe the "if ... then..." is simple, but input data are not existing in the game, some time is needed to code their gathering and if I am not sure they will be useful, I am not much eager to code it. But I will tell you what is there now:
There is much more, but I dont know what can be interesting for you.. Can you based on this variables suggest some "if...then..."? Than it really could be few lines of code only... Top Quote |
king_of_nowhere |
Posted at: 2016-12-31, 01:02
What input data is missing? Ok, "weapon" is not a ware, but it just needs to specify all the types of weapons and armors individually; it is longer to write, but still the same thing. So the string I proposed
for example for atlanteans it would become IF (economy has target quantity of soldiers AND has target quantity of light trident AND has target quantity of tabard AND has target quantity of golden tabard AND has target quantity of long trident AND has target quantity of steel trident AND has target quantity of double trident AND has target quantity of heavy double trident AND has target quantity of steel shield AND has target quantity of advanced shield AND has target quantity of bread AND (has target quantity of smoked meat OR has target quantity of smoked fish)) THEN raise soldier target quantity by 10. All those are wares in warehouses, as found in the stock. and the only way to activate the barracks (short of losing soldiers) is to have all soldiers trained to the highest level, which only applies to rare instances. Top Quote |