Algebraic solution towards unit and faction balancing?

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderator: Forum Moderators

Forum rules
Before posting a new idea, you must read the following:
User avatar
Daxion
Posts: 66
Joined: July 24th, 2009, 9:23 am

Re: Algebraic solution towards unit and faction balancing?

Post by Daxion »

from my poor memory of statistics, one thing that you could do is run an analysis on the approximate weights of all the unit stats towards unit cost. can't remember how the procedure is called, but all you'd need is a stats program and the patience for typing in all the data from all the mainline units. i might look into this further.
Basically what you want to do is a fit. What method is suitable here depends on the fuction you are trying to fit.
xbriannova took a function which is linear in all arguments. This could be a good approach, since it is easy to work with.
The basic idea behind a fit is always going to be: we/you define an "error function" which you try to minimise.

The following goes a bit off topic. Or at least the threat as a whole already has.

Anybody who's interested in a bit math should be supportet, so I'll try to explain a bit here (those who aren't, just skip over the part):
We have a set of parameters (m1,m2,....mN). Those are the important parameters.
We have a function of those parameters that results in the cost of a unit. Xbirannova used a linear function, but it doesn't have to.
The function also needs the values of the unit (i.e. dammage, HP, movement cost, resistances etc.). I'm denoting that as v1...vC

Code: Select all

f(m1,m2...mN,v1...vC) = unit gold
So our error for one unit is going to be:
we take the parameters m1...mN, and the values of the unit (which define the unit) and calculate the gold:

Code: Select all

f(m1...mN, v1_unit...vC_unit) = calc_gold
and now we take the difference to the actual playtested value: (calc_gold - unit_gold)
Since this can be positive and negative, and we want an error that always gets bigger we'll square that (otherwise, we might have 2 big errors which cancel each other out).

Code: Select all

err_unit1 = (calc_gold_unit1 - unit_gold_unit1) ²
and to get the total error we'll sum over all avaiable units (this most likely just going to be the mainline units. Take at least as many units as you have free parameters):

Code: Select all

total error = Sum(( calc_gold_unit - unit_gold_unit ) ²)
This is so far mainly independent of what fit method and what function you intend to use. The idea is always to minimise this total error (sometime you use a bit different error, but the idea is still the same).
There are different methods to go on from here. And looking from the theoretical side, even a trained neuronal network is not much different. Only that for a NN the used function is a little bit more complicated.
A usual way to minimise this error (for a big class of possible functions) is to use the gradiant and always "run down the slope". You'll have to do this for a few steps (in case of a NN quite alot of steps).

Basically I'm just using http://en.wikipedia.org/wiki/Least_squares as a reference. Which eventually leads to: [rul] http://en.wikipedia.org/wiki/Ordinary_Least_Squares[/url] as a method.
The nice thing about a linear function is, that you can determine your parameters "in one step". That is, you do alot of calculations, and you are done. This can be expressed with matricies. Yea matricies can be a bit taxing, but its really worth the effort if you know how to handle matrix equations (mainly because it's easy to implement in a computer programm, and there are quite a few algebraic packages out there, Mathlab, Octave, just to name two).

so we express our problme by a matrix equation:

Code: Select all

X*b = gold
now. b is our parameters m1 to mN just written under each other as a vector: (m1,m2,...,mN)
X a matrix, with all the unit values (defences, Hp etc.) next to each other. A new row mean the next unit.
gold, is a vector which has all the gold information. How much each unit costs, written under each other, in the same oder as you have arranged
the X matrix.

So if we write it all out, you'd have

Code: Select all

m1*value1_unit1 + m2*value2_unit1 +....+ mN*valueN_unit1 = gold_unit1
m1*value1_unit2 + m2*value2_unit2 +....+ mN*valueN_unit2 = gold_unit2
...
m1*value1_unitC + m2*value2_unitC +....+ mN*valueN_unitC = gold_unitC
The solution for m1...mN as a least square is given by: (see http://en.wikipedia.org/wiki/Ordinary_L ... Estimation

Code: Select all

m = (X' X)¯¹ X' y
Where X' means the transpose of X and A¯¹ the inverse of A (or in our case of X' X)

There are a few things to note:
1) Since all unit costs are without experience (they start out with XP = 0) you cannot introduce this as a parameter in m. If you do that, you probably end up with a matrix that cannot be inverted.
2) least squares is not necessarily the method which gives the best results. But it's an easy method (and probably sufficient).
3) the results might not be that good, since the unit cost might depent on faction necesseties (such as a faction needs something to move fast. Since no dedicated fast move is avaiable for said faction, probably the faster units are a bit cheaper). There are rounding errors (e.g. a Dwarf thunderer cannot cost 18.76 Gold, but would be rounded to 19 Gold). All this enters as "statistical errors" into the method, making it (and every other method) less accurate.
User avatar
Daxion
Posts: 66
Joined: July 24th, 2009, 9:23 am

Re: Algebraic solution towards unit and faction balancing?

Post by Daxion »

I've hacked a simple linear model into octave.

The script codes is here:
Spoiler:
The model used is:

Code: Select all

gold =   a0 * health_points + a1 * short_range_dmg_per_strike + a2 * short_range_number_of_strikes + a3 * long_range_dmg_per_strike	+ a4 * long_range_number_of_strikes
and the resulting parameters from fitting a few unit (elvish fighter, elvish hero, spearman, orc grunt, troll, dwarf fighter):

Code: Select all

 a0 =  1.068184
a1=  -1.627231
a2=  -4.716156
a3=   1.664715
a4=  -0.054841
It's a bit strange that some parameters seem to imply a negative cost :oops:


The current errors in gold are still:

Code: Select all

   0.92109 - elvish fighter
  -0.41868 - elvish hero
  -0.25121 - spearman
  -4.51360 - orc grunt
   2.46343 - troll
   0.94810 - dwarf fighter
(for this I used the difference between cost, as ingame and the model. Data comes from version 1.4)

