All files / systems/ai types.ts

100% Statements 13/13
100% Branches 2/2
100% Functions 1/1
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107                                      25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x                                                                                                                                                        
/**
 * AI Combat System Type Definitions
 * 
 * Core types for AI decision-making and combat behavior.
 * Separated to avoid circular dependencies between modules.
 * 
 * @module systems/ai/types
 * @category AI Combat
 * @korean AI 전투 시스템 타입 정의
 */
 
import { Position, TrigramStance } from "@/types";
import { BalanceState } from "@/types/player-visual";
 
/**
 * AI action types
 * 
 * @korean AI 행동 유형
 */
export enum AIActionType {
  ATTACK = "attack",
  TECHNIQUE = "technique",
  DEFEND = "defend",
  COUNTER = "counter",
  RETREAT = "retreat",
  APPROACH = "approach",
  CIRCLE = "circle",
  STANCE_CHANGE = "stance_change",
  FEINT = "feint",
  WAIT = "wait",
  COMBO = "combo",
}
 
/**
 * AI decision result
 * 
 * @korean AI 결정 결과
 */
export interface AIDecision {
  readonly action: AIActionType;
  readonly targetPosition?: Position;
  readonly targetStance?: TrigramStance;
  readonly targetVitalPoint?: string; // ID of vital point to target
  readonly priority: number; // 0-10: Decision confidence
  readonly reason: string; // For debugging/analysis
}
 
/**
 * Vulnerability assessment context for exploitation tactics
 * 
 * Comprehensive analysis of opponent's defenseless states:
 * - **isHelpless**: Balance === HELPLESS (90% takedown priority)
 * - **isVulnerable**: Balance === VULNERABLE or HELPLESS (70% aggressive attack priority)
 * - **isShaken**: Balance === SHAKEN, VULNERABLE, or HELPLESS (50% pressure tactics priority)
 * - **hasLowStamina**: Stamina < 20% (60% exploitation priority)
 * - **hasNoKi**: Ki < 10% (50% technique spam priority)
 * - **overallVulnerability**: Composite vulnerability score (0.0-1.0)
 * 
 * @korean 취약성 평가 컨텍스트
 */
export interface VulnerabilityContext {
  readonly isHelpless: boolean; // balance === HELPLESS
  readonly isVulnerable: boolean; // balance === VULNERABLE or HELPLESS
  readonly isShaken: boolean; // balance === SHAKEN, VULNERABLE, or HELPLESS
  readonly hasLowStamina: boolean; // stamina < 20%
  readonly hasNoKi: boolean; // ki < 10%
  readonly overallVulnerability: number; // 0.0-1.0 composite score
}
 
/**
 * Combat context for decision making
 * 
 * @korean 전투 컨텍스트
 */
export interface CombatContext {
  readonly playerPosition: Position;
  readonly opponentPosition: Position;
  readonly playerHealth: number;
  readonly playerMaxHealth: number;
  readonly playerKi: number;
  readonly playerMaxKi: number;
  readonly playerStamina: number;
  readonly playerMaxStamina: number;
  readonly opponentHealth: number;
  readonly opponentMaxHealth?: number; // Opponent max health (if undefined, assumes symmetric with playerMaxHealth)
  readonly opponentStance: TrigramStance;
  readonly playerStance: TrigramStance;
  readonly distanceToOpponent: number;
  readonly timeInMatch: number;
  readonly isOpponentAttacking: boolean;
  readonly recentDamageTaken: number;
  readonly opponentBalance?: BalanceState; // Balance state: "READY" | "SHAKEN" | "VULNERABLE" | "HELPLESS"
  readonly opponentStamina?: number; // Opponent stamina for exploitation
  readonly opponentMaxStamina?: number; // Opponent max stamina
  readonly opponentKi?: number; // Opponent ki for exploitation
  readonly opponentMaxKi?: number; // Opponent max ki
  readonly stanceFatigue?: {
    readonly timeInStance: number; // Milliseconds in current stance
  };
  readonly arenaBounds: {
    readonly x: number;
    readonly y: number;
    readonly width: number;
    readonly height: number;
  };
}