Latest Posts

Topic: A bug or a feature?

Ex-Member
Avatar
Topic Opener
Joined: 2014-09-12, 09:53
Posts: 184
Ranking
Widelands-Forum-Junkie
Posted at: 2014-09-13, 12:50

I am playing a simulation where there is a large area between me and the AI enemy which was cleverly designed so that few building can be buit there, and all are limited to the smallest. So I build a string of sentries and then a cluster as I reach the border. I can the attack the opposing sentry with about 20 soldiers, one from each of my sentries with one left behind guarding or washing his hair.

A short while later the expeditionary forces return victorious but bloodied, most have some reduction in their health, some are almost dead, now is the time tp press on with my advantage in numbers but if I select the next sentry to attack all the wounded soldiers return to battle, is there a way I can select the ones that did not fight the first battle so the wounded guys can get some rest?

It could be that the buttons for prefering rookies or veterans does something like this though I have not found out what the option actually do yet, but it does seem logical to me that the soldier with the worst health would be the one to stay at home. It seems that the last on in is always the first one out.

On a similar topic, when I atack an AI military object the AI sends assistance from other nearby buildings, when the AI attacks one of my buildings nobody leaves any nearby buildings to help defend, How do I tell soldiers to help defend a nearby building?


Top Quote
wl-zocker

Joined: 2011-12-30, 16:37
Posts: 495
Ranking
Tribe Member
Location: Germany
Posted at: 2014-09-13, 13:27

1) Wounded soldiers being sent to attack is surely not the best way. There is currently no way to control which soldiers are sent out (and I have no idea how they are chosen by the game). If you would like to discuss this and bring in your ideas, you can write here: https://bugs.launchpad.net/widelands/+bug/585981. It makes sense to consider the soldiers' health, too.

2) The prefer heroes/rookies buttons have no influence on which soldiers go out to fight, but which soldiers go into this particular building. Buildings that prefer heroes get the trained soldiers (if available), buildings that prefer rookies get the untrained ones. This exchange is done automatically from time to time.

3) Soldiers do come out automatically when hostile soldiers attack somewhere nearby, there is no need to tell that explicitely. I do not know the exact conditions when this happens, but you need at least two soldiers in those buildings if you want them to help (one always has to guard his building, the others can help). I normally do not pay much attention to that, because if it works, it works (and if not, I cannot change it). However, if you have lost your building, you can attack with many more soldiers than those that helped to defend, so it normally is not that bad to lose a building.


"Only few people know how much one has to know in order to know how little one knows." - Werner Heisenberg

Top Quote
Ex-Member
Avatar
Topic Opener
Joined: 2014-09-12, 09:53
Posts: 184
Ranking
Widelands-Forum-Junkie
Posted at: 2014-09-13, 13:38
  1. I did not want to clutter bug reports with things that are not bugs, but will add something following your suggestion.

  2. That was how I thought it might work, thanks for the confirmation.

  3. I think in this case it was a sentry I had captured but there was no road connection to the rest of my economy, got to remember to join captured buildings to the rest of my road network.


Top Quote
wl-zocker

Joined: 2011-12-30, 16:37
Posts: 495
Ranking
Tribe Member
Location: Germany
Posted at: 2014-09-13, 13:50

I did not want to clutter bug reports with things that are not bugs

It is ok to write it in the forums. The developpers look here from time to time. However, bug reports can always be set to invalid or marked as wishlist item. Furthermore, features that Widelands has but that are not found by the players are also a kind of bug - what is a feature worth that nobody knows?


"Only few people know how much one has to know in order to know how little one knows." - Werner Heisenberg

Top Quote
DragonAtma
Avatar
Joined: 2014-09-14, 00:54
Posts: 351
Ranking
Tribe Member
Posted at: 2014-09-14, 01:37

