Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions src/engine/core/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,33 +652,6 @@ export class Game extends GameCore {
}
}

/**
* Issue an AI command. In multiplayer, AI commands execute at current tick
* since AI logic is deterministic and runs identically on all clients.
* Commands are recorded for desync detection but not broadcast (both clients compute same AI).
*/
public issueAICommand(command: GameCommand): void {
// Ensure command tick is set to current tick for deterministic execution
command.tick = this.currentTick;

if (this.config.isMultiplayer) {
// In multiplayer, record the command for desync detection
// Both clients compute identical AI decisions, so no network broadcast needed
this.recordExecutedCommand(command);
}

// Execute command via parent class (bypasses multiplayer validation since AI is local)
super.processCommand(command);
}

/**
* Check if this client is in multiplayer mode.
* Used by AI systems to disable non-deterministic features.
*/
public isInMultiplayerMode(): boolean {
return this.config.isMultiplayer;
}

private queueCommandWithReceipt(command: GameCommand): void {
this.queueCommand(command);

Expand Down
15 changes: 15 additions & 0 deletions src/engine/core/GameCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,21 @@ export abstract class GameCore {
// COMMAND PROCESSING (shared implementation)
// ============================================================================

/**
* Issue an AI command for immediate execution at current tick.
* AI commands bypass multiplayer validation since AI logic is deterministic
* and runs identically on all clients.
*
* Subclasses (Game) may override to add multiplayer-specific behavior
* like command recording for desync detection.
*/
public issueAICommand(command: GameCommand): void {
// Set command tick to current tick for deterministic execution
command.tick = this.currentTick;
// Execute command directly
this.processCommand(command);
}

/**
* Queue a command for execution at a specific tick (lockstep multiplayer)
*/
Expand Down