Combat outcome calculation (berserk)

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
SlowThinker
Posts: 876
Joined: November 28th, 2008, 6:18 pm

Combat outcome calculation (berserk)

Post by SlowThinker »

In past I played SX maps with BfW 1.4 and noticed an extremely long computation if two very strong units faced one another.
Then I had heard the algorithm was improved, but now I have heard the outcome computation is still very slow.

The slowness of the algorithm is suspicious for me, I think it should be quite fast in case it was done in C++.
Can anyone tell how is the algorithm done roughly?
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
SlowThinker
Posts: 876
Joined: November 28th, 2008, 6:18 pm

Re: Combat outcome calculation (berserk)

Post by SlowThinker »

That thread is related to the topic, but it doesn't explain the algorithm that computes the outcome matrix...
User avatar
Crab
Inactive Developer
Posts: 200
Joined: March 18th, 2009, 9:42 pm

Re: Combat outcome calculation (berserk)

Post by Crab »

roughly: create hp distribution matrix, set to initial hitpoints, 'simulate' all attacks, changing the hp distribution matrix in the process, after each attack. see
http://svn.gna.org/viewcvs/wesnoth/trun ... iew=markup
Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Combat outcome calculation (berserk)

Post by Max »

Sapient wrote:In attack evaluation phase it builds a matrix of every possible outcome, and you can see this also in the damage calculations preview. If a unit has thousands of hitpoints, drain and/or berserk then it will cause a real slowdown.
it just doesn't scale well here. has nothing to do with c++...

http://mirror.linux.org.au/linux.conf.a ... gaming.ogg
(~1h50)
SlowThinker
Posts: 876
Joined: November 28th, 2008, 6:18 pm

Re: Combat outcome calculation (berserk)

Post by SlowThinker »

Crab wrote:... 'simulate' all attacks ...
There is no need to simulate anything:

I attached a file with a simple algorithm that counts a chance to kill for each specific strike. The distribution matrix may be computed from the spreadsheet this way:
for each cell in columns R (chance attacker kills now) and S (chance defender kills now) one can easily count a partial hp distribution matrix (rather hp distribution *vector*, because one side always dies), then add distribution matrixes of individual cells together.

the algorithm contains a mistake. Will you be the first one who finds it out?
Edit: the attached file contains formulas in cells now.
Attachments
berserk_calculator.zip
(19.86 KiB) Downloaded 323 times
Last edited by SlowThinker on April 4th, 2012, 3:31 pm, edited 4 times in total.
User avatar
Drakefriend
Posts: 436
Joined: September 27th, 2009, 12:57 pm
Location: Wandering from one world to another
Contact:

Re: Combat outcome calculation (berserk)

Post by Drakefriend »

SlowThinker wrote:
Crab wrote:... 'simulate' all attacks ...
There is no need to simulate anything:

I attached an Excel file with a simple algorithm that counts a chance to kill for each specific strike. The distribution matrix may be computed from the spreadsheet this way:
for each cell in columns R (chance attacker kills now) and S (chance defender kills now) one can easily count a partial hp distribution matrix (rather hp distribution *vector*, because one side always dies), then add distribution matrixes of individual cells together.
But you also have to calculate the hitpoints for any combinition of hits, which is important for the surviving unit, and for normal combat.
After far too long an absence, I have returned.
According to the quiz 100% Silver Mage (85% Archmage, 75% Shyde, 67% Flameheart and Ancient Wose,58% Assassin, Troll Warrior and Berserker). And my top score is exactly how I see myself.
SlowThinker
Posts: 876
Joined: November 28th, 2008, 6:18 pm

Re: Combat outcome calculation (berserk)

Post by SlowThinker »

Drakefriend wrote:But you also have to calculate the hitpoints for any combinition of hits, which is important for the surviving unit, and for normal combat.
Why would I need it? I believe all I need is the aggregate hp distribution matrix.

____________________________________________
Edit: My apologies, the original spreadsheet didn't contain formulas, only values.

:) But why nobody complained? I said "I attached a file with an algorithm", but there was nothing resembling to an algorithm ... 6 people downloaded it ...
Post Reply