A House Divided A House DividedDocumentation
↵
Changelog
Game Design/Economy & Finance

Formula Deep-Dive

Last updated 2026-10-29
Source files

Summary#

This reference documents the key formulas and calculations that drive election, influence, turnout, fund and action mechanics. Every constant is listed with its value and the source file it lives in, so the page can be checked against the code.

Player guide: Reference: Formulas

The formulas split into seven groups, each a subsection of Rules: the general-election vote (turn pool, candidate weight, bonuses, floors), political influence, presidential and state primary scoring, demographic turnout, fund generation, the action economy, and state lean. Each group has at least one worked example inline, and the Worked trace section carries one case through the whole vote path to a stored tally.

Rules#

Election Vote Calculation#

Vote Turn Pool#

Each turn, votes are allocated to candidates based on:

effectiveTurnPool = turnPool × approvalVoteMultiplier × officeStrength
approvalVoteMultiplier = 1 + (stateApproval - 0.5) × slope
slope = LEGISLATIVE_APPROVAL_VOTE_SLOPE = 0.2   (every race except the presidency)
slope = PRESIDENTIAL_APPROVAL_VOTE_SLOPE = 0.5  (presidential general)

turnPool is the share of the race's total vote pool cast this turn (turnVoteWeight, src/lib/electionEngine/voteCalculations.ts). The general-election window is split into three bands: the early band casts EARLY_POOL_SHARE = 0.5 of the pool, the ramp band (up to RAMP_TURNS = 8 turns) casts RAMP_POOL_SHARE = 0.2, and the final ELECTION_DAY_TURNS = 4 turns cast FINAL_POOL_SHARE = 0.3. Races of 4 turns or fewer spread the pool evenly. If there is no early band, its share folds into the ramp so the shares still sum to 1. The window starts at the end of the primary, not at the race start, so primary turns do not dilute the early band.

Approval is a small modifier, not a direct multiplier: 50% approval gives 1.0x. In every race except the presidency each 10 points of approval above or below 50 shifts the pool by about 2% (tallyManagement.ts); the presidential general uses the steeper slope, about 5% per 10 points, up to 25% at the extremes (src/lib/presidentialElectionEngine.ts). Both slopes live in src/lib/electionEngine/approvalVoteMultiplier.ts. officeStrength comes from partyStrengthWeight in the country's office-type config (field defined in , looked up with a 0.9 default when unset; US values in ). US values:

Why: the pool is scaled by how the state judges the party in power, but only by a few percent, so approval can tilt a close race without deciding it alone.

Worked example. A House race has a 20 turn general window and a total pool of 1,000,000 votes. The early band has 8 turns (20 - 4 - 8), so each early turn casts 0.5 x 1,000,000 / 8 = 62,500. Each ramp turn casts 0.2 x 1,000,000 / 8 = 25,000. Each of the final 4 turns casts 0.3 x 1,000,000 / 4 = 75,000. With state approval at 60%, strength is (1 + (0.6 - 0.5) x 0.2) x 0.9 = 0.918, so a final-turn pool is 75,000 x 0.918 = 68,850 votes, split among candidates by weight.

Candidate Vote Share#

Votes are allocated per demographic group, not with a single state-wide formula. For each group, every candidate gets a weight:

weight = appeal × reach × approval × org × regResistance × regBaseline × supportMood
         × nppPenalty × infamyMult × pgfMult × regimeMult × partyFit
         × stateOrgMult × homeStateMult × partyInfluenceMult

(distributeVotesByGroupLevelAllocation in src/lib/electionEngine/voteDistribution.ts). The candidate's share of that group's vote pool is weight / totalWeight across candidates in the group. There is no separate "state lean" multiplier: lean is baked into appeal, computed per group from the group's own economic/social lean versus the candidate's position (calcAppeal in ). Several of the other factors (org, regResistance, regBaseline, supportMood, state-org bonus, home-state bonus, party-influence bonus) only apply when relevant (general election, presidential primary, etc.); they default to 1.0x (no-op) otherwise.