Hello, everyone! I found widelands back in may 2012 and I've been lurking ever since. One thing I did notice is that -- thanks to https://wl.widelands.org/wiki/SoldierLevels/ -- it's possible to estimate the power of any soldier with a single number (feel free to guess how the three tribes compare; I'll give their stats a few paragraphs down).

Defense is "you block X%" of the damage, so 100 HP and 75 defense function the same as 400 HP and 0 defense. So you can multiply HP by (100/(100-defense)).
Evade is "you avoid damage X% of the time", so 100 HP and 75 evade is, on average, the same as 400 HP and 0 evade. So you can multiply HP by (100/(100-evade)).

That just leaves Attack and HP. But since "10-12 Attack, 100 HP, 0 defense, 0 evade" and "20-24 Attack, 50 HP, 0 defense, 0 evade" are pretty much the same (they'd both need five hits to take each other out), you can just multiply the two to get a single number.

That means the formula for a soldier's power would be ((MaxAttack+MinAttack)/2)*(100/(100-Defense))*(100/(100-Evade))*MaxHP.

So, how do the three compare? For total min-stat rookies, Atlanteans (2872.34) lead, followed by Empire (2736.84) and then Barbarians (2501.72). With maximum stats, Atlanteans (28668.09) still lead, again followed by Empire (27268.70), while Barbarians (24022.91) lag further behind. But make sure your Atlanteans get gold! Without gold-requiring equipment, they fall to last place (13081.4), behind Barbarians (14914.09) and Empire(16038.78).

So, why am I posting this seemingly off-topic info? Because it can be used to help solve the "wounded soldiers go out to fight" problem! If a soldier is 10000 power (according to the formula) but at 40% HP, he'd be about as useful as a soldier that's 5000 power but 80% health! So my advice is to use a formula something like this to determine who goes out:

(MaxAttack+MinAttack)/2)*(100/(100-Defense))*(100/(100-Evade))*CurHP*(CurHP/MaxHP)

That way, it'll prioritize how healthy a soldier is when choosing who to send out; a badly wounded hero and a slightly wounded rookie may be similar in battle at the moment, but the badly wounded hero'll heal a lot faster!


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 14:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2014-09-14, 07:27

That way, it'll prioritize how healthy a soldier is when choosing who to send out; a badly wounded hero and a slightly wounded rookie may be similar in battle at the moment, but the badly wounded hero'll heal a lot faster!

Also, the slightly wounded rookie is less of an investment than the badly wounded hero, so it would be more efficient to send out the rookie.


Busy indexing nil values

Top Quote
wl-zocker

Joined: 2011-12-30, 16:37
Posts: 495
Ranking
Tribe Member
Location: Germany
Posted at: 2014-09-14, 12:24

The idea makes sense.

I think there an error in the formula, it should read (MaxAttack+MinAttack)/2)*(100/(100-Defense))*(100/(100-Evade))*MaxHP*(CurHP/MaxHP). If you cancel MaxHP and the constant factors, you get (MaxAttack+MinAttack)/((100-Defense)(100-Evade))*CurHP.

Those soldiers are equally strong and die with the same percantage, but the trained soldier is a bigger loss. I would therefore divide this value by the costs the soldier has produced, cumulative for every step of his training. The costs should be something like log = 0.5 (thus wood = 2*log = 1), fish = meat = bread = 1, coal and the ores based on the food cost, since gold is rarer, multiply it by 1.5 or so. These parameters have to be adjusted with care so that the "best" soldier (the soldier a human would send out?) is sent out.


"Only few people know how much one has to know in order to know how little one knows." - Werner Heisenberg

Top Quote
DragonAtma
Avatar
Joined: 2014-09-14, 00:54
Posts: 351
Ranking
Tribe Member
Posted at: 2014-09-14, 13:12

I added the extra (CurHP/MaxHP) so it'd prioritize high-health soldiers over badly wounded soldiers (just like real life!). You don't have to use that chunk (which would give the same formula you suggested) if you don't mind seeing a veteran at 20% health being prioritized over a rookie at 80% health, but it'd just seem bizarre to me.

