Skip to content

Conversation

@FloPinguin
Copy link
Contributor

Description:

Refactor

  • Moved findBestNukeTarget() (and child methods) from AiAttackBehavior to NationNukeBehavior because it makes more sense.
  • NationNukeBehavior: Renamed mg to game (So its similar to the other nation .ts files)
  • Moved the removeOldNukeEvents() method a bit

New features

  • Impossible difficulty nations are now optimized for SAM outranging!
  • 1 of 3 nations is now a hydro-nation. They cannot send atom bombs. They save up for hydros. This is to reduce atom-bomb-spam on the map.
  • On impossible difficulty, the crown nukes the second place now (in FFAs)
  • On hard and impossible difficulty, nations now ignore the perceived cost for nukes if they get heavily attacked. Reasoning: They should stop saving for MIRV, they should defend with all their gold!
  • On medium, hard and impossible difficulty, nations no longer throw nukes at places where another team member already has a nuke "in the flying process"
  • Optimized lastNukeSent a bit (to respect nuke radius)
  • Adjusted maybeSendNuke() to use 30 instead of 10 randomTiles on impossible difficulty to improve chances of finding a perfect SAM outranging spot
  • On impossible difficulty, nations now ignore their "most hated enemy" if the crown has 50%+ of the map (Very big danger). Instead they are nuking the crown.
  • Added isFriendly check to findStrongestTeamTarget()

Media

SAM outranging:

2026-01-03.04-08-31.mp4

Team game nukes not hitting the same spot:

Screenshot 2026-01-03 042236

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

…vior` to `NationNukeBehavior` because it makes more sense.

- `NationNukeBehavior`: Renamed `mg` to `game` (So its similar to the other nation .ts files)
- 1 of 3 nations is now a hydro-nation. They cannot send atom bombs. They save up for hydros. This is to reduce atom-bomb-spam on the map.
…ost for nukes if they get heavily attacked. Reasoning: They should stop saving for MIRV, they should defend with all their gold!
…kes at places where another team member already has a nuke "in the flying process"
- Adjusted `maybeSendNuke()` to use 30 instead of 10 randomTiles on impossible difficulty to improve chances of finding a perfect SAM outranging spot
…y" if the crown has 50%+ of the map (Very big danger). Instead they are nuking the crown.

- Added `isFriendly` check to `findStrongestTeamTarget()`
@FloPinguin FloPinguin requested a review from a team as a code owner January 3, 2026 15:11
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 3, 2026

Walkthrough

Nuke targeting and timing moved from AiAttackBehavior into NationNukeBehavior. NationExecution now calls mirvBehavior.considerMIRV() earlier and invokes maybeSendNuke() with no target. NationNukeBehavior gained internal target selection, expanded validation, teammate-collision avoidance, recent-nuke tracking, and a hydro-nation preference.

Changes

Cohort / File(s) Summary
Call-site / Tick flow
src/core/execution/NationExecution.ts
Moved mirvBehavior.considerMIRV() earlier in the tick; replaced maybeSendNuke(target) call with maybeSendNuke() (target chosen internally).
Nuke behavior consolidation & enhancement
src/core/execution/nation/NationNukeBehavior.ts
Major refactor: constructor param/fields renamed mggame; maybeSendNuke() now computes target via findBestNukeTarget(); new helpers added (findFFACrownTarget, findStrongestTeamTarget, isUnderHeavyAttack, isTeammateAlreadyNukingThisSpot, removeOldNukeEvents); replaced lastNukeSent with recentlySentNukes (600-tick window); introduced isHydroNation; enhanced tile selection, SAM/interception checks, cost perception, and sendNuke instrumentation.
Attack behavior cleanup
src/core/execution/utils/AiAttackBehavior.ts
Removed internal nuke-target helpers (findBestNukeTarget, findFFACrownTarget, findStrongestTeamTarget); made findIncomingAttackPlayer() public; removed GameMode import.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant NationExecution
  participant MirvBehavior
  participant AiAttackBehavior
  participant NationNukeBehavior
  participant Game
  Note right of NationExecution `#DDEBF7`: Tick start

  NationExecution->>MirvBehavior: considerMIRV()
  MirvBehavior-->>NationExecution: (decisions)
  NationExecution->>AiAttackBehavior: maybeAttack()
  AiAttackBehavior-->>NationExecution: (attack decision / incoming attacker)
  NationExecution->>NationNukeBehavior: maybeSendNuke()
  Note right of NationNukeBehavior `#F7E9D7`: internally:\nfindBestNukeTarget()\nvalidation, SAM checks,\nteammate-collision checks
  NationNukeBehavior->>Game: assess config, units, distances
  Game-->>NationNukeBehavior: game state info
  alt valid nuke plan
    NationNukeBehavior->>Game: addExecution(sendNuke)
    Game-->>NationNukeBehavior: execution scheduled
  else no valid target
    NationNukeBehavior-->>NationExecution: no nuke
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

Feature - AI

Suggested reviewers

  • evanpelle
  • scottanderson

Poem

🌍 Nation's logic shifts its aim,
Bomb choices change, no longer the same,
Teammates steer clear of overlapping fire,
Crowns and heavy hits now tweak desire,
Hydro prefers a flash; tactics grow higher.

Pre-merge checks

❌ Failed checks (3 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title references emoji icons and uses vague phrasing 'much better nukes now (Part 2)' without clearly summarizing the main refactoring and behavioral changes. Replace with a more specific title like 'Refactor nuke targeting logic and improve AI behavior on higher difficulties' to clearly describe the primary changes.
Linked Issues check ❓ Inconclusive The PR description includes a reference to 'Part 2' and references GitHub media assets, but no linked issues, feature requests, or related PR context are mentioned in the provided materials. Verify that relevant issues or feature requests are linked to this PR for traceability and to establish context for the changes.
Out of Scope Changes check ❓ Inconclusive The changes appear focused on nuke-behavior refactoring and AI improvements; however, the renaming of 'mg' to 'game' and removal of GameMode imports could indicate broader consistency changes beyond the core nuke-targeting feature. Clarify whether the 'mg' to 'game' renaming is part of a larger codebase consistency effort or specific to this PR, and confirm that all changes align with the stated objectives.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description is directly related to the changeset, detailing refactoring steps, new features, and behavioral improvements across multiple files with clear explanations of each change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 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 996046a and 6f0e9fe.

📒 Files selected for processing (1)
  • src/core/execution/NationExecution.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/core/execution/NationExecution.ts

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.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 3, 2026
@iiamlewis iiamlewis added the Gameplay Features that affect gameplay label Jan 3, 2026
@iiamlewis iiamlewis added this to the v29 milestone Jan 3, 2026
Copy link
Collaborator

@evanpelle evanpelle left a comment

Choose a reason for hiding this comment

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

thanks!

@github-project-automation github-project-automation bot moved this from Triage to Final Review in OpenFront Release Management Jan 4, 2026
@evanpelle evanpelle added this pull request to the merge queue Jan 4, 2026
Merged via the queue into openfrontio:main with commit f73953c Jan 4, 2026
7 checks passed
@github-project-automation github-project-automation bot moved this from Final Review to Complete in OpenFront Release Management Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gameplay Features that affect gameplay

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

3 participants