Factors a player can move: appeal (change position or build influence), reach (political influence), approval (favorability), org (party organisation), and infamy. The rest are structural.

Other terms in the stack, in plain words: regResistance is own-registration making voters harder to peel away, 1.0x to 1.3x (REG_RESISTANCE_MAX_BONUS = 0.3); regBaseline prices a party's current registration where a world authors partisan baselines; supportMood is the candidate's Support, 0.6x to 1.4x and neutral 1.0x at Support 50 (SUPPORT_MOOD_FLOOR, SUPPORT_MOOD_CEILING); nppPenalty is the NPP multiplier, pgfMult is the party-group favorability boost from addresses, regimeMult is the regime multiplier, and partyFit is the candidate's fit with the party platform.

State Org and Home State Bonuses#

Not part of the vote-share formula above but stack into it as stateOrgMult / homeStateMult (src/lib/electionEngine/constants.ts):

Both bonuses multiply the weight as 1 + bonus. Worked example. At org level 10 in a general election the org bonus is 0.15 x 0.75 = 0.1125, and at home the candidate adds 0.05, so the weight is multiplied by 1.1125 x 1.05 = 1.168. In a primary at level 10 it is 1.1875 x 1.2 = 1.425.

Minimum Vote Floor#

There is no 50%-of-base-vote floor. The actual floors are on the individual factors that feed the weight: VOTE_REACH_FLOOR clamps reach to at least ~0.1x, and APPEAL_POSITION_FLOOR (0.5, about 2% of max appeal) keeps position score above zero per axis. Together these keep even a badly-misaligned, low-influence candidate from hitting a literal zero weight in a group, but they do not guarantee any fixed share of the base vote pool.

Political Influence#

Decay#

decay = clamp(influence, 0, 100) × POLITICAL_INFLUENCE_DECAY_RATE × multiplier
POLITICAL_INFLUENCE_DECAY_RATE = 0.0075  (0.75% per turn)

Source: shared/constants/formulas.ts (calculatePoliticalInfluenceDecay, applyPoliticalInfluenceDecay). multiplier is 1 for most characters. Members of the party holding the national executive use executivePartyInfluenceDecayMultiplier(approval) = 2 - approval / 100: 2.0x at 0% approval, 1.5x at 50%, 1.0x at 100%. The multiplier is stored on the character as politicalInfluenceDecayMultiplier by the action refresh ().

Why: holding power costs home-state standing, and a government that is popular pays less of it.

Worked example. Influence 40 loses 40 x 0.0075 = 0.30 per turn, so 39.70 next turn. A member of the governing party at 50% approval loses 0.30 x 1.5 = 0.45.

Floors#

National influence#

Decay is NATIONAL_INFLUENCE_DECAY_RATE = 0.01 of current national influence per turn. Passive gain from state influence (calculateNationalInfluenceGain) is si / 50 - 0.5 for state influence si up to 50, and 0.5 + (si - 50) x 0.03 above 50 (so -0.5 at 0, 0 at 25, +0.5 at 50, +1.25 at 75, +2.0 at 100). Each turn applies decay first, then the gain, floored at 0 (applyNationalInfluenceTurn). Every role settles where gain equals decay, at 100 x gain.

Presidential Election Scoring#

Primary Score#

score = alignmentScore(0-40) + partyInfluenceScore(0-20) + nationalReachScore(0-15) + favorabilityScore(0-25)

Weights are PRESIDENT_PRIMARY_ALIGNMENT_WEIGHT = 40, PRESIDENT_PRIMARY_PARTY_INFLUENCE_WEIGHT = 20, PRESIDENT_PRIMARY_NATIONAL_REACH_WEIGHT = 15, PRESIDENT_PRIMARY_FAVORABILITY_WEIGHT = 25 (, rebalanced 2026-08-19). Party influence, not "party org," is the second term; it scales linearly and is uncapped above the reference scale (party influence 150). Favorability was raised from 10 to 25 because it is the single most decisive variable in the general election (approvalScalar measured at ~0.45 vote-share points per favorability point) while party influence never enters the general-vote formula at all, the old weighting let parties nominate candidates the electorate had already rejected.