Imagine, for example, that you have two soldiers. One is a total novice (minimum in all stats, 130 HP); the other is wounded, minimum attack/defense/evade, but has maximized HP (130/214 HP). With your formula it'd pick one at random, while with mine it'd take the full-health rookie (which you'd likely want in-game as well!)

Of course, if a player assumes (whether correctly or incorrectly!) that they won't be losing any soldiers -- say, your soldiers are all somewhat trained, whereas the AI is only using total novices -- then going with your formula would be fine; I don't mind if the team gives you a choice whether to factor in the (CurHP/MaxHP) or not (although most of the time I'd be using my modified formula!)

Edited: 2014-09-14, 13:21

Top Quote
wl-zocker

Joined: 2011-12-30, 16:37
Posts: 495
Ranking
Tribe Member
Location: Germany
Posted at: 2014-09-14, 19:01

In the first two paragraphs, I did not introduce anything new, I merely corrected a fault you had made (at least what you wrote did not accord with your formula). In your first formula, you multiply with with MaxHP at the end, while in your second formula, you multiply with CurHP (and the relHP factor you introduced). It makes even sense that the maxHP cancel out, because when a soldier (with given evade, attack and defense) has 100 HP, it does not matter in battle whether he can have 130 or 214, simply because he will never get there. So the formula (MaxAttack+MinAttack)/((100-Defense)(100-Evade))*CurHP describes the soldier's power (in the lack of a better term). Soldiers of equal power have the same chance of winning, even when the distribution on the attributes is different.

As GunChleoc pointed out, a rookie is not such a big loss when he is killed as a hero (with the same strength), therefore some corrections have to be made when deciding which soldier should be sent out.
You did this by dividing by maxHP. I did a more general approch by using the costs a soldier has produced. Imagine two soldiers with the same power and the same maxHP (therefore the same send-out-value following your argumentation), but one is trained in evade (which is cheap) while the other is trained in attack (which needs iron and maybe gold). You would send out one soldier at random, but I would send out the cheaper one (remember that they have the same power, i.e. the same probability to win a battle). I therefore suggest something like efficiency (again in the lack of a better term) = power/f(costs), where f is a function that we need to optimize. (I imagine something like (sum(ware_weight*ware_amount))^cost_weight. For every ware a soldier has consumed, you check how many and multiply them with the ware_weight, which indicates the value of the ware (examples see above, e.g. meat = 1). You add up all those values. cost_weight indicates how important these costs actually are (^ means power, cost_weight = 0: does not matter, infinity: only they count and not the power, i.e. rookies will be sent out).)

To conlude:

  • power = (MaxAttack+MinAttack)/((100-Defense)(100-Evade))*CurHP. Soldiers with the same power fight equally well.
  • efficiency = power/f(costs). The most efficient soldier (a cheap one who fights relatively well) should be sent out.

Btw, I do not understand your last paragraph:

That way, it'll prioritize how healthy a soldier is when choosing who to send out; a badly wounded hero and a slightly wounded rookie may be similar in battle at the moment, but the badly wounded hero'll heal a lot faster!

Edited: 2014-09-14, 19:40

"Only few people know how much one has to know in order to know how little one knows." - Werner Heisenberg

Top Quote
DragonAtma
Avatar
Joined: 2014-09-14, 00:54
Posts: 351
Ranking
Tribe Member
Posted at: 2014-09-15, 01:57

We have two formulas:

Absolute formula: (MaxAttack+MinAttack)/2)*(100/(100-Defense))*(100/(100-Evade))*CurHP
Modified formula: (MaxAttack+MinAttack)/2)*(100/(100-Defense))*(100/(100-Evade))*CurHP*(CurHP/MaxHP)

Suppose we have two soldiers as well:
Wounded hero: 14000 power, 20% health (absolute: 2800, modified: 560)
Healthy rookie: 3000 power, 90% health (absolute: 2700, modified: 2430)

If you use the absolute formula, it will pick the wounded hero, because he's slightly more useful in battle -- but usually he's much stronger than he currently is, plus you spent a lot more resources in him. Sending him out to protect the rookie would be very wasteful, as the chance of winning is only slightly higher, but if he loses it's much worse for you. With the modified formula, because the wounded hero is so low on HP it'd clearly prefer the rookie (despite him being slightly less useful in a fight). And if the player has a choice, most of the time they don't want their hero to see battle until he's back to full health!

Also, the wounded hero will increase in power (by healing) a lot quicker than the healthy rookie. In the time that it takes the rookie to heal by 10% (for example, 90/100 health -> 100/100 health), suppose the wounded hero has enough max health they're only healed by 5% (for example, 40/200 health -> 50/200 health). Stats for the two will look like this:

Wounded hero: 14000 power, 25% health (absolute: 3500, modified: 875)
Healthy rookie: 3000 power, 100% health (absolute: 3000, modified: 3000)

Because the hero's base power is so much higher, healing raises his effective power much faster. That's what I was trying to explain with the confusing paragraph.


Top Quote