Currently Online

Latest Posts

Topic: Define if strong or werk soldiers should attack first

corsch
Avatar
Topic Opener
Joined: 2017-05-29, 20:54
Posts: 6
Ranking
Pry about Widelands
Posted at: 2017-05-29, 21:28

It would be nice if you could decide if the stronger or the weaker soldiers should attack first.


Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 19:48
Posts: 2439
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2017-05-29, 22:08

As far as i know the strongest soldiers attack first per default. Not sure though...


Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 03:10
Posts: 2094
OS: Linux
Version: Recent tournament version
Ranking
One Elder of Players
Location: Germany
Posted at: 2017-05-30, 00:09

kaputtnik wrote:

As far as i know the strongest soldiers attack first per default. Not sure though...

That would be nice. But I'm sure that they don't do that

corsch wrote:

It would be nice if you could decide if the stronger or the weaker soldiers should attack first.

Yes, you're right. In fact one is able to manage that only the best soldiers attack, but that requires some micromanagement and the weaker soldiers leave the buildings in this case, so that's a problem. And it doesn't always work. And of course it's hard to figure it out how it works face-wink.png


Wanted to save the world, then I got widetracked

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

I dug up the code:

// TODO(unknown): Perform a meaningful sort on the soldiers array.
uint32_t
Player::find_attack_soldiers(Flag& flag, std::vector<Soldier*>* soldiers, uint32_t nr_wanted) {

As you can see from the TODO comment, nothing smart is being done here yet. If simply grabs the requested amount of soldiers wherever it can find them. And then the first soldier who gets there is the first to attack. I haven't looked at how it works once a bunch of soldiers are awaiting their turn to attack.

I think the algorithm should get all available soldiers, sort them by strength, and then get the strongest ones until the requested amount is sent. We also should take current health into account, so it's not that simple.


Busy indexing nil values

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 17:07
Posts: 1949
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2017-05-30, 12:27

How about calculating a soldier´s strength by adding his trainining levels and multiplying the sum with his health percentage?

For example, a soldier with levels AT3/EV2/DE0/HP0 and a current health status of 80% would get a strength of (3+2+0+0)*80%=4.

And when several soldiers are waiting to attack, we could either have First Come First Served or Strongest First.


Top Quote
king_of_nowhere
Avatar
Joined: 2014-09-15, 17:35
Posts: 1668
Ranking
One Elder of Players
Posted at: 2017-05-30, 14:27

kaputtnik wrote:

As far as i know the strongest soldiers attack first per default. Not sure though...

to the best of my knowledge, it isn't always so. the soldier who has the higher chance of being sent to attack is the one on the left, followed by the one on the right, with those in the middle coming last.getting to cchoose would be great, but as far as i understnd the code, it does not make any difference among the soldiers. I proposed to sort soldier by skill, turning elite and mook soldiers into different kinds of wares, but that would require some reworking of the code.

speaking of soldiers priority, it would also be nice if, when all the soldiers are sent out to meet an invader, one of the stronger was left inside the building. as it is, a castle with 11 fullly promoted soldiers and 1 untrained could be conquered by 2 untrained soldiers with a bit of subterfuge.


Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 03:10
Posts: 2094
OS: Linux
Version: Recent tournament version
Ranking
One Elder of Players
Location: Germany
Posted at: 2017-05-31, 20:26

Nordfriese wrote:

How about calculating a soldier´s strength

It seems to me that this is already done somehow. You can watch it if the attacking enemy is right before the military building: I think the "strongest" soldier usually goes outside. But it seems that an badly injured elite-soldier has lower "strength" then a healthy untrained soldier...

by adding his trainining levels and multiplying the sum with his health percentage?

Well, if you add just the levels, that's not that accurate. And only multiplying with the health percentage could also be problematic. Why? Because an elite soldier is approximately ten times stronger than an untrained soldier, but if his health is at 10%, he should never go out instead of an untrained soldier, right? So maybe it should be multiplied with the health percentage once more, or something like this.


Wanted to save the world, then I got widetracked

Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 03:10
Posts: 2094
OS: Linux
Version: Recent tournament version
Ranking
One Elder of Players
Location: Germany
Posted at: 2017-05-31, 20:27

king_of_nowhere wrote:

speaking of soldiers priority, it would also be nice if, when all the soldiers are sent out to meet an invader, one of the stronger was left inside the building. as it is, a castle with 11 fullly promoted soldiers and 1 untrained could be conquered by 2 untrained soldiers with a bit of subterfuge.

Yes


Wanted to save the world, then I got widetracked

Top Quote
ypopezios
Avatar
Joined: 2018-04-19, 23:22
Posts: 220
Ranking
Widelands-Forum-Junkie
Posted at: 2018-04-30, 15:29
// TODO(unknown): Perform a meaningful sort on the soldiers array.
uint32_t Player::find_attack_soldiers(Flag& flag, std::vector<Soldier*>* soldiers, uint32_t nr_wanted) {

GunChleoc wrote:

As you can see from the TODO comment, nothing smart is being done here yet.

I think the algorithm should get all available soldiers, sort them by strength, and then get the strongest ones until the requested amount is sent. We also should take current health into account, so it's not that simple.

This sounds like an algorithm I could work with. Any chance of someone pointing me to relevant files?


Top Quote
teppo

Joined: 2012-01-30, 08:42
Posts: 423
Ranking
Tribe Member
Posted at: 2018-04-30, 16:49

king_of_nowhere wrote:

speaking of soldiers priority, it would also be nice if, when all the soldiers are sent out to meet an invader, one of the stronger was left inside the building. as it is, a castle with 11 fullly promoted soldiers and 1 untrained could be conquered by 2 untrained soldiers with a bit of subterfuge.

Why do so many soldiers leave the building?

While being attacked, I have often hoped that some who are in bad need of healing would stay inside and recover, instead of picnicking outside.


Top Quote