The component curves are in :

State-level primary score#

Used for House, Senate, Governor and State Senate style races (calcPrimaryScore, ):

score = (stateAlignment(0-25) + partyAlignment(0-15) + favorability(0-35) + influence(0-25)) × infamyMult
stateAlignment = max(0, 25 - (|econDiff_state| + |socialDiff_state|) × 1.25)
partyAlignment = max(0, 15 - (|econDiff_party| + |socialDiff_party|) × 0.75)
favorability   = favorability / 100 × 35
influence      = normalizeNPI(politicalInfluence) × 25   // sqrt(PI / 100), PI clamped to 0-100

With no cached state lean the alignment collapses to a single party-only term, max(0, 40 - (|econDiff_party| + |socialDiff_party|) × 2.0). NPP candidates in a primary that has at least one player in the same party take NPP_PRIMARY_SCORE_MULTIPLIER = 0.5 (src/lib/electionEngine/constants.ts), and are not subject to the infamy penalty. The score sets a candidate's standing; it is not a direct vote count.

Worked example. State distance 4, party distance 2, favorability 60, influence 36, infamy 40: state alignment 25 - 5 = 20; party alignment 15 - 1.5 = 13.5; favorability 21; influence sqrt(0.36) x 25 = 15. Raw 69.5. Infamy multiplier 1 - 0.05 x 0.4 = 0.98, so the score is 68.1.

Why the presidential weights differ: the presidential primary is national, so no state lean is involved, and favorability gets the larger weight because it is the most decisive variable in the general election.

Electoral College#

Independent Penalty#

Independent presidential candidates receive a 0.3x vote multiplier (src/lib/presidentialElectionEngine.ts).

Demographic Turnout#

Turnout Modifier Range#

Each demographic group: -20 to +20 percentage points (TURNOUT_CAP = 20, ; the legacy path clamps at the same 20 in ).

Decay#

modifier = modifier × 2^(-1/6)   (TURNOUT_HALF_LIFE = 6 turns, about 10.9% per turn)

Values with magnitude under 0.01 snap to 0. This is the rule for races created under campaign rules version 1 (CAMPAIGN_RULES_VERSION = 1). Legacy races use modifier × 0.98 (DECAY_RATE = 0.02, ).

Turns since canvassing Remaining (v1 races) Remaining (legacy)
0 100% 100%
4 63% 92%
10 31% 82%
20 10% 67%

Canvassing Effectiveness (campaign rules version 1)#

distanceSquared = ((charEcon - demoEcon)² + (charSocial - demoSocial)²) / 2
fit             = 0.2 + 0.8 × exp(-distanceSquared / 18)
boost           = CANVASS_BASE_BOOST × fit² × (closing ? 2 : 1)       // CANVASS_BASE_BOOST = 2 points
resistance      = max(0, sign(boost) × current) / 20
new             = clamp(current + boost × (1 - resistance), -20, +20)

Source: canvassingBoost and addTurnoutBoost in . The closing sprint is the final 4 turns of the race, which doubles the boost. Resistance is directional: pushing further the way a bucket is already pushed gets harder, while a positive action can recover a suppressed bucket.

Worked example. A candidate at distance squared 0 from a group has fit 1.0, so a canvass adds 2 points (4 in the closing sprint). At distance squared 9 the fit is 0.2 + 0.8 x exp(-0.5) = 0.685, so the boost is 2 x 0.685² = 0.94. With the modifier already at +10 the resistance is 0.5 and the boost halves to 0.47.

Legacy races ():

distance      = |charEcon - demoEcon| + |charSocial - demoSocial|
alignmentMult = max(0.1, 1.0 - distance × 0.15)
rawBoost      = 0.05 × alignmentMult × (campaign season ? 2.0 : 1.0)
boost         = applyDiminishingReturns(current, rawBoost)   // × (1 - |current| / 20), floored at 0

