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 »

Okay, how do I test the formula? By factoring in a unit and see if it all makes sense :P I'm seeing some consistency when I did that in my formula. What happened is that I put in the Spearman into my formula and everything looks good, but the movement is at 8.75. So what I conclude is that each factor, or a unit's statistic, could be exchanged for one another like how you do it in an RPG game. It is algebra after all- the actual numerical value of each expression is never actually determined. I believe, by exchanging one factor with another, I will eventually end up with the actual spearman's statistics and this is how we balance units- by giving it disadvantages to bestow advantages to it.
This is bound to run up against a wall sooner or later. Even in theoretical physics you don't do things that do not lead to an experiment (eventually, okay maybe with exception of the string theory, but they are doing it only because they hope that somesay they can test it via some kind of experiment). Sooner or later you have to test it in the "real world" (here that means: in game). Test a formula with a gedanken-experiment is fine, but only shows that the result is what you imagined, not that it works.

Seconds: RPGs often have a huge problem in their rules, as they reflect some situations fine, but fail catastrophically in others (Star Wars D6 with snipers come to mind).

And somehow I feel you are taking a bit of a wrong path here. What are you trying to achieve? Confirming the unit cost based on math? I don't want to say it can't work, but mainly alot of people have playtested the unit cost. In other words, they already know how far the ball will fly, because they have thrown it. This can only be usefull if you intend to tax new unit types (still doesn't rid you of the need to playtest).
Or do you want to get an idea if a scenario is balanced? In that case you have the problem that you are simply ignoring terrain. And I would say that about 40-60% of the balancing comes from just that. And I don't even know how to start to get a complete (in the sense of always correct) formula for that.

I'll now continue assuming you're looking the second option.
The goal I'm now trying to achieve is, pushing the "uncertaincies" into some corner, as the user for the formula just needs to determain a few "values" but looking at the scenario.

I'm assuming a few things:
1) The user can determain the main dominating terrain type, that are going to decide the scenario.
2) the user can determain how prevalent it is.
3) a set of variables is know and documented (well...someone would need to come up with that by playtesting or other means)

for 3:
among the variables is a table in which each faction and dominanat terrain type get a "weighting factor". This is really what it's all about
weighting the whole landscape.

So the basic thing should look something like that:
wf( faction, dominant terrain) * prevalence = income-factor (or start gold factor)
in the weighting factor (wf) is really the main thing. First throw would be to have elves on forrest 0.7, on hills 0.9, water 1.3, 1 otherwise.
For prevalence, just take a look how much tiles are dominated by the terrain and devide by total hex number.
This sounds too easy, and I agree it is. But it would need waaaaaay to much fitting (each faction-terrain combination needs a factor determaind), my advice by looking at it would be: just forget about it
User avatar
xbriannova
Posts: 237
Joined: August 2nd, 2009, 2:51 am

Re: Algebraic solution towards unit and faction balancing?

Post by xbriannova »

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.

Yes, I intend to do experiments with this actually. There are many ways to do it. I could either apply this theory and create units based off the algebraic expression and then test them out on well-balanced maps. The possibility is endless.

There's too much to say, too much to do... I think this is all I can type for now.
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
Daxion
Posts: 66
Joined: July 24th, 2009, 9:23 am

Re: Algebraic solution towards unit and faction balancing?

Post by Daxion »

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.
Okay. What you are now trying to do is a linear fit (however in quite alot of dimensions).
You might want to take a look at:
http://en.wikipedia.org/wiki/Linear_regression
http://en.wikipedia.org/wiki/Least_squares
http://documents.wolfram.com/applicatio ... iques.html
I'm not quite sure if the described techniques work that well in your case.

