Massive Assault Official Forum
   
It is currently Fri Apr 19, 2024 7:57 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: This is how balance is calculated
PostPosted: Tue May 10, 2005 11:26 am 
Offline
Tough Nut

Joined: Fri Mar 25, 2005 1:25 pm
Posts: 32
Karma: 0
I decided to figure out how balance is calculated from some examples. It took a few data samples to figure it out, but here is how it's done.

========================

First, let me quote Vano:

Full Control is calculated as the sum of all 'Secret Army' values in the following countries:

1 ) under your control
2) your undisclosed Secret Allies
3) with control in dispute (contributes half of its 'Secret Army' value)
=====================

Instead of the term "Full Control", I will use the term "Control Total".

The control total for player 1 shall be called CT1.

The control total for player 2 shall be called CT2.


Let us calculate the balance for the player who is ahead (or tied).

Let's say that player 1 is ahead or tied, that is CT1 >= CT2.


We first calculate the following value:


V = (CT1 - CT2)/CT2

Let VI = Int(V), that is the integer part of V.

For example, if V = 2.34, then VI = 2. Just drop everything after the decimal.

We perform a table lookup:

VI Value
---|--------
0 | 0
1 | 40
2 | 80
3 | 100


If V is an integer, for example if V = 2, then the balance is the value from the table.

If V is not an integer, then the balance is calculated by taking the percentage or ratio that V has "moved" towards the next index value, and moving the value from the table proportionately towards the next value.

The game uses some floating point calculations, and truncates. For example, there is a case in which the actual value should be 16%, but the game calculates 15.99999% and truncates it and reports 15%.

Here are some examples:

--------------------
CT1 = 24, CT2 = 8.

V = (CT1 - CT2)/CT2 = (24 - 8)/8 = 16/8 = 2.

We look in the table with VI = 2, and find 80. The balance is 80%.

--------------------
CT1 = 32, CT2 = 16.

V = (CT1 - CT2)/CT2 = (32 - 16)/16 = 16/16 = 1.

We look in the table with VI = 1, and find 40. The balance is 40%.

-------------------

CT1 = 24, CT2 = 16.

V = (CT1 - CT2)/CT2 = (24 - 16)/16 = 8/16 = 0.5.

Dropping the decimal, VI = 0.

Looking in the table, we find a value of 0.

We also look at the table value for an index of 1, which is 40.

Since V is halfway to 1, we take the value halfway from 0 to 40, which is 20.

The balance is 20%.

------------------------

CT1 = 28, CT2 = 12.

V = (CT1 - CT2)/CT2 = (28 - 12)/12 = 16/12 = 1.33333.

In this case, VI = 1.

The table entry for 1 is 40, and for 2 is 80.

So, we calculate 40 + .33333(80-40) = 40 + 13.333 = 53.333. The program reports a balance of 53%

----------------------


Top
 Profile  
 
 Post subject: Typo
PostPosted: Tue May 10, 2005 11:30 am 
Offline
Tough Nut

Joined: Fri Mar 25, 2005 1:25 pm
Posts: 32
Karma: 0
My previous post contains an obvious typo.

The line with the smiley face should read:

V = (CT1 - CT2)/CT2 = (24 - 8)/8 = 16/8 = 2.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 11:34 am 
Offline
Tough Nut

Joined: Fri Mar 25, 2005 1:25 pm
Posts: 32
Karma: 0
Ah, I had to disable smiles, lol.

The line should read:

V = (CT1 - CT2)/CT2 = (24 - 8)/8 = 16/8 = 2.


Part of the formula happened to be the meta sequence for a smile. :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 5:18 am 
Offline
Developer

Joined: Mon Dec 09, 2002 7:00 pm
Posts: 322
Karma: 0

Location: Wargaming.Net
the formulas are simple.
Here is the extract:

nMyCC = 0; // Control Total My
nEnemyCC = 0; // Control Total Enemy
for (int i = 1; i < MAX_COUNTRY_ID; i++)
{
XCountry * country = GetCountry((COUNTRY_ID)i);
if (country)
{
COLOR colCtrl = country->GetBorderColor(logic_map);
if (colCtrl == player_color) nMyCC += country->DisclosureValue;
else if ( colCtrl == opponent_color ) nEnemyCC += country->DisclosureValue;
else if (colCtrl == NEUTRAL)//country was invaded or disclosed!!!!!
{
nMyCC += country->DisclosureValue/ 2;
nEnemyCC += country->DisclosureValue/ 2;
}
if (country->isHiddenAlly(player_color)) nMyCC += country->DisclosureValue;
if (country->isHiddenAlly(opponent_color)) nEnemyCC += country->DisclosureValue;
}
}

colCtrl == NEUTRAL means that the country is contested right now. If country was never invaded nor disclosed colCtrl != NEUTRAL;

And 100% balance is reached when you's control Total 2.5 times greater than Enemy's. (in MAPR).

_________________
Do not invade 8 countries on your first turn :)


Top
 Profile  
 
 Post subject: Clarification and comments regarding Sky Keeper's post
PostPosted: Wed May 11, 2005 10:12 am 
Offline
Tough Nut

Joined: Fri Mar 25, 2005 1:25 pm
Posts: 32
Karma: 0
1) The code you displayed just calculates the "control totals" for each side (nMyCC and nEnemyCC , which I called CT1 and CT2 in my posts). The calculation of these values is very simple, and was never an issue. Still, it does not hurt to show the code.

2) You state: "And 100% balance is reached when you's control Total 2.5 times greater than Enemy's".

This English statement of a formula not completely clear, at least to me.

The algebraic statement (based on my earlier post) is: 100% balance is acheived if

(nMyCC - nEnemyCC)/nEnemyCC >= 2.5

This is probably what you meant.

I initially came up with the formula:

balance = 40 * ((CT1 - CT2)/CT2)

This formula worked for all the examples I tried in which balance was 80% or less.

It failed in the case of CT1 = 32, CT2 = 8, since the game reported a balance of 100% and the formula produced a balance of 120%.

A few minutes after submitting my post (I was VERY tired - well, actually suffering oxygen deprivation and other problems due to a medical condition), I thought "duh, I had the right formula, the game just caps balance at 100%". I wasn't able to submit an update at the time for health reasons, and figured "what the heck, the table still works, it's just much more cumbersome than necessary".

The formula above is correct except that balance is capped at 100.

The table is the equivalent of multiplying by 40, and truncating at 100. It seems absurd that I missed this (until a few minutes after posting), but try being borderline passing out from oxygen deprivation sometime, and you'll understand how it's possible.


From the formula:

balance = 40 * ((CT1 - CT2)/CT2)

it is easy to see that if

100 = 40 * ((CT1 - CT2)/CT2), then ((CT1 - CT2)/CT2) = 2.5


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Karma functions powered by Karma MOD © 2007, 2009 m157y