The alignment multiplier floor of 0.1 is reached at distance 6.

Party GOTV#

Party budgets have a GOTV allocation targeted at a specific category or group (gotvTargetCategory / gotvTargetGroup), which feeds turnout for the tally (processPartyGOTV, ).

spend = floor(revenue × gotvBudgetPercent / 100)        // percent 0-25; legacy flat gotvBudgetPerTurn if percent is 0
boost = spend / DOLLARS_PER_TURNOUT_POINT × alignmentMultiplier
DOLLARS_PER_TURNOUT_POINT = 5000   (src/lib/utils/demographicAlignment.ts)

A national budget divides the spend evenly across the country's regions before applying the formula; a state-scoped budget applies in full to one state. The alignment multiplier runs from 1.0 at perfect alignment with the target bucket down to a 0.1 floor. Diminishing returns apply on top (applyDiminishingReturns: the boost is multiplied by 1 - |current| / 20), so at a +10 modifier a 1 point boost becomes 0.5. No rule boosts demographics automatically for being near the party position; only the budget allocation above does that.

Worked example. A party with 200,000 revenue an hour and a 5% GOTV budget spends 10,000, which is 2 points at alignment 1.0, or 0.8 points at alignment 0.4. At a current modifier of +10 the 0.8 becomes 0.4.

Fund Generation#

Passive Income#

income = round((baseRate + donorBonus) × gdpScalar × priceLevel) + round(officeBonus × priceLevel)

Source: getTotalFundGeneration, . Rates are per hour (one turn).

State population baseRate Donor bonus per level
under 2,000,000 (small) $5,000 $100
2,000,000 to 7,999,999 (medium) $10,000 $200
8,000,000 to 19,999,999 (large) $20,000 $400
20,000,000 and over (mega) $40,000 $800

Worked example. A medium state, donor level 10, state influence 50, GDP scalar 1.0, price level 1: donor bonus is 200 x 10 x 1.5 = 3,000; base plus donor is 13,000; a House member adds $5,000 for $18,000 per hour.

Office Fund Bonuses#

Flat per hour, not scaled by GDP (OFFICE_FUND_BONUS, ):

Office Bonus
House, Commons, Bundestag, parliamentary and UK cabinet +$5,000/hr
State Senate, Landtag +$3,000/hr
Senate, Governor, Minister-President +$15,000/hr
Vice President +$25,000/hr
President, Prime Minister, Chancellor +$50,000/hr

Action Economy#

Base Actions#

baseActionsPerTurn = 4, plus the per-turn office bonus from officeActionBonus (, used by ):

Office Bonus
House, State Senate, Commons, Regional Council, Bundestag, Landtag, Sangiin, Shugiin, cabinet seats +1
Senate, Governor, Vice President, Bundesrat, Minister-President, Premier +2
President, Prime Minister, Chancellor +4

A cabinet bonus stacks on top of the holder's legislative seat. The central bank chair adds chairActionBonus = 3. These are game-config values, so a world may override them.

Action Costs#

Action costs vary by action and target. For example, setting a travel or primary campaign state costs 3, 5, 7 or 10 actions depending on the state's electoral votes (getTravelActionCost in ). Advertise, fundraise and influence actions have their own costs.

State Adjacency Costs#

These multipliers apply to the action cost of Support and Attack only. Campaign, Advertise and Barnstorm have no distance multiplier.

State Lean Calculation#

stateLean = weightedAverage(groupLeans, groupPopulations × groupTurnout)

Lean is stored on an integer -5 to +5 scale per axis (economic, social), not a -1..1 float. Display labels (getEconomicPositionName / getSocialPositionName, ) use 11 discrete buckets, one per integer value:

Economic axis: Far Left (-5), Strong Left (-4), Left (-3), Lean Left (-2), Center-Left (-1), Centrist (0), Center-Right (1), Lean Right (2), Right (3), Strong Right (4), Far Right (5).