I do agree that is not a terribly well result. For the simple fighter it works fine. Only the Troll and the Orc go off course.
The troll has regenerate and is overpriced compared to the model. That should be fine once those attributes are included.
The orc is way underpriced, which I think for compensating other pitfalls the notheners faction has.
User avatar
xbriannova
Posts: 237
Joined: August 2nd, 2009, 2:51 am

Re: Algebraic solution towards unit and faction balancing?

Post by xbriannova »

I see that you've taken an interest in an Algebraic solution towards unit balancing. I guess you've got me to thank XD. Anyway, I can't really understand your equations :'( I'm not mathematically inclined :-( I'm the kind of guy who leans towards the linguistic/literary side.

Anyway, I've tried automated testing. What I did is that I prepared a multiplayer faction that has all of my custom units and I pit one AI player against another. One AI player gets to control my faction. My idea of balance is that if there is balance, the two sides should be able to maintain a stalemate fight indefinitely (I am not expecting it to be indefinite of course, I'm more than eager to see a match that would last about 50-100 turns, that would be balanced enough for me).

For the experiment, we would of course need a positive control and I simulated a positive control by having two Loyalist sides fighting against each other in a 2-sided symmetrical map with 200 gold each and +10 gold income each. The match lasted 50+ turns. This is the result that I must achieve with my faction.

After tweaking my faction a little based on previous experimentations, I decided to give it a go- Well, I gave it about 3 gos actually. The first experiment resulted in a stalemate that lasted 50+ turns with the Guardian Order emerging as the winner! I was very happy. But the second experiment resulted in a match lasting only 15 turns with the Guardian Order emerging victorious. The third experiment resulted in a match lasting about 20+ turns with the Loyalists emerging as the triumphant. This, I think, proves that my faction is somewhat balanced against the Loyalists, although I would need a much bigger sample size to prove it.

As for the other races, I have done little experiments. The Guardian Order lost to the Orcs after 20+ turns in one experiment and the Guardian Order is utterly helpless against the Undead. The Elves were useless against the Guardian Order. More work needs to be done to balance my faction.
Current Projects:

UMC Campaign Guardian Order.
Main Campaign Thread: http://www.wesnoth.org/forum/viewtopic.php?f=8&t=26895
Art Thread: http://www.wesnoth.org/forum/viewtopic. ... 28&start=0
lotsofphil
Posts: 128
Joined: March 27th, 2009, 4:45 pm

Re: Algebraic solution towards unit and faction balancing?

Post by lotsofphil »

