Skip to content

v5general/Absolute_Majority

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

100 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Absolute Majority

"You are not the Prime Minister. You are not a party leader. You are one rookie MP among 200 โ€” and politics is a game where the rules, the numbers, and the human heart collide."

License: GPL v3 NPCs: Political Human Skill


An AI-driven turn-based parliamentary political strategy game set in a fictional Japanese parliament of 2058. Every event, line of dialogue, and choice is generated live by an LLM, grounded by a deterministic rule engine that enforces parliamentary procedure. When no LLM is configured, the game falls back to rule-based text so it always runs.


English | ็ฎ€ไฝ“ไธญๆ–‡ | ๆ—ฅๆœฌ่ชž | ํ•œ๊ตญ์–ด


What is this ยท ๐ŸŽฎ Connection to Political Human Skill ยท Features ยท The World ยท Game Flow ยท Tech Stack ยท Getting Started ยท LLM Configuration ยท Project Structure ยท Status ยท License


What is this

Absolute Majority is a turn-based parliamentary political strategy game. You play as a newly elected member of the House of Representatives and navigate factional struggles, coalition politics, committee battles, media wars, and backroom deals across 48 turns (4 years).

The game runs on a two-layer architecture:

Rule Engine (always on)                   LLM Enhancement (optional)
- Deterministic parliamentary procedure    - Dynamic narrative generation
- Seat allocation & election math          - NPC dialogue & reasoning
- Intent validation & settlement           - Event & choice production
- 14 procedural intent types               - Context-aware adaptation

        โ†“ Both layers collaborate, neither is subservient โ†“
The rule engine is the sole authority for state mutation.
The LLM generates narrative, dialogue, and choices within those constraints.
When the LLM is absent, rule-based text fills every gap.

Every NPC in the game โ€” from the Prime Minister to faction leaders, media commentators, and interest groups โ€” perceives the world and generates intents through an agent engine. Those intents are validated by the rule engine before they can change any game state.


๐ŸŽฎ Connection to Political Human Skill

๐Ÿงฉ The NPCs in this game are powered by Political Human Skill โ€” an open-source framework for creating political-figure personas with a dual-layer structure (Human Layer + Political Layer).

Absolute Majority needs more than MPs who vote by the numbers. It needs NPCs who exist like real political people: with age, background, and formative experience; with personality, weaknesses, and hobbies; with stances, support bases, and faction relationships; who shift their trust and wariness based on the player's past actions; who speak differently in public, private, crisis, and intimate settings; who take different strategies under constituency pressure, faction orders, personal ambition, and political grudges โ€” and whose memories are isolated from one another.

Political Human Skill provides exactly this. When integrated, the skill:

  • Judges among candidate actions provided by the game rules and selects one
  • Outputs structured, debuggable, explainable NPC behavior JSON
  • Maintains persona continuity across turns with isolated memory and relationship state
  • Switches self-states (public / private / strategic / wounded / intimate) based on context
{
  "selected_action": "negotiate_budget",
  "action_scores": { "support_bill": 58, "negotiate_budget": 86, "join_rebellion": 27 },
  "public_statement": "I understand the policy direction, but local economies need more carefully designed institutional safeguards.",
  "private_reason": "My support base depends on local public spending. Direct support would damage constituency relations.",
  "relationship_delta": { "trust": 1, "respect": 2, "caution": 1 },
  "memory_write": ["The player asked this NPC to support the fiscal reform bill without offering local budget compensation."]
}

Absolute Majority is the primary application scenario for Political Human Skill, but the skill itself stands as an independent, reusable, extensible framework. Both projects are developed in tandem and share the same safety commitments โ€” no real modern political figures, ever.