Social axis: Far Liberal (-5), Strong Liberal (-4), Liberal (-3), Lean Liberal (-2), Center-Liberal (-1), Moderate (0), Center-Trad (1), Lean Trad (2), Traditional (3), Strong Trad (4), Far Traditional (5).

Data#

The formulas read from and write to these collections. Intermediate weights are recomputed every turn from the inputs below; the stored result of the election path is the cumulative tally.

Collection Fields read Fields written Where it comes from
characters favorability, infamy, politicalInfluence, donorBaseLevel, currentOffice, homeState, party, stats politicalInfluence, politicalInfluenceDecayMultiplier, funds or currencyBalances.campaign (income), the action pool actionRefresh.ts, turn/fundGeneration.ts
states population, gdp, state lean none by these formulas Seeds and metric turns
stateDemographics, demographicDefaults, demographicCategories group shares, leans, per-archetype approvals none by these formulas (the granular layer writes them, see granular electorate) Seeds, legislation effects
stateDemographicTurnout per-group turnout modifiers modifiers (canvass boost, decay, party GOTV) campaignTargeting/rules.ts, demographicTurnoutTurn.ts
statePartyOrg org, registration, registrationShare, stateTaxRate treasury (tax credits) Party systems
politicalParties nationalTaxRate treasury Party systems
elections, electionCandidates window, race type, campaignRulesVersion, candidate stats none Election setup
electionVoteTallies running tally per-candidate votes added each turn tallyManagement.ts
governmentApprovals, stateApprovalHistory stored approval (coattails, history) none here, see government approval Approval snapshot

Player-visible results: election tallies (as results and polls), each character's own stats, funds and actions, party treasuries, and state approval. Raw modifiers and weights are not shown directly.

Configuration#

Setting Default Where set Effect
gameConfig.baseActionsPerTurn 4 Base actions per turn
gameConfig.officeActionBonus per office (House 1, Senate 2, President 4) Per-turn office action bonus
gameConfig.chairActionBonus 3 Central bank chair bonus
gameConfig.campaignEraPriceLevelEnabled true on fresh worlds Scales fund generation by the era price level; off means 1
gameState.preset, gameState.startingYear, gameState.currentYear world-specific World reset Era tables for electoral votes, GDP baseline, price level
Election.campaignRulesVersion 1 for new races, absent (0) for legacy Stamped at election creation () Canvass and decay rule set (see Demographic Turnout)
partyStrengthWeight 0.9 if unset Office-type config per country () Office strength in the vote pool
Party tax rates 0 to 33 Party and state party settings Share of fund generation taxed

Every constant named in Rules (for example ORG_WEIGHT_EXPONENT, TURNOUT_HALF_LIFE) is a source constant, not a runtime setting; changing it needs a code change.

Timing#

The formulas run in different parts of the hourly turn (1 turn = 1 game week). The order is set in the turn processor (src/lib/turn/).

Formula group Turn group Notes
Action refresh, fund generation, influence decay Resources (group 1) First, so later phases read the new action pool and treasury.
Turnout decay, party GOTV Demographics (group 2)
Primary resolution, vote accumulation, general resolution Election resolution (group 7) Strictly sequential: primary resolution, then vote accumulation, then general resolution

Vote accumulation (src/lib/electionEngine/tallyManagement.ts) runs once per active race per turn, after turnout decay has already moved the modifiers it reads.

Order of operations across one turn, with the source of each step:

group 1  Resources              action refresh (influence decay), fund generation
group 2  Demographics           turnout decay, party GOTV
group 7  Election resolution    primary resolution -> vote accumulation -> campaign spend reset
...
state effects stage             demographic effects, era checkpoints, approval snapshot

The state effects stage runs after election resolution in the same turn, so vote accumulation reads approval and demographic overlays as left by the previous turn's stage (approval is also recomputed live from current metrics, see government approval).

Worked trace#

One House general election, final-band turn, one demographic group, two candidates. Pool and approval come from the pool worked example above (20-turn window, total pool 1,000,000, state approval 60%, House strength 0.9).

Step 1, pool. Final turn casts 0.3 x 1,000,000 / 4 = 75,000. Multiplier (1 + (0.6 - 0.5) x 0.2) x 0.9 = 0.918. Effective pool 68,850. Assume this group is 10% of the turnout-weighted pool: 6,885 votes.

Step 2, appeal. Group sits at economic 0, social 0, so the direction bonus is 0 for both.

Candidate A Candidate B
Position (econ, social) (1, 1) (-2, 1)
positionRaw = 50 - 5 x 1 - 5 x 1, and 50 - 10 - 5 40 35
positionScore = 25 x (raw / 50)^1.5 + 0.5 25 x 0.7155 + 0.5 = 18.39 25 x 0.5857 + 0.5 = 15.14

Step 3, other terms.

A B
Influence 49 and 16, reach = sqrt(PI / 100) 0.70 0.40
Favorability 64 and 50, group approval 0, approval = (fav / 100)^0.8 0.6998 0.5743
Party org 60 and 20 of 80, (share)^0.2 0.75^0.2 = 0.9441 0.25^0.2 = 0.7579
Personal org floor 0.1 x reach x approval 0.049, below party org 0.023, below party org
Infamy 40 and 0, 1 - 0.05 x infamy / 100 0.98 1.00
Other factors 1.0 1.0

Step 4, weight. A = 18.39 x 0.70 x 0.6998 x 0.9441 x 0.98 = 8.33. B = 15.14 x 0.40 x 0.5743 x 0.7579 = 2.64.

Step 5, share and votes. A share 8.33 / 10.97 = 75.97%, B 24.03%. Of the 6,885 votes, A gets about 5,230 and B about 1,655. These are added to the candidates' running totals in electionVoteTallies. Rounding of individual group slices happens in the engine, so a real tally can differ by a vote or two.

Edge cases and limits#

Invariants#

Invariant Enforced by
The three pool bands sum to 1, so per-turn weights integrate to the total pool (an empty early band folds into the ramp) (conserves the pool over the General phase) and the fold-forward branch in turnVoteWeight
Candidate shares in a group sum to about 100% src/lib/electionEngine/voteDistribution.test.ts (shares sum)
Normalised org shares sum to 1 across parties present src/lib/electionEngine/electionFormulaFactors.test.ts
Reach never falls below VOTE_REACH_FLOOR, so no weight is zero from influence alone applyVoteReachFloor in electionFormulaFactors.ts; covered by electionFormulaFactors.test.ts
Turnout modifiers stay within +/-20 points Clamp in canvassingBoost and addTurnoutBoost;
Influence stays within 0 to 100 (NPP floor 10) shared/constants/formulas.ts; shared/constants/formulas.test.ts
Money is conserved in party tax: character receives gross minus both taxes Arithmetic in ; . No runtime reconciliation specific to this step
Presidential and legislative approval slopes stay at 0.5 and 0.2 Constants only; not enforced by a dedicated test

Failure and recovery#

Connections#

Driven by:

Affects:

Tests#

Area Test files
Pool bands and timing , src/lib/electionEngine/voteCalculations.test.ts
Weight factors (org, reach, tenure, support) src/lib/electionEngine/electionFormulaFactors.test.ts, src/lib/electionEngine/rules/tenureRetention.test.ts
Appeal and normalisation , ,
Group vote distribution src/lib/electionEngine/voteDistribution.test.ts, src/lib/electionEngine/voteDistributionSwingFlow.test.ts
Vote accumulation src/lib/electionEngine/tallyManagement.test.ts
Primary score
Presidential engine src/lib/presidentialElectionEngine.test.ts
Influence decay shared/constants/formulas.test.ts
Turnout and canvassing , ,
Fund generation , ,
Action bonus ,

Gaps: no direct unit test of approvalVoteMultiplier, and no test pins the presidential 0.5 slope. The Electoral College tie path is covered by the contingent election tests, not by a formula test.

Known issues and history#

Last checked: 2026-10-29, version 1.18.0

Ask