xbriannova wrote:My idea of balance is that if there is balance, the two sides should be able to maintain a stalemate fight indefinitely (I am not expecting it to be indefinite of course, I'm more than eager to see a match that would last about 50-100 turns, that would be balanced enough for me).
...
The match lasted 50+ turns. This is the result that I must achieve with my faction.
Very cool. Well done. I'd suggest that the aggregate win/loss record might be a better measure of balance (as you get a big enough sample). Some reasons why:
*If all games last 20 turns or less but Faction A wins 50% and Faction B wins 50%, that's still pretty balanced.
*2 equally skilled human players wouldn't necessarily engage in a long game.
*If the AI is keener on capturing/holding villages, that would artificially inflate the number of turns. Just a hypothetical, maybe a bit far-fetched.

This is very neat.
User avatar
Daxion
Posts: 66
Joined: July 24th, 2009, 9:23 am

Re: Algebraic solution towards unit and faction balancing?

Post by Daxion »

Earlier you said:
You're not getting the point. I'm forming a formula not to test whether the factions in a scenario would stand an equal chance in winning. I am forming an equation as a tool to determine whether two units, or by extension, whether two factions could make a stalemate on an average environment.

The game environment factors will not be expressed as those are tweaked normally by campaign authors to affect the difficulty of the scenario. By environment factors I don't just mean terrain. I meant income and base gold as well.
And now:
My idea of balance is that if there is balance, the two sides should be able to maintain a stalemate fight indefinitely (I am not expecting it to be indefinite of course, I'm more than eager to see a match that would last about 50-100 turns, that would be balanced enough for me).
What is it you are actually trying to find? Or better, what are you actually trying to balance? :hmm:
Know that would really help to find something like an algebraic solution to the problem (within the already stated bounds).
Factions and units are already balanced. So there's actually little to do with the math. I was just fitting a simple model really (in other words: just smashing the playtested values into a math expression).
I see that you've taken an interest in an Algebraic solution towards unit balancing. I guess you've got me to thank XD. Anyway, I can't really understand your equations :'( I'm not mathematically inclined :-( I'm the kind of guy who leans towards the linguistic/literary side.
Just get Octave (http://www.gnu.org/software/octave/) and run the script ( octave-dir:> octave scriptfile.txt ).
I hope it's well enough documented to expand it even without understanding everything in there (of course NOT understanding the underlying math, can lead to stupid errors, so proceed with a bit caution). Maybe I'll get around doing it myself (the most work is entering the values of all mainline units into the matrix)
User avatar
xbriannova
Posts: 237
Joined: August 2nd, 2009, 2:51 am

Re: Algebraic solution towards unit and faction balancing?

Post by xbriannova »

lotsofphil wrote:
xbriannova wrote:My idea of balance is that if there is balance, the two sides should be able to maintain a stalemate fight indefinitely (I am not expecting it to be indefinite of course, I'm more than eager to see a match that would last about 50-100 turns, that would be balanced enough for me).
...
The match lasted 50+ turns. This is the result that I must achieve with my faction.
Very cool. Well done. I'd suggest that the aggregate win/loss record might be a better measure of balance (as you get a big enough sample). Some reasons why:
*If all games last 20 turns or less but Faction A wins 50% and Faction B wins 50%, that's still pretty balanced.
*2 equally skilled human players wouldn't necessarily engage in a long game.
*If the AI is keener on capturing/holding villages, that would artificially inflate the number of turns. Just a hypothetical, maybe a bit far-fetched.

This is very neat.
Actually, what you said is really actually what I did. It's a mix of both really. I looked at the length of the match and I looked at the the win percentage of each faction. The reason why I thought a long game is an evidence of balance is because it shows that there is a great struggle for supremacy. If one side is extremely powerful compared to the other, wouldn't the extremely powerful just steamroll over the other side rather than to camp in the villages or engage in an extended melee?
Daxion wrote:Earlier you said:
You're not getting the point. I'm forming a formula not to test whether the factions in a scenario would stand an equal chance in winning. I am forming an equation as a tool to determine whether two units, or by extension, whether two factions could make a stalemate on an average environment.

The game environment factors will not be expressed as those are tweaked normally by campaign authors to affect the difficulty of the scenario. By environment factors I don't just mean terrain. I meant income and base gold as well.
And now:
My idea of balance is that if there is balance, the two sides should be able to maintain a stalemate fight indefinitely (I am not expecting it to be indefinite of course, I'm more than eager to see a match that would last about 50-100 turns, that would be balanced enough for me).
What is it you are actually trying to find? Or better, what are you actually trying to balance? :hmm:
Know that would really help to find something like an algebraic solution to the problem (within the already stated bounds).
Factions and units are already balanced. So there's actually little to do with the math. I was just fitting a simple model really (in other words: just smashing the playtested values into a math expression).
I see that you've taken an interest in an Algebraic solution towards unit balancing. I guess you've got me to thank XD. Anyway, I can't really understand your equations :'( I'm not mathematically inclined :-( I'm the kind of guy who leans towards the linguistic/literary side.
Just get Octave (http://www.gnu.org/software/octave/) and run the script ( octave-dir:> octave scriptfile.txt ).
I hope it's well enough documented to expand it even without understanding everything in there (of course NOT understanding the underlying math, can lead to stupid errors, so proceed with a bit caution). Maybe I'll get around doing it myself (the most work is entering the values of all mainline units into the matrix)
I'm trying to balance my faction and units. Those two go hand in hand as, to balance a faction, you must first balance the units. The faction and its units are intimately related you see.

As for Octave, I'll try it out. Man, where on Earth did you guys get those stuff?
Current Projects:

UMC Campaign Guardian Order.
Main Campaign Thread: http://www.wesnoth.org/forum/viewtopic.php?f=8&t=26895
Art Thread: http://www.wesnoth.org/forum/viewtopic. ... 28&start=0
lotsofphil
Posts: 128
Joined: March 27th, 2009, 4:45 pm

Re: Algebraic solution towards unit and faction balancing?

Post by lotsofphil »

Actually, what you said is really actually what I did. It's a mix of both really. I looked at the length of the match and I looked at the the win percentage of each faction. The reason why I thought a long game is an evidence of balance is because it shows that there is a great struggle for supremacy. If one side is extremely powerful compared to the other, wouldn't the extremely powerful just steamroll over the other side rather than to camp in the villages or engage in an extended melee?
Good point. You seem to be rolling along here, so all I have to add is "hope it works out."
User avatar
xbriannova
Posts: 237
Joined: August 2nd, 2009, 2:51 am

Re: Algebraic solution towards unit and faction balancing?

Post by xbriannova »

lotsofphil wrote:
Actually, what you said is really actually what I did. It's a mix of both really. I looked at the length of the match and I looked at the the win percentage of each faction. The reason why I thought a long game is an evidence of balance is because it shows that there is a great struggle for supremacy. If one side is extremely powerful compared to the other, wouldn't the extremely powerful just steamroll over the other side rather than to camp in the villages or engage in an extended melee?
Good point. You seem to be rolling along here, so all I have to add is "hope it works out."
Actually it kinda really is working out. When I saw that the Guardian Order faction is having a great struggle with the Loyalists, I was moved to tears really. It took me hours upon hours to get it right.

Anyway, I have a great idea. I'll just let you guys see my units/faction and you guys could decide whether they are balanced or not:

Order Infantry

Code: Select all

#textdomain wesnoth-go
[unit_type]
    id=Order Infantry
    name= _ "Order Infantry"
    race=human
    image="units/order_infantry.png"
    profile="portraits/humans/swordsman.png"
    {MAGENTA_IS_THE_TEAM_COLOR}
    hitpoints=40
    movement_type=smallfoot
    movement=5
    experience=50
    level=1
    alignment=lawful
    advanceto=null
    {AMLA_DEFAULT}
    cost=28
    usage=fighter
    description= _ "Trained in the well-funded barracks of the Guardian Order, the Order Infantry is the Guardian Order's rank-and-file infantry, but this is not to mean they are of mediocre quality- They are perhaps one of the best kind of soldiers fielded by men, exceptionally lethal on the offense as well as defense. They are hard to rid of, but expensive as well.

An 'average' Order Infantry is very well trained in the arts of war, particularly in the art of swordfighting. Their skill is focused on exhibiting grace, agility as well as power and strength in the use of blades. As a result, they are lethal when a melee exchange has taken place, being able to deliver blows quickly with precision, wisdom and force. This is very unlike the other schools of swordsmanship, that relies on brute force primarily."
    die_sound={SOUND_LIST:HUMAN_DIE}
    {DEFENSE_ANIM "units/order_infantry-defend.png" "units/order_infantry.png" {SOUND_LIST:HUMAN_HIT} }
    [resistance]
        blade=70
        impact=80
	  pierce=70
    [/resistance]
    [attack]
        name=sword
        description=_"sword"
        icon=attacks/sword-human.png
        type=blade
        range=melee
        damage=6
        number=5
    [/attack]
    [attack_anim]
        [attack_filter]
            name=sword
        [/attack_filter]
        [frame]
            begin=-200
            end=-175
            image="units/order_infantry.png"
        [/frame]
        [frame]
            begin=-175
            end=-75
            image="units/order_infantry.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-75
                end=75
                image="units/order_infantry-attack-2.png"
                sound={SOUND_LIST:SWORD_SWISH}
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-75
                end=75
                image="units/order_infantry-attack-2.png"
                sound={SOUND_LIST:MISS}
            [/frame]
        [/else]
        [frame]
            begin=75
            end=200
            image="units/order_infantry.png"
        [/frame]
    [/attack_anim]
[/unit_type]
Order Phalanx

Code: Select all

#textdomain wesnoth-go
[unit_type]
    id=Order Phalanx
    name= _ "Order Phalanx"
    race=human
    image="units/order_phalanx.png"
    profile="portraits/humans/pikeman.png"
    {MAGENTA_IS_THE_TEAM_COLOR}
    hitpoints=43
    movement_type=smallfoot
    movement=5
    experience=50
    level=1
    alignment=lawful
    advances_to=null
    {AMLA_DEFAULT}
    cost=28
    usage=fighter
    description= _ "The Phalanx is a distinctively Guardian Order innovation, a battle tactic that is a step up from the kind used with spears or pikes. While similar to the pike formation used by the numerous polearmed army of Wesnoth, the Phalanx has several differences that made it superior. For one, each individual Phalanx soldier within this Order formation is trained to tighten his grip upon his pike, and when necessary, bury the blunt end of his pike into the soil for further support. They were drilled to produce more frequent stabbing motions when up against non-charging adversaries. In summary, it all boils down to the technique of handling a pike as well as the amount of training.

Another notable difference between the Phalanx trained by the Order and that which is employed by the many barons, dukes and lords of Wesnoth is that each Phalanx soldier himself is an able fighter in terms of single combat. Normal pikemen rely on their fellow men for success on the field of battle, and should their position be broken, the entire cohort could easily be dispersed or killed off.

The Order Phalanx represents the heavy element of the Guardian Order infantry forces- they are normally more thoroughly armored than other infantries within the protective order, and are grilled to take even more punishment. Each stab and slash of their pike could gravely wound an average soldier, if not kill him."
    die_sound={SOUND_LIST:HUMAN_DIE}
    {DEFENSE_ANIM "units/order_phalanx.png" "units/order_phalanx.png" {SOUND_LIST:HUMAN_HIT} }
    [portrait]
        size=400
        side="left"
        mirror="false"
        image="portraits/humans/transparent/pikeman.png"
    [/portrait]
    [portrait]
        size=400
        side="right"
        mirror="true"
        image="portraits/humans/transparent/pikeman.png"
    [/portrait]
    [resistance]
        blade=60
        impact=70
	  pierce=60
    [/resistance]
    [death]
        [frame]
            begin=0
            end=80
            image="units/order_phalanx.png"
        [/frame]
        [frame]
            begin=80
            end=160
            image="units/order_phalanx.png"
        [/frame]
        [frame]
            begin=160
            end=240
            image="units/order_phalanx.png"
        [/frame]
        [frame]
            begin=240
            end=320
            image="units/order_phalanx.png"
        [/frame]
        [frame]
            begin=320
            end=400
            image="units/order_phalanx.png"
        [/frame]
    [/death]
    [attack]
        name=pike
        description=_"pike"
        type=pierce
        range=melee
        damage=8
        number=4
        [specials]
            {WEAPON_SPECIAL_FIRSTSTRIKE}
        [/specials]
    [/attack]
    [idle_anim]
        {STANDARD_IDLE_FILTER}
        start_time=0
        [frame]
            duration=100
            image="units/order_phalanx.png"
        [/frame]
        [frame]
            duration=100
            image="units/order_phalanx.png"
        [/frame]
        [frame]
            duration=100
            image="units/order_phalanx.png"
        [/frame]
        [frame]
            duration=1000
            image="units/order_phalanx.png"
        [/frame]
        [frame]
            duration=100
            image="units/order_phalanx.png"
        [/frame]
        [frame]
            duration=100
            image="units/order_phalanx.png"
        [/frame]
        [frame]
            duration=100
            image="units/order_phalanx.png"
        [/frame]
    [/idle_anim]
    [attack_anim]
        [filter_attack]
            name=pike
        [/filter_attack]
        direction=ne,nw
        [frame]
            begin=-250
            end=-150
            image="units/order_phalanx.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-150
                end=100
                image="units/order_phalanx.png"
                sound=spear.ogg
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-150
                end=100
                image="units/order_phalanx.png"
                sound=spear-miss.ogg
            [/frame]
        [/else]
        [frame]
            begin=100
            end=175
            image="units/order_phalanx.png"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=pike
        [/filter_attack]
        direction=se,sw
        [frame]
            begin=-250
            end=-150
            image="units/order_phalanx.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-150
                end=100
                image="units/order_phalanx.png"
                sound=spear.ogg
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-150
                end=100
                image="units/order_phalanx.png"
                sound=spear-miss.ogg
            [/frame]
        [/else]
        [frame]
            begin=100
            end=175
            image="units/order_phalanx.png"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=pike
        [/filter_attack]
        direction=n
        [frame]
            begin=-250
            end=-200
            image="units/order_phalanx.png"
        [/frame]
        [frame]
            begin=-200
            end=-100
            image="units/order_phalanx.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-100
                end=100
                image="units/order_phalanx.png"
                sound=spear.ogg
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-100
                end=100
                image="units/order_phalanx.png"
                sound=spear-miss.ogg
            [/frame]
        [/else]
        [frame]
            begin=100
            end=175
            image="units/order_phalanx.png"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=pike
        [/filter_attack]
        direction=s
        [frame]
            begin=-250
            end=-200
            image="units/order_phalanx.png"
        [/frame]
        [frame]
            begin=-200
            end=-100
            image="units/order_phalanx.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-100
                end=100
                image="units/order_phalanx.png"
                sound=spear.ogg
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-100
                end=100
                image="units/order_phalanx.png"
                sound=spear-miss.ogg
            [/frame]
        [/else]
        [frame]
            begin=100
            end=175
            image="units/order_phalanx.png"
        [/frame]
    [/attack_anim]
[/unit_type]
Order Archer

Code: Select all

#textdomain wesnoth-go
[unit_type]
    id=Order Archer
    name= _ "Order Archer"
    race=human
    gender=male
    image="units/order_archer.png"
    profile="portraits/humans/longbowman.png"
    ellipse="misc/ellipse"
    {MAGENTA_IS_THE_TEAM_COLOR}
    hitpoints=35
    movement_type=smallfoot
    movement=5
    experience=50
    level=1
    alignment=lawful
    advances_to=null
    {AMLA_DEFAULT}
    undead_variation=archer
    cost=26
    usage=archer
    description= _ "To complement their core infantries, the Guardian Order trains her own archers as well. Instructed by the gifted, these archers are far from perfect, but are still of excellent quality compared to the kind of bowmen employed by the many earldoms of men."
    die_sound={SOUND_LIST:HUMAN_DIE}
    [portrait]
        size=400
        side="left"
        mirror="false"
        image="portraits/humans/transparent/longbowman.png"
    [/portrait]
    [portrait]
        size=400
        side="right"
        mirror="true"
        image="portraits/humans/transparent/longbowman.png"
    [/portrait]
    [resistance]
        blade=80
        impact=90
	  pierce=80
    [/resistance]
    [attack]
        name=sword
        description=_"sword"
        icon=attacks/sword-human.png
        type=blade
        range=melee
        damage=8
        number=2
    [/attack]
    [attack]
        name=bow
        description=_"bow"
        type=pierce
        range=ranged
        damage=6
        number=4
    [/attack]
    [attack]
        name=bow
        description=_"bow"
        type=fire
        range=ranged
        damage=11
        number=2
    [/attack]
    {DEFENSE_ANIM_RANGE "units/order_archer.png" "units/order_archer.png" {SOUND_LIST:HUMAN_HIT} melee}
    {DEFENSE_ANIM_RANGE "units/order_archer.png" "units/order_archer.png" {SOUND_LIST:HUMAN_HIT} ranged}
    [attack_anim]
        [filter_attack]
            name=bow
	    type=pierce
        [/filter_attack]
        start_time=-445
        [missile_frame]
            begin=-150
            end=0
            image="projectiles/missile-n.png"
            image_diagonal="projectiles/missile-ne.png"
        [/missile_frame]
        [frame]
            duration=65
            image="units/order_archer.png"
        [/frame]
        [frame]
            duration=75
            image="units/order_archer.png"
        [/frame]
        [frame]
            duration=75
            image="units/order_archer.png"
        [/frame]
        [if]
            hits=no
            [frame]
                duration=100
                image="units/order_archer.png"
                sound=bow-miss.ogg
            [/frame]
        [/if]
        [else]
            hits=yes
            [frame]
                duration=100
                image="units/order_archer.png"
                sound=bow.ogg
            [/frame]
        [/else]
        [frame]
            duration=130
            image="units/order_archer.png"
        [/frame]
        [frame]
            duration=65
            image="units/order_archer.png"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=bow
	    type=fire
        [/filter_attack]
        start_time=-445
        [missile_frame]
            begin=-150
            end=0
            image="projectiles/missile-fire-n.png"
            image_diagonal="projectiles/missile-fire-ne.png"
        [/missile_frame]
        [frame]
            duration=65
            image="units/order_archer.png"
        [/frame]
        [frame]
            duration=75
            image="units/order_archer.png"
        [/frame]
        [frame]
            duration=75
            image="units/order_archer.png"
        [/frame]
        [if]
            hits=no
            [frame]
                duration=100
                image="units/order_archer.png"
                sound=bow-puny-fire-miss.ogg
            [/frame]
        [/if]
        [else]
            hits=yes
            [frame]
                duration=100
                image="units/order_archer.png"
                sound=bow-puny-fire.ogg
            [/frame]
        [/else]
        [frame]
            duration=130
            image="units/order_archer.png"
        [/frame]
        [frame]
            duration=65
            image="units/order_archer.png"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=sword
        [/filter_attack]
        start_time=-275

        [frame]
            duration=50
            image="units/order_archer.png"
        [/frame]
        [frame]
            duration=100
            image="units/order_archer.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                duration=100
                image="units/order_archer.png"
                sound={SOUND_LIST:SWORD_SWISH}
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                duration=100
                image="units/order_archer.png"
                sound={SOUND_LIST:MISS}
            [/frame]
        [/else]
        [frame]
            duration=100
            image="units/order_archer.png"
        [/frame]
        [frame]
            duration=100
            image="units/order_archer.png"
        [/frame]
        [frame]
            duration=50
            image="units/order_archer.png"
        [/frame]
    [/attack_anim]
[/unit_type]
Order Crossbowman

Code: Select all

#textdomain wesnoth-go
[unit_type]
    id=Order Crossbowman
    name= _ "Order Crossbowman"
    race=human
    gender=male
    image="units/order_crossbowman.png"
    profile="portraits/humans/longbowman.png"
    ellipse="misc/ellipse"
    {MAGENTA_IS_THE_TEAM_COLOR}
    hitpoints=37
    movement_type=smallfoot
    movement=5
    experience=50
    level=1
    alignment=lawful
    advances_to=null
    {AMLA_DEFAULT}
    undead_variation=archer
    cost=25
    usage=archer
    description= _ "Amongst Wesnothian armies, the crossbow was not seen as a fitting weapon for infantries due to the complex warfare against other races and themselves. It was however, more of tradition and old-thinking leadership that prevented the crossbow from being distributed to foot soldiers. The Guardian Order was able to transcend this limitation, and has started to field crossbowmen.

Despite being slow to reload, the crossbow do has its advantages- such as a higher penetrating power and a longer range. Moreover, it would take but a little more than several weeks for a man to be familiar with the crossbow while, unless one is an elf, it would take years upon years of exhaustive drilling to master the bow."
    die_sound={SOUND_LIST:HUMAN_DIE}
    [portrait]
        size=400
        side="left"
        mirror="false"
        image="portraits/humans/transparent/longbowman.png"
    [/portrait]
    [portrait]
        size=400
        side="right"
        mirror="true"
        image="portraits/humans/transparent/longbowman.png"
    [/portrait]
    [resistance]
        blade=80
        impact=90
	  pierce=80
    [/resistance]
    [attack]
        name=sword
        description=_"sword"
        icon=attacks/sword-human.png
        type=blade
        range=melee
        damage=7
        number=2
    [/attack]
    [attack]
        name=crossbow
        description=_"crossbow"
        icon=attacks/crossbow-human.png
        type=pierce
        range=ranged
        damage=14
        number=2
    [/attack]
    {DEFENSE_ANIM_RANGE "units/order_crossbowman.png" "units/order_crossbowman.png" {SOUND_LIST:HUMAN_HIT} melee}
    {DEFENSE_ANIM_RANGE "units/order_crossbowman.png" "units/order_crossbowman.png" {SOUND_LIST:HUMAN_HIT} ranged}
    [attack_anim]
        [filter_attack]
            name=crossbow
        [/filter_attack]
        start_time=-445
        [missile_frame]
            begin=-150
            end=0
            image="projectiles/missile-n.png"
            image_diagonal="projectiles/missile-ne.png"
        [/missile_frame]
        [frame]
            duration=65
            image="units/order_crossbowman.png"
        [/frame]
        [frame]
            duration=75
            image="units/order_crossbowman.png"
        [/frame]
        [frame]
            duration=75
            image="units/order_crossbowman.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                duration=100
                image="units/order_crossbowman.png"
                sound=crossbow.ogg
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                duration=100
                image="units/order_crossbowman.png"
                sound=crossbow-miss.ogg
            [/frame]
        [/else]
        [frame]
            duration=130
            image="units/order_crossbowman.png"
        [/frame]
        [frame]
            duration=65
            image="units/order_crossbowman.png"
        [/frame]
    [/attack_anim]
    [attack_anim]
        [filter_attack]
            name=sword
        [/filter_attack]
        start_time=-275

        [frame]
            duration=50
            image="units/order_crossbowman.png"
        [/frame]
        [frame]
            duration=100
            image="units/order_crossbowman.png"
        [/frame]
        [if]
            hits=yes
            [frame]
                duration=100
                image="units/order_crossbowman.png"
                sound={SOUND_LIST:SWORD_SWISH}
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                duration=100
                image="units/order_crossbowman.png"
                sound={SOUND_LIST:MISS}
            [/frame]
        [/else]
        [frame]
            duration=100
            image="units/order_crossbowman.png"
        [/frame]
        [frame]
            duration=100
            image="units/order_crossbowman.png"
        [/frame]
        [frame]
            duration=50
            image="units/order_crossbowman.png"
        [/frame]
    [/attack_anim]
[/unit_type]

Code: Select all

#textdomain wesnoth-go
[unit_type]
    id=Order Cataphract
    name= _ "Order Cataphract"
    race=human
    image="units/order_cataphract.png"
    profile="portraits/humans/cavalryman.png"
    ellipse="misc/ellipse"
    {MAGENTA_IS_THE_TEAM_COLOR}
    hitpoints=43
    movement_type=mounted
    movement=7
    experience=50
    level=1
    alignment=lawful
    advances_to=null
    {AMLA_DEFAULT}
    undead_variation=mounted
    cost=33
    usage=fighter
    #extra resistance for these units
    description= _ "Order Cataphracts are essentially mounted soldiers clad in thick armor who, in other armies, would surely forego such luxury as they are neither nobles nor knights. Similarly, the steed is well armored and bred of stamina, endurance and raw, physical power. The Cataphract was conceived as both a replacement of the typical light cavalry soldiers employed by Wesnothian governments as well as the knight- normal cavalrymen are simply too susceptible to anything with a pointy end while knights require a complex initiation program that would have taken more than a decade.

The Cataphract's main tactic is focused on literally slamming through enemy formations with the combined weight of both men and horses clad in high quality, thick and heavy armor. Like any other good mounted army however, they could simply unsheath their sword and join in a melee- for which they have plenty of opportunity to do, usually after their initial charge. More often than not however, a single, devestating charge would have been enough to break the foe, massacre them or both.

As a consequence of their armour, which is heavy even by a knight's standard, the Order Cataphract is slightly slower than a regular cavalry force, so they can never hope to catch up with the other horsemen fielded by men and other races."
    die_sound=horse-die.ogg
    [portrait]
        size=400
        side="left"
        mirror="false"
        image="portraits/humans/transparent/cavalryman.png"
    [/portrait]
    [portrait]
        size=400
        side="right"
        mirror="true"
        image="portraits/humans/transparent/cavalryman.png"
    [/portrait]
    [resistance]
        blade=60
        impact=60
	  pierce=70
    [/resistance]
    [movement_anim]
        [frame]
            begin=0
            end=150
            image="units/order_cataphract.png"
        [/frame]
    [/movement_anim]
    {DEFENSE_ANIM "units/order_cataphract.png" "units/order_cataphract.png" {SOUND_LIST:HORSE_HIT} }
    [death]
        [frame]
            begin=0
            end=200
            image="units/order_cataphract.png"
        [/frame]
        [frame]
            begin=200
            end=400
            image="units/order_cataphract.png"
        [/frame]
    [/death]
    [attack]
        name=sword
        description=_"sword"
        icon=attacks/sword-human.png
        type=blade
        range=melee
        damage=6
        number=4
    [/attack]
    [attack_anim]
        [filter_attack]
            name=sword
        [/filter_attack]
        [frame]
            begin=-225
            end=-200
            image="units/order_cataphract.png"
        [/frame]
        [frame]
            begin=-200
            end=-150
            image="units/order_cataphract.png"
            sound=horse-canter.wav
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-150
                end=150
                image="units/order_cataphract.png"
                sound={SOUND_LIST:SWORD_SWISH}
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-150
                end=150
                image="units/order_cataphract.png"
                sound={SOUND_LIST:MISS}
            [/frame]
        [/else]
        [frame]
            begin=150
            end=200
            image="units/order_cataphract.png"
        [/frame]
        [frame]
            begin=200
            end=225
            image="units/order_cataphract.png"
        [/frame]
    [/attack_anim]
    [attack]
        name=charge
        description=_"charge"
        icon=attacks/rectangular-shield.png
        type=impact
        [specials]
            {WEAPON_SPECIAL_CHARGE}
        [/specials]
        range=melee
        damage=20
        number=1
    [/attack]
    [attack_anim]
        [filter_attack]
            name=charge
        [/filter_attack]
        [frame]
            begin=-225
            end=-200
            image="units/order_cataphract.png"
        [/frame]
        [frame]
            begin=-200
            end=-150
            image="units/order_cataphract.png"
            sound=horse-canter.wav
        [/frame]
        [if]
            hits=yes
            [frame]
                begin=-150
                end=150
                image="units/order_cataphract.png"
                sound=club.ogg
            [/frame]
        [/if]
        [else]
            hits=no
            [frame]
                begin=-150
                end=150
                image="units/order_cataphract.png"
                sound={SOUND_LIST:MISS}
            [/frame]
        [/else]
        [frame]
            begin=150
            end=200
            image="units/order_cataphract.png"
        [/frame]
        [frame]
            begin=200
            end=225
            image="units/order_cataphract.png"
        [/frame]
    [/attack_anim]
[/unit_type]
I'll be pasting these onto my campaign thread as well, as this is my latest breakthrough in units/faction design and balancing.
Current Projects:

UMC Campaign Guardian Order.
Main Campaign Thread: http://www.wesnoth.org/forum/viewtopic.php?f=8&t=26895
Art Thread: http://www.wesnoth.org/forum/viewtopic. ... 28&start=0
Soliton
Site Administrator
Posts: 1683
Joined: April 5th, 2005, 3:25 pm
Location: #wesnoth-mp

Re: Algebraic solution towards unit and faction balancing?

Post by Soliton »

Upload your era to the addon server and it'll appear on units.wesnoth.org the next day.

Also to reiterate, factions are not balanced by units but as whole and no, the AI is not adequate to say much about the balance. If you take a look at the ai-test page you can see that the AI can not play all default factions equally well (or anywhere remotely as well as a human..).
"If gameplay requires it, they can be made to live on Venus." -- scott
User avatar
xbriannova
Posts: 237
Joined: August 2nd, 2009, 2:51 am

Re: Algebraic solution towards unit and faction balancing?

Post by xbriannova »

Soliton wrote:Upload your era to the addon server and it'll appear on units.wesnoth.org the next day.

Also to reiterate, factions are not balanced by units but as whole and no, the AI is not adequate to say much about the balance. If you take a look at the ai-test page you can see that the AI can not play all default factions equally well (or anywhere remotely as well as a human..).
What makes up a faction? The units. Therefore by changing the units around you could balance the faction. You could balance a faction by either changing a unit's statistics or by swapping/adding/removing units. The way I see it, that's common sense. By changing the units in anyway, you're changing the factions. But of course, I do know the the whole is never the sum of its parts- that is why the way units complement each other could generate extra capabilities for the faction. Still, you will always be able to balance a faction by changing the units in it.

Hmm... If what you say is correct about the AI not being able to play every factions equally well, then my experiments would be flawed. Man, what am I supposed to do? Do I play with myself or something? One thing for sure is that I don't think I'm gonna concentrate on unit balancing as much as I concentrate on finishing my campaign.
Current Projects:

UMC Campaign Guardian Order.
Main Campaign Thread: http://www.wesnoth.org/forum/viewtopic.php?f=8&t=26895
Art Thread: http://www.wesnoth.org/forum/viewtopic. ... 28&start=0
User avatar
melinath
Posts: 1298
Joined: May 20th, 2009, 7:42 am

Re: Algebraic solution towards unit and faction balancing?

Post by melinath »

you'll have to do what Steelhive Faction and Era of the Future do and find people to beta test... or beta test yourself.
User avatar
xbriannova
Posts: 237
Joined: August 2nd, 2009, 2:51 am

Re: Algebraic solution towards unit and faction balancing?

Post by xbriannova »

melinath wrote:you'll have to do what Steelhive Faction and Era of the Future do and find people to beta test... or beta test yourself.
Hmm... That I might do... Maybe both ways.
Current Projects:

UMC Campaign Guardian Order.
Main Campaign Thread: http://www.wesnoth.org/forum/viewtopic.php?f=8&t=26895
Art Thread: http://www.wesnoth.org/forum/viewtopic. ... 28&start=0
Velensk
Multiplayer Contributor
Posts: 4002
Joined: January 24th, 2007, 12:56 am

Re: Algebraic solution towards unit and faction balancing?

Post by Velensk »

I find this thread frustrating to behold.

Yes you balance factions by changing units/adding/removing units however this isn't an equasion, it is the effect that comes out on the field and simply playing the game is the best way to see which effects are the ones causing problems. It is more accurate, quicker, and IMO funner.

You are balancing a campaign, as such. Your faction does not need to be balanced to make it fun. Your faction could be obviously overpowered or obviously underpowered and quirky and you could still make a campaign that works and is fun. Unless you want to try to get this faction into mulitplayer, then do not worrry about balancing your faction. Instead, balance your campaign. If they are overpowered, then send enough/strong enough enemies at them to make it interesting. If they are underpowered, then make it so that there are still ways you could use them to defeat an overwhelming force. If your faction levels up too quickly then either fix that or include a couple 'kill em' scenarios in your campaign (scenarios that feature enemies with high offensive power such as magicians and lancers. You do not have to spend all that time away from your campaign worrying about faction balance, when you can infact just balance them within your campaign. This also allows you to work with a greator veriety of possibilities (consiter how potentially interesting a campaign where your basic infantry was a teleporter, or where your entire faction was cavarly type units, or where you had a tunnler unit who could dig through cave walls by moving into them).

A few simple tests could have told you what Soliton told you about the AI as long as you're willing to assume the people who tell you that all the factions are balanced, know what they are talking about. Wesnoth mulitplayer is balanced on the assumption that both players know what they are doing and are skilled. When you think about it, mathmatically the drakes could never beat the undead who would simply need a few meat sheilds then enough dark adepts to clean the map with drakes at any time other than day. If you play this match-up with the AI I think you'll find that you get this result too (I don't know for certain I havn't tried checking, but I do know that the AI does factor in what their opponent is when they recruit). However, when it comes to two good players against each other it is so much more even (Infact a few believe that it favors the drakes).

Edit: to fix a repeated sentance

Edit2: Having done some quick testing (nothing difinitive) I picked 5 maps, had the AI play 2 games on each map (ud vs dr and dr vs ud). The undead won 8 games out of 10. One of the games they lost was ud vs dr on fallenstar, primaraly because their leader did not castle jump forward and the drake leader did, this was reversed in the next game. The other was on caves of the baskalisk where the drakes did a leader assassination against the undead.
"There are two kinds of old men in the world. The kind who didn't go to war and who say that they should have lived fast died young and left a handsome corpse and the old men who did go to war and who say that there is no such thing as a handsome corpse."
User avatar
xbriannova
Posts: 237
Joined: August 2nd, 2009, 2:51 am

Re: Algebraic solution towards unit and faction balancing?

Post by xbriannova »

Velensk wrote:I find this thread frustrating to behold.

Yes you balance factions by changing units/adding/removing units however this isn't an equasion, it is the effect that comes out on the field and simply playing the game is the best way to see which effects are the ones causing problems. It is more accurate, quicker, and IMO funner.

You are balancing a campaign, as such. Your faction does not need to be balanced to make it fun. Your faction could be obviously overpowered or obviously underpowered and quirky and you could still make a campaign that works and is fun. Unless you want to try to get this faction into mulitplayer, then do not worrry about balancing your faction. Instead, balance your campaign. If they are overpowered, then send enough/strong enough enemies at them to make it interesting. If they are underpowered, then make it so that there are still ways you could use them to defeat an overwhelming force. If your faction levels up too quickly then either fix that or include a couple 'kill em' scenarios in your campaign (scenarios that feature enemies with high offensive power such as magicians and lancers. You do not have to spend all that time away from your campaign worrying about faction balance, when you can infact just balance them within your campaign. This also allows you to work with a greator veriety of possibilities (consiter how potentially interesting a campaign where your basic infantry was a teleporter, or where your entire faction was cavarly type units, or where you had a tunnler unit who could dig through cave walls by moving into them).

A few simple tests could have told you what Soliton told you about the AI as long as you're willing to assume the people who tell you that all the factions are balanced, know what they are talking about. Wesnoth mulitplayer is balanced on the assumption that both players know what they are doing and are skilled. When you think about it, mathmatically the drakes could never beat the undead who would simply need a few meat sheilds then enough dark adepts to clean the map with drakes at any time other than day. If you play this match-up with the AI I think you'll find that you get this result too (I don't know for certain I havn't tried checking, but I do know that the AI does factor in what their opponent is when they recruit). However, when it comes to two good players against each other it is so much more even (Infact a few believe that it favors the drakes).

Edit: to fix a repeated sentance

Edit2: Having done some quick testing (nothing difinitive) I picked 5 maps, had the AI play 2 games on each map (ud vs dr and dr vs ud). The undead won 8 games out of 10. One of the games they lost was ud vs dr on fallenstar, primaraly because their leader did not castle jump forward and the drake leader did, this was reversed in the next game. The other was on caves of the baskalisk where the drakes did a leader assassination against the undead.
Let's just say I think on the long term and yes, I was hoping that one day my units could somehow make it into multiplayer, or would inspire a different set of units to be made for multiplayer. Ultimately, whether it would show or not, I'd still want to balance my units against the mainline ones- it's an accomplishment to me that I am more willing to attempt and the way I see it, it'd make things more controllable for me as the author. I don't know, it seems like the way to go. If this is a mistake then I'm afraid I'm gonna have to learn it the hard way.

I'm sorry I hurt your eyes :cry:

Hmm... Maybe by doing this I'd gain the essential skill of balancing eventually
Current Projects:

UMC Campaign Guardian Order.
Main Campaign Thread: http://www.wesnoth.org/forum/viewtopic.php?f=8&t=26895
Art Thread: http://www.wesnoth.org/forum/viewtopic. ... 28&start=0
Noy
Inactive Developer
Posts: 1321
Joined: March 13th, 2005, 3:59 pm

Re: Algebraic solution towards unit and faction balancing?

Post by Noy »

xbriannova wrote: Let's just say I think on the long term and yes, I was hoping that one day my units could somehow make it into multiplayer, or would inspire a different set of units to be made for multiplayer. Ultimately, whether it would show or not, I'd still want to balance my units against the mainline ones- it's an accomplishment to me that I am more willing to attempt and the way I see it, it'd make things more controllable for me as the author. I don't know, it seems like the way to go. If this is a mistake then I'm afraid I'm gonna have to learn it the hard way.

I'm sorry I hurt your eyes :cry:

Hmm... Maybe by doing this I'd gain the essential skill of balancing eventually
Or you'll fail, which seems almost certain given your attitude. I don't know why you're being so insensitive, given all the good advice you've been given along the way. Basically you have people with advanced degrees in stats or have assisted in game balancing for two years or more... and you ignore them or give them highly trite answers. This is most apparent when you told Soliton, a developer of four years, "factions are made up of units." Thats about the dumbest response I have ever read on this forum and thats saying alot.

You've ignored all of the reasoning behind why this isn't an very feasible project, just to push your preferred option of creating a formula for balancing. It turns people off, the very same people who you need to help to get your project into mainline.
I suspect having one foot in the past is the best way to understand the present.

Don Hewitt.
Locked