Features

  • AI-driven narrative โ€” Events, dialogues, and choices are produced by an LLM in real time, adapting to the current political situation, the congressional season, and your character's background.
  • Full parliamentary simulation โ€” A 200-seat House of Representatives (110 direct + 90 proportional D'Hondt, parallel system), 9 standing committees, no-confidence motions, bill decision chains, and tiered vote thresholds (simple / absolute / supermajority).
  • Faction system โ€” Internal party factions with loyalty, ambition, and the ability to challenge the party leader. One party (ULP) runs on democratic centralism and forbids factions.
  • Seasonal congressional calendar โ€” The year is split into four sessions that change what is possible: a budget battle (Janโ€“Mar), a legislative push (Aprโ€“Jun), a constituency recess (Julโ€“Sep), and an extraordinary session (Octโ€“Dec).
  • Dual career tracks โ€” Climb the party ladder and the parliamentary ladder independently; becoming a minister โ‰  becoming party leader.
  • Government formation โ€” Post-election coalition negotiations, cabinet allocation, and prime-minister designation.
  • 14 procedural intents โ€” Full intent pipeline with validate + settle: no-confidence proposals, dissolution decisions, bill drafting/voting, committee review/voting, coalition negotiation, cabinet reshuffle, leadership challenge, and policy announcements.
  • Galgame-style dialog โ€” Political events unfold as visual-novel-style conversations with choices and consequences, rendered fullscreen with adaptive layouts on phone and desktop.
  • Character creation โ€” Define your name, age, gender, party, personality traits, ideology, and background; your background shapes the events you encounter.
  • Mobile-responsive โ€” Layout, typography, image format (WebP on mobile, PNG on desktop), and even LLM call concurrency adapt to the screen size. Refresh-safe URL routing keeps you on the same screen (Main Hall vs Situation) across reloads.

The World

Setting: Fictional Japan, 2058. Parliamentary cabinet system. The House of Representatives is the only playable chamber.

Term: 4 years = 48 turns. 1 turn = 1 month. The game starts in January of the budget-battle session.

Six original parties (no real-world parties or politicians):

Party Abbr. Ideology Base seats
Reform Democratic Party RDP Center 54
Liberty Party LP Right 40
National Conservative Party NCP Center-right 38
Social Alliance SA Center-left 29
First Citizens Front FCF Far-right 24
United Labor Party ULP Left 14

The 199 NPC seats are distributed via a deterministic parallel election system. You are the 200th seat โ€” a proportional-representation seat that adds +1 to whichever party you join.


Game Flow

  1. Main menu โ€” Start a new game or continue a saved one.
  2. Character creation โ€” Define your politician.
  3. Main Hall โ€” Your home base: advance turns, open popovers for party overview and your profile, and enter the Situation.
  4. Situation โ€” Four dashboards (Cabinet / Committees / Political landscape / Relations) plus a live AI reasoning log. Reachable via #/game/situation so the view survives refresh.

Tech Stack

  • React 18 + TypeScript
  • Vite 6 (build tooling)
  • No runtime dependencies beyond React โ€” all game logic is hand-written.

Getting Started

# install dependencies
npm install

# start the dev server
npm run dev

# build for production
npm run build

# preview the production build
npm run preview

Then open the URL Vite prints (default http://localhost:5173).


LLM Configuration

The game uses a two-layer architecture:

  • Rule fallback (always on) โ€” Pure local logic keeps the game playable without any API.
  • LLM enhancement (optional) โ€” Connect any OpenAI-compatible API (DeepSeek, OpenAI, Kimi, Qwen, GLM, SiliconFlow, etc.) for richer, more dynamic narrative and reasoning.

Configure the LLM in-game via the settings panel: provide a Base URL, an API Key, and a Model name. The configuration is stored locally in your browser.

Calls stream the response back via SSE so long generations stay alive on flaky mobile networks, and the engine automatically serializes agent calls on phones to respect stricter concurrent-connection limits. If your provider does not support streaming, the bridge transparently falls back to a single JSON response.


Project Structure

src/
โ”œโ”€โ”€ App.tsx                # Routing, header, nav tabs, turn flow
โ”œโ”€โ”€ App.css                # Situation view styles + responsive breakpoints
โ”œโ”€โ”€ components/            # UI: MainMenu, CharacterCreation, GalgameDialog, dashboards, popups
โ”œโ”€โ”€ engine/                # Game logic: agent, narrative, rules, election, committee, faction, llmBridge...
โ”œโ”€โ”€ config/                # Rule constants, election/district/background config
โ”œโ”€โ”€ data/                  # Initial state, parties, events, market, media, world config
โ”œโ”€โ”€ hooks/                 # useGameState (central state management)
โ””โ”€โ”€ types/                 # TypeScript type definitions

Key engines:

  • agentEngine โ€” AI agents (the PM, party leaders, faction leaders, media, interest groups) perceive the world and generate intents.
  • narrativeEngine โ€” Converts intents into playable events (title, dialog, choices, effects).
  • rulesEngine โ€” The sole authority for modifying seats, support, funds, and relations; validates and settles all 14 procedural AI intents.
  • electionEngine โ€” Deterministic parallel election: 110 direct seats (per-block D'Hondt across 11 districts) + 90 proportional seats (national D'Hondt with 5% threshold).
  • llmBridge โ€” OpenAI-compatible client with mobile-aware streaming, timeout, retry, and a debugLLMConfig() console helper.

Status

Personal project, actively iterated with 419 deterministic unit tests across 11 test files. Built for fun and as an experiment in LLM-grounded political simulation.


License

This project is licensed under the GNU General Public License v3.0.


48 turns. 200 seats. Your move.

About

A parliamentary political sim with 199 AI NPCs featuring personalities, CK3-style traits, life/death cycles, and multi-party politics. Built with React + TypeScript.

Topics

Resources

License

Stars

3 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages