Skip to content

Some little HumansVsNations improvements before public games launch 🤖 - #2825

Merged
evanpelle merged 4 commits into
openfrontio:mainfrom
FloPinguin:flopinguin-nation-improvement
Jan 9, 2026
Merged

evanpelle merged 4 commits into
openfrontio:mainfrom
FloPinguin:flopinguin-nation-improvement

Conversation

@FloPinguin

Copy link
Copy Markdown
Contributor

Description:

  • Added generateUniqueNationName() to NationCreation because I saw a duplicate name while spawning 300 nations on Pangaea 😄
  • Switched HumansVsNations public game difficulty from hard to impossible because I realized how crazy strong troop donations between humans are (in an enzo HVN stream).

Maybe I have to make nations donate troops to each other, we will see... Playtests won't tell the truth because the players attending these are probably better than the usual OF player. I will try to check the HVN winrate via API after launch

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

Please put your Discord username so you can be contacted if a bug or regression is found:

FloPinguin

@FloPinguin
FloPinguin requested a review from a team as a code owner January 8, 2026 19:45
@coderabbitai

coderabbitai Bot commented Jan 8, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

The PR refactors nation name generation to prevent duplicate names using a tracking set and introduces helper functions. It also adjusts the difficulty mapping for HumansVsNations team mode from Hard to Impossible in map configurations.

Changes

Cohort / File(s) Summary
Nation Name Generation
src/core/game/NationCreation.ts
Adds uniqueness tracking for nation names via a Set. Introduces generateUniqueNationName() helper that attempts up to 1000 retries to generate non-duplicate names, with numeric suffix fallback. Extracts generateNationName() as a separate helper for cleaner name construction using templates and nouns.
Difficulty Configuration
src/server/MapPlaylist.ts
Changes HumansVsNations team mode difficulty mapping from Difficulty.Hard to Difficulty.Impossible in the gameConfig() method.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

Gameplay, Feature

Suggested reviewers

  • evanpelle

Poem

🌍 Nations rise with names so bright,
No twins compete for glory's fight!
From Hard to Impossible we climb,
Each difficulty set sublime!
Unique names seal the deed—design refined! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title partially relates to the changeset by mentioning HumansVsNations improvements, but it is vague and uses casual emoji without specifying the concrete changes (uniqueness mechanism for nation names and difficulty adjustment). Provide a more specific title that clearly describes the main changes, such as 'Add unique nation name generation and increase HumansVsNations difficulty to Impossible'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description directly relates to the changeset, clearly explaining both main changes: adding the unique nation name generation function to avoid duplicates and switching HumansVsNations difficulty from Hard to Impossible.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9512e48 and 5cecfd6.

📒 Files selected for processing (2)
  • src/core/game/NationCreation.ts
  • src/server/MapPlaylist.ts
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: Saphereye
Repo: openfrontio/OpenFrontIO PR: 2233
File: src/client/HostLobbyModal.ts:891-891
Timestamp: 2025-10-21T20:06:04.823Z
Learning: For the HumansVsNations game mode in `src/client/HostLobbyModal.ts` and related files, the implementation strategy is to generate all nations and adjust their strength for balancing, rather than limiting lobby size based on the number of available nations on the map.
Learnt from: FloPinguin
Repo: openfrontio/OpenFrontIO PR: 2689
File: src/client/PublicLobby.ts:245-245
Timestamp: 2025-12-26T22:21:21.904Z
Learning: In public lobbies with HumansVsNations mode in src/client/PublicLobby.ts, maxPlayers represents only human player slots (already halved in DefaultConfig.ts). The nation NPCs are added automatically server-side and don't count toward maxPlayers. Therefore, getTeamSize correctly returns maxPlayers directly for HumansVsNations to display the proper team size (e.g., maxPlayers=5 yields "5 Humans vs 5 Nations").
📚 Learning: 2025-10-21T20:06:04.823Z
Learnt from: Saphereye
Repo: openfrontio/OpenFrontIO PR: 2233
File: src/client/HostLobbyModal.ts:891-891
Timestamp: 2025-10-21T20:06:04.823Z
Learning: For the HumansVsNations game mode in `src/client/HostLobbyModal.ts` and related files, the implementation strategy is to generate all nations and adjust their strength for balancing, rather than limiting lobby size based on the number of available nations on the map.

Applied to files:

  • src/server/MapPlaylist.ts
  • src/core/game/NationCreation.ts
📚 Learning: 2025-10-20T20:15:28.858Z
Learnt from: sambokai
Repo: openfrontio/OpenFrontIO PR: 2225
File: src/core/execution/FakeHumanExecution.ts:51-51
Timestamp: 2025-10-20T20:15:28.858Z
Learning: In src/core/execution/FakeHumanExecution.ts, game balance constants like MIRV_COOLDOWN_TICKS, MIRV_HESITATION_ODDS, VICTORY_DENIAL_TEAM_THRESHOLD, VICTORY_DENIAL_INDIVIDUAL_THRESHOLD, and STEAMROLL_CITY_GAP_MULTIPLIER are experimental tuning parameters subject to frequent change during balance testing. Do not flag changes to these values as issues or compare them against previous values.

Applied to files:

  • src/server/MapPlaylist.ts
📚 Learning: 2025-12-26T22:21:21.904Z
Learnt from: FloPinguin
Repo: openfrontio/OpenFrontIO PR: 2689
File: src/client/PublicLobby.ts:245-245
Timestamp: 2025-12-26T22:21:21.904Z
Learning: In public lobbies with HumansVsNations mode in src/client/PublicLobby.ts, maxPlayers represents only human player slots (already halved in DefaultConfig.ts). The nation NPCs are added automatically server-side and don't count toward maxPlayers. Therefore, getTeamSize correctly returns maxPlayers directly for HumansVsNations to display the proper team size (e.g., maxPlayers=5 yields "5 Humans vs 5 Nations").

Applied to files:

  • src/server/MapPlaylist.ts
🧬 Code graph analysis (2)
src/server/MapPlaylist.ts (2)
src/core/configuration/DefaultConfig.ts (1)
  • playerTeams (318-320)
src/core/game/Game.ts (1)
  • HumansVsNations (56-56)
src/core/game/NationCreation.ts (1)
src/core/PseudoRandom.ts (1)
  • PseudoRandom (3-76)
🔇 Additional comments (4)
src/server/MapPlaylist.ts (1)

124-126: LGTM! Difficulty adjustment is appropriate.

The change from Hard to Impossible for HumansVsNations mode addresses the balance issue from troop donations between human players mentioned in the PR objectives. The ternary logic is clean and correct.

src/core/game/NationCreation.ts (3)

72-76: LGTM! Clean uniqueness tracking.

The usedNames Set correctly prevents duplicate nation names by initializing from existing manifest nations and updating after each generation. The pattern is clear and straightforward.


102-120: LGTM! Robust uniqueness guarantee.

The retry mechanism with 1000 attempts handles the common case efficiently, and the fallback with counter ensures uniqueness even in extreme scenarios. The approach is solid for the reported issue (300 nations on Pangaea).


122-139: LGTM! Clear template-based generation.

The name generation logic is straightforward: randomly select a template and noun, then replace symbols with noun forms. The code is clean, uses proper Symbol comparison, and properly delegates to the existing pluralize helper.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@FloPinguin FloPinguin changed the title Some little HumansVsNations improvements before launch 🤖 Some little HumansVsNations improvements before public game launch 🤖 Jan 8, 2026
@FloPinguin FloPinguin changed the title Some little HumansVsNations improvements before public game launch 🤖 Some little HumansVsNations improvements before public games launch 🤖 Jan 8, 2026
@FloPinguin FloPinguin added this to the v29 milestone Jan 9, 2026

@evanpelle evanpelle left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@evanpelle
evanpelle merged commit eaef00e into openfrontio:main Jan 9, 2026
11 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants