Skip to content

feat: Integrate AI primitives into AI orchestration layer#1172

Merged
braedonsaunders merged 1 commit into
mainfrom
claude/analyze-ai-architecture-EeYKw
Jan 31, 2026
Merged

feat: Integrate AI primitives into AI orchestration layer#1172
braedonsaunders merged 1 commit into
mainfrom
claude/analyze-ai-architecture-EeYKw

Conversation

@braedonsaunders

Copy link
Copy Markdown
Owner

Wire up sophisticated AI primitive systems into the AI orchestration layer:

  • AICoordinator: Initialize shared InfluenceMap and PositionalAnalysis, add per-player ScoutingMemory, WorkerDistribution, RetreatCoordination, and FormationControl instances
  • AIScoutingManager: Use ScoutingMemory for enemy intel tracking with confidence decay, strategy inference, and unit type detection
  • AITacticsManager: Use InfluenceMap for threat analysis, RetreatCoordination for coordinated retreats with rally points, FormationControl for army positioning with concave/box/spread formations
  • AIEconomyManager: Use WorkerDistribution for optimal worker saturation tracking and transfer recommendations across multiple bases
  • AIBuildOrderExecutor: Use PositionalAnalysis for strategic defensive building placement near choke points and pre-analyzed expansion locations

This eliminates code duplication between src/engine/ai (primitives) and src/engine/systems/ai (orchestration) by properly integrating the primitives' sophisticated algorithms.

https://claude.ai/code/session_01DNptntMLovVJiitzsVeDgY

Wire up sophisticated AI primitive systems into the AI orchestration layer:
- AICoordinator: Initialize shared InfluenceMap and PositionalAnalysis,
  add per-player ScoutingMemory, WorkerDistribution, RetreatCoordination,
  and FormationControl instances
- AIScoutingManager: Use ScoutingMemory for enemy intel tracking with
  confidence decay, strategy inference, and unit type detection
- AITacticsManager: Use InfluenceMap for threat analysis, RetreatCoordination
  for coordinated retreats with rally points, FormationControl for army
  positioning with concave/box/spread formations
- AIEconomyManager: Use WorkerDistribution for optimal worker saturation
  tracking and transfer recommendations across multiple bases
- AIBuildOrderExecutor: Use PositionalAnalysis for strategic defensive
  building placement near choke points and pre-analyzed expansion locations

This eliminates code duplication between src/engine/ai (primitives) and
src/engine/systems/ai (orchestration) by properly integrating the
primitives' sophisticated algorithms.

https://claude.ai/code/session_01DNptntMLovVJiitzsVeDgY
@braedonsaunders braedonsaunders force-pushed the claude/analyze-ai-architecture-EeYKw branch from 1fcbcaf to c4a1d46 Compare January 31, 2026 02:43
@braedonsaunders braedonsaunders merged commit b8f1733 into main Jan 31, 2026
4 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1fcbcaf942

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +770 to +773
// Check group retreat status
const retreatStatus = retreatCoordinator.getGroupStatus(this.world, ai.playerId);
if (retreatStatus.isRetreating) {
// Issue retreat commands to retreating units

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Trigger retreat orders without requiring group retreat

This branch only issues retreat MOVE commands when retreatStatus.isRetreating is true, but getGroupStatus only sets that flag when group retreat is active (retreat ratio/avg health threshold). As a result, individual low‑health units that receive retreat orders during retreatCoordinator.update(...) never get commanded to retreat unless a full group retreat is triggered, so they keep fighting and the new retreat coordination doesn’t engage in small skirmishes (e.g., 1–2 units drop below the health threshold while the rest of the army is healthy).

Useful? React with 👍 / 👎.

Comment on lines +506 to +510
for (const transfer of transfers) {
// The transfer already specifies which worker to move
const workerId = transfer.workerId;
const workerIndex = idleWorkers.findIndex(w => w.entityId === workerId);
if (workerIndex === -1) continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Execute transfers even when workers aren’t idle

WorkerDistribution can select workers that are still gathering when rebalancing oversaturated bases, but this code only executes a transfer if the worker is in idleWorkers and silently skips otherwise. In typical play, oversaturated workers are actively gathering, so transfers are never executed and the distribution system can’t actually rebalance bases. Consider issuing the transfer command regardless of idle state or ensuring WorkerDistribution only returns idle workers.

Useful? React with 👍 / 👎.

Comment on lines 720 to 722
const command: GameCommand = {
tick: currentTick,
playerId: ai.playerId,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid overriding formation MOVE with same‑tick ATTACK

This ATTACK command is issued on the same tick as the earlier formation MOVE orders in executeAttackingPhase. Because commands are dispatched immediately and later orders override earlier ones, the attack order will cancel the formation moves, so units never actually form up before engaging (especially on the first attack cooldown tick). To make formations take effect, the attack order needs to be delayed or queued after units reach formation positions.

Useful? React with 👍 / 👎.

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