This assumes, there exist a pair of variables for your equation, and the users / wesnoth team, has already found the correct number of Gold for each unit, however with possibly an error (in the end, there's bound to be one, due to the fact that the unit cost is actually rounded to a cold coin)

Another pitfall is, that the factors are not really linear. But you'll notice that, if your errors get to big. In that case you'd have to revert to a polynomial function.
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 »

xbriannova wrote: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.
You might not have heard it yet but factions are not balanced unit by unit but as a whole. You can see that from some mentioned examples in this thread. That means you will never come to a formula that determines the value of each unit in default correctly this way. (Except in a way like: if unit == spearman then cost = 14 gold etc.. which obviously defeats the whole point.) Your premise is wrong.
"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 »

Alright, all I can say is, if I'm going all out on this, this is going to take alot of work. What I've presented so far is the very first prototype formula. It's not the final thing. That is, assuming I'm going all out on this. I think I'm only going to go part time on this.
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
Daxion
Posts: 66
Joined: July 24th, 2009, 9:23 am

Re: Algebraic solution towards unit and faction balancing?

Post by Daxion »

Listen to Soliton :eng: He's absolutly right, it's sort of missing the point in terms of usefullness. The only value would be in knowing how much a unit should cost if you create your onw new unit in a campaign. But you can rather easily playtest.
The only other thing where it might be usefull is with variable recall costs. But for this you are really just making an overkill. Unit recruitment cost, with Experience factored in should do the trick for this (and is by the way much less work, and easier to get right, downside is, you don't have all that nice fit-data)
lotsofphil
Posts: 128
Joined: March 27th, 2009, 4:45 pm

Re: Algebraic solution towards unit and faction balancing?

Post by lotsofphil »

xbriannova,

If I were you, I would go about this differently. Instead of working out some ideal of balance and seeing if your faction fits the mold, work the other way. Have a faction and then test it for balance.

What I mean is, you seem like you are looking for some formula into which you'll input hundreds of terrain defenses, traits, etc and get some verdict about balance. Instead picture something like "if my new faction plays 100k games against the undead, it will win XX% of the time." If XX is too high, your faction is likely too strong. If XX is too low, it's too weak.

Instead of coming up with a formula, try to use the game as a formula.

If you want to go forward with this, use the fact that you have a probabilistic system and a way to run lots of paths (Wesnoth games/battles). Think Monte Carlo.
User avatar
xbriannova
Posts: 237
Joined: August 2nd, 2009, 2:51 am

Re: Algebraic solution towards unit and faction balancing?

Post by xbriannova »

*Sigh* You guys are probably right. I think I'm really going to have to make the necessary preparations to test my units. But then again... It'd be an awful waste to just leave all that algebraic expression lying around. I'm gonna try and perfect it for fun and curiosity. Who knows? There might come a time in which I might need it someday.
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 »

I didn't mean to discourage you (entirely). It's a thorny problem and you said it isn't in your strongest area. Do you know what Monte Carlo simulation is? If you could set something up with a test suite of scenarios (unit mix, maps, t.o.d, aggressiveness, etc) and then have a way of churning through thousands of simulations using the wesnoth AI, that would be really cool (even if it spit out garbage). You have 5 or 6 controls (the balanced mainline factions) and can create obvious failure cases (give spearmen 100% to hit, make great mages recruitable for 10 gp).

I meant Wesnoth AI can be your black box. It can tell you if a faction is balanced without you needing to know a formula.
User avatar
xbriannova
Posts: 237
Joined: August 2nd, 2009, 2:51 am

Re: Algebraic solution towards unit and faction balancing?

Post by xbriannova »

Hmm... Alright... I think I can do just that... I'd be slower though. My way of doing that simulation would of course be a simpler way :wink:

I'm not gonna run 1000s of skirmishes. Maybe several everytime I change the units about.
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: I'm not gonna run 1000s of skirmishes. Maybe several everytime I change the units about.
The key to what I am suggesting would be to automate it :) I imagine the ai function calls would be quite fast without any gui/graphics/sound involved.
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 »

http://ai-test.wesnoth.org
lotsofphil wrote:I meant Wesnoth AI can be your black box. It can tell you if a faction is balanced without you needing to know a formula.
Note that the AI is not used in actual balancing and we'll not spend any effort into making default balanced for it.
"If gameplay requires it, they can be made to live on Venus." -- scott
User avatar
ancestral
Inactive Developer
Posts: 1108
Joined: August 1st, 2006, 5:29 am
Location: Motion City

Re: Algebraic solution towards unit and faction balancing?

Post by ancestral »

Despite comments detailing that there isn't a algebraic forumla for unit balancing, attacks and damage are however calculated fairly geometrically. Some of the lower level units and units which spawn branches or introduce a powerful new ability are often the exception, but if you take most any unit tree in mainline and multiply the attacks and damage and compare them to the next level up, the rate is consistent, with a slight tendency of rounding down.
Wesnoth BestiaryPREVIEW IT HERE )
Unit tree and stat browser
CanvasPREVIEW IT HERE )
Exp. map viewer
User avatar
Kip-of-teh-Mud
Posts: 9
Joined: July 5th, 2009, 9:01 pm

Re: Algebraic solution towards unit and faction balancing?

Post by Kip-of-teh-Mud »

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.

it would give you a tool to determine how much a unit should theoretically cost to be comparable to mainline, and the cool thing is, it only uses the unit stats that have been heavily playtested and wouldnt need any extra considerations.

of course, certain units would probably need a different cost if they were in a different faction.. but using statistics instead of algebra would give you these 'error terms' as well, e.g. show how much a unit cost deviates from its predicted value given that 1hp = x gold..

EDIT: i think the method is called factor analysis
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:http://ai-test.wesnoth.org
lotsofphil wrote:I meant Wesnoth AI can be your black box. It can tell you if a faction is balanced without you needing to know a formula.
Note that the AI is not used in actual balancing and we'll not spend any effort into making default balanced for it.
How do I use it?
lotsofphil wrote:
xbriannova wrote: I'm not gonna run 1000s of skirmishes. Maybe several everytime I change the units about.
The key to what I am suggesting would be to automate it :) I imagine the ai function calls would be quite fast without any gui/graphics/sound involved.
Sure, I'll try that.
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
Locked