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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 | 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 105x 105x 105x 105x 105x 105x 105x 192x 411x 411x 110x 301x 301x 301x 301x 301x 1x 301x 301x 301x 301x 167x 134x 25x 109x 301x 301x 1506x 301x 56x 245x 301x 301x 301x 1x 1x 300x 1x 1x 1x 301x 301x 301x 301x 301x 301x 116x 185x 301x 13x 288x 288x 191x 97x 97x 97x 97x 97x 97x 301x 301x 73x 228x 167x 167x 167x 167x 167x 124x 43x 35x 8x 167x 167x 167x 52x 115x 345x 115x 115x 1x 1x 114x 32x 31x 31x 83x 84x 83x 83x 83x 25x 25x 109x 109x 109x 34x 75x 34x 34x 41x 41x 301x 301x 42x 259x 1x 1x 1x 1x 1x 1x 1x 66x 66x 66x 34x 34x 34x 300x 300x 300x | /**
* AI Decision Tree for Korean Martial Arts Combat
* Strategic decision-making system with multiple tactical options
*
* **Korean Philosophy Integration (한국 무술 철학)**:
* - 지피지기백전불태 (知彼知己百戰不殆) - Know the enemy, know yourself, and victory is certain
* - 이순응변 (以柔應變) - Adapt with flexibility and flow like water
* - 급소공격 (急所攻擊) - Strike vital points with precision and timing
*/
import { Position, TrigramStance } from "@/types";
import { AIPersonality } from "./AIPersonality";
import { AIComboSystem } from "./ComboSystem";
import { TrigramSystem } from "@/systems/TrigramSystem";
import { KOREAN_VITAL_POINTS, getVitalPointById } from "@/systems/vitalpoint/KoreanVitalPoints";
import { PlayerState } from "@/systems/player";
/**
* AI action types
*/
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
*/
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
}
/**
* Combat context for decision making
*/
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 opponentStance: TrigramStance;
readonly playerStance: TrigramStance;
readonly distanceToOpponent: number;
readonly timeInMatch: number;
readonly isOpponentAttacking: boolean;
readonly recentDamageTaken: number;
readonly arenaBounds: {
readonly x: number;
readonly y: number;
readonly width: number;
readonly height: number;
};
}
/**
* AI Decision Tree System
*
* **Korean Combat Philosophy (한국 무술 철학)**:
* This system embodies traditional Korean martial arts principles:
*
* - **팔괘 응용** (Trigram Application): Uses Eight Trigram system for stance transitions
* - **급소 타격** (Vital Point Strikes): Targets anatomical weak points with precision
* - **상황 판단** (Situational Awareness): Adapts tactics based on combat context
* - **기술 조합** (Technique Combinations): Chains attacks into flowing combos
* - **방어 우선** (Defense First): Prioritizes survival and tactical retreat when needed
*/
export class AIDecisionTree {
private lastDecisionTime = 0;
private decisionCooldown = 50; // 50ms minimum between decisions
private consecutiveAttacks = 0;
private lastStanceChange = 0;
private readonly stanceChangeCooldown = 3000; // 3 seconds
// Systems for advanced decision-making
private trigramSystem: TrigramSystem;
private difficultyLevel: number = 0.5; // 0.0-1.0: AI skill level
constructor() {
this.trigramSystem = new TrigramSystem();
}
/**
* Set AI difficulty level for vital point targeting accuracy
* @param level - 0.0 (beginner) to 1.0 (master)
*/
setDifficultyLevel(level: number): void {
this.difficultyLevel = Math.max(0, Math.min(1, level));
}
/**
* Make strategic decision based on combat context
*/
makeDecision(
context: CombatContext,
personality: AIPersonality,
comboSystem: AIComboSystem
): AIDecision {
const now = Date.now();
// Respect decision cooldown for performance
if (now - this.lastDecisionTime < this.decisionCooldown) {
return {
action: AIActionType.WAIT,
priority: 0,
reason: "Decision cooldown active",
};
}
this.lastDecisionTime = now;
// Check for active combo first
Iif (comboSystem.isComboActive()) {
return this.decideComboAction(context, personality);
}
// Evaluate tactical options in priority order
const decisions: AIDecision[] = [];
// 1. Critical health - survival priority
decisions.push(this.evaluateSurvival(context, personality));
// 2. Counter-attack opportunity
if (context.isOpponentAttacking) {
decisions.push(this.evaluateCounter(context, personality));
}
// 3. Combo initiation
decisions.push(this.evaluateComboStart(context, personality, comboSystem));
// 4. Stance transition
decisions.push(this.evaluateStanceChange(context, personality, now));
// 5. Feint attack
decisions.push(this.evaluateFeint(context, personality));
// 6. Distance-based tactics
if (context.distanceToOpponent < 120) {
decisions.push(this.evaluateCloseRange(context, personality));
} else if (context.distanceToOpponent > 250) {
decisions.push(this.evaluateApproach(context, personality));
} else {
decisions.push(this.evaluateMidRange(context, personality));
}
// 7. Defensive positioning
decisions.push(this.evaluateDefense(context, personality));
// Select highest priority decision
const bestDecision = decisions.reduce((best, current) =>
current.priority > best.priority ? current : best
);
// Track consecutive attacks
if (
bestDecision.action === AIActionType.ATTACK ||
bestDecision.action === AIActionType.TECHNIQUE
) {
this.consecutiveAttacks++;
} else {
this.consecutiveAttacks = 0;
}
return bestDecision;
}
/**
* Evaluate survival tactics when critically low health
*/
private evaluateSurvival(
context: CombatContext,
personality: AIPersonality
): AIDecision {
const healthPercent = context.playerHealth / context.playerMaxHealth;
if (healthPercent < personality.tacticalRetreatThreshold) {
const retreatVector = this.calculateRetreatPosition(context);
return {
action: AIActionType.RETREAT,
targetPosition: retreatVector,
priority: 10, // Highest priority
reason: `Critical health: ${(healthPercent * 100).toFixed(1)}%`,
};
}
return { action: AIActionType.WAIT, priority: 0, reason: "Health stable" };
}
/**
* Evaluate counter-attack opportunity
*/
private evaluateCounter(
context: CombatContext,
personality: AIPersonality
): AIDecision {
const shouldCounter =
Math.random() < personality.defensePreference * 0.8 &&
context.distanceToOpponent < 150;
Eif (shouldCounter) {
return {
action: AIActionType.COUNTER,
priority: 8,
reason: "Opponent attacking - counter opportunity",
};
}
return {
action: AIActionType.DEFEND,
priority: 6,
reason: "Opponent attacking - defensive stance",
};
}
/**
* Evaluate combo initiation (fix for issue #2529467014)
*/
private evaluateComboStart(
context: CombatContext,
personality: AIPersonality,
comboSystem: AIComboSystem
): AIDecision {
// Check if combo system is already active
Iif (comboSystem.isComboActive()) {
return {
action: AIActionType.WAIT,
priority: 0,
reason: "Combo already active",
};
}
// Don't start combo if already in consecutive attacks
Iif (this.consecutiveAttacks > 0) {
return { action: AIActionType.WAIT, priority: 0, reason: "Combo cooldown" };
}
const hasResources =
context.playerKi > context.playerMaxKi * 0.3 &&
context.playerStamina > context.playerMaxStamina * 0.3;
const goodDistance = context.distanceToOpponent < 130;
const comboChance = Math.random() < personality.comboTendency;
if (hasResources && goodDistance && comboChance) {
return {
action: AIActionType.COMBO,
priority: 7,
reason: "Initiating combo sequence",
};
}
return {
action: AIActionType.WAIT,
priority: 0,
reason: "Combo conditions not met",
};
}
/**
* Evaluate stance change using TrigramSystem
*
* **Korean Philosophy (자세 전환)**:
* Uses I Ching-based trigram system to find optimal stance transitions.
* Considers resource costs and counter-stance effectiveness.
*/
private evaluateStanceChange(
context: CombatContext,
personality: AIPersonality,
now: number
): AIDecision {
// Respect stance change cooldown
if (now - this.lastStanceChange < this.stanceChangeCooldown) {
return {
action: AIActionType.WAIT,
priority: 0,
reason: "Stance change on cooldown",
};
}
const shouldChange = Math.random() < personality.stanceSwitchFrequency;
if (!shouldChange) {
return {
action: AIActionType.WAIT,
priority: 0,
reason: "No stance change needed",
};
}
// Use TrigramSystem to recommend optimal stance
// Create a minimal PlayerState object with only the properties actually used by recommendStance
const playerState = {
currentStance: context.playerStance,
ki: context.playerKi,
stamina: context.playerStamina,
archetype: personality.archetype,
} as unknown as PlayerState;
const recommendedStance = this.trigramSystem.recommendStance(playerState);
// Check if we can afford the transition
const canTransition = this.trigramSystem.canTransitionTo(
context.playerStance,
recommendedStance,
playerState
);
Iif (!canTransition) {
// Try counter-stance instead
const counterStance = this.selectCounterStance(
context.opponentStance,
personality
);
this.lastStanceChange = now;
return {
action: AIActionType.STANCE_CHANGE,
targetStance: counterStance,
priority: 5,
reason: `Counter stance to ${context.opponentStance} (급소 대응)`,
};
}
this.lastStanceChange = now;
return {
action: AIActionType.STANCE_CHANGE,
targetStance: recommendedStance,
priority: 6,
reason: `Optimal stance transition via TrigramSystem (팔괘 전환)`,
};
}
/**
* Evaluate feint attack
*/
private evaluateFeint(
context: CombatContext,
personality: AIPersonality
): AIDecision {
const shouldFeint =
Math.random() < personality.feintChance &&
context.distanceToOpponent < 180;
if (shouldFeint) {
return {
action: AIActionType.FEINT,
priority: 4,
reason: "Feinting to bait opponent",
};
}
return {
action: AIActionType.WAIT,
priority: 0,
reason: "No feint opportunity",
};
}
/**
* Evaluate close range tactics with vital point targeting
*
* **Korean Philosophy (급소 공격)**:
* At close range, AI targets specific vital points based on difficulty level.
* Higher difficulty = more precise targeting of critical points.
*/
private evaluateCloseRange(
context: CombatContext,
personality: AIPersonality
): AIDecision {
const hasResources =
context.playerKi > 10 && context.playerStamina > 15;
const aggression = personality.aggressionLevel;
// Select vital point target based on difficulty
const targetVitalPoint = this.selectVitalPointTarget(context, personality);
// Get Korean name for logging if vital point is selected
const vitalPointName = targetVitalPoint
? (getVitalPointById(targetVitalPoint)?.names.korean ?? targetVitalPoint)
: undefined;
if (Math.random() < aggression * 0.8) {
return {
action: AIActionType.ATTACK,
targetVitalPoint,
priority: targetVitalPoint ? 7 : 6,
reason: targetVitalPoint
? `Close range - vital point attack (급소 타격: ${vitalPointName})`
: "Close range - aggressive strike",
};
} else if (Math.random() < aggression * 0.9 && hasResources) {
return {
action: AIActionType.TECHNIQUE,
targetVitalPoint,
priority: targetVitalPoint ? 6 : 5,
reason: targetVitalPoint
? `Close range - technique on vital point (급소 기술: ${vitalPointName})`
: "Close range - technique execution",
};
} else {
return {
action: AIActionType.DEFEND,
priority: 4,
reason: "Close range - defensive posture (방어 자세)",
};
}
}
/**
* Select vital point to target based on difficulty and stance
*
* **Korean Philosophy (급소 선택)**:
* - Beginner AI: Random targeting or no specific target
* - Intermediate AI: Favors easier vital points
* - Advanced AI: Targets appropriate points for current stance
* - Master AI: Targets critical points with high precision
*/
private selectVitalPointTarget(
context: CombatContext,
personality: AIPersonality
): string | undefined {
// Guard: Ensure vital points are available
Iif (KOREAN_VITAL_POINTS.length === 0) {
return undefined;
}
// Check if AI attempts vital point targeting based on difficulty
const targetChance = this.difficultyLevel * personality.aggressionLevel;
if (Math.random() > targetChance) {
return undefined; // No specific vital point target
}
// Filter vital points by effective stance
const effectivePoints = KOREAN_VITAL_POINTS.filter(point =>
point.effectiveStances?.includes(context.playerStance)
);
Iif (effectivePoints.length === 0) {
// Fallback to any vital point
const randomIndex = Math.floor(Math.random() * KOREAN_VITAL_POINTS.length);
return KOREAN_VITAL_POINTS[randomIndex].id;
}
// Select based on difficulty level
if (this.difficultyLevel < 0.3) {
// Beginner: Random selection from effective points.
// NOTE: This uses Math.random(), which is not seeded and thus not deterministic.
// For reproducible AI behavior (e.g., in testing or balancing), consider using a seeded RNG.
// Also, this "beginner" AI still filters by effective points (stance-appropriate), which may be more sophisticated than a true novice.
// If true beginner behavior is desired, select from all KOREAN_VITAL_POINTS instead.
const randomIndex = Math.floor(Math.random() * effectivePoints.length);
return effectivePoints[randomIndex].id;
} else if (this.difficultyLevel < 0.6) {
// Intermediate: Prefer easier targets (lower difficulty)
const easierPoints = effectivePoints.filter(p => p.targetingDifficulty < 0.7);
Iif (easierPoints.length > 0) {
// Sort without mutating original array
const sortedEasierPoints = [...easierPoints].sort((a, b) => a.targetingDifficulty - b.targetingDifficulty);
return sortedEasierPoints[0].id;
}
return effectivePoints[0].id;
} else {
// Advanced/Master: Target high-value critical points
const criticalPoints = effectivePoints
.filter(p => p.severity === "critical" || p.severity === "major");
Eif (criticalPoints.length > 0) {
// Sort without mutating original array
const sortedCritical = [...criticalPoints].sort((a, b) => (b.baseDamage ?? 0) - (a.baseDamage ?? 0));
return sortedCritical[0].id;
}
// Fallback to highest damage point (guaranteed to exist due to check at line 456)
const sortedByDamage = [...effectivePoints].sort((a, b) => (b.baseDamage ?? 0) - (a.baseDamage ?? 0));
return sortedByDamage[0]?.id ?? effectivePoints[0].id;
}
}
/**
* Evaluate approach tactics
*/
private evaluateApproach(
context: CombatContext,
_personality: AIPersonality
): AIDecision {
const approachPos = this.calculateApproachPosition(context);
return {
action: AIActionType.APPROACH,
targetPosition: approachPos,
priority: 5,
reason: `Moving closer (distance: ${Math.round(context.distanceToOpponent)})`,
};
}
/**
* Evaluate mid-range tactics
*/
private evaluateMidRange(
context: CombatContext,
_personality: AIPersonality
): AIDecision {
const hasResources = context.playerKi > context.playerMaxKi * 0.3;
const tacticRoll = Math.random();
if (tacticRoll < 0.3 && hasResources) {
return {
action: AIActionType.TECHNIQUE,
priority: 5,
reason: "Mid-range technique",
};
} else if (tacticRoll < 0.6) {
const circlePos = this.calculateCirclePosition(context);
return {
action: AIActionType.CIRCLE,
targetPosition: circlePos,
priority: 4,
reason: "Tactical repositioning",
};
} else {
const approachPos = this.calculateApproachPosition(context);
return {
action: AIActionType.APPROACH,
targetPosition: approachPos,
priority: 4,
reason: "Moving to optimal range",
};
}
}
/**
* Evaluate defensive tactics
*/
private evaluateDefense(
context: CombatContext,
personality: AIPersonality
): AIDecision {
const shouldDefend =
Math.random() < personality.defensePreference &&
context.recentDamageTaken > 20;
if (shouldDefend) {
return {
action: AIActionType.DEFEND,
priority: 6,
reason: "Defensive response to damage",
};
}
return {
action: AIActionType.WAIT,
priority: 0,
reason: "No defensive need",
};
}
/**
* Decide combo action
*/
private decideComboAction(
_context: CombatContext,
_personality: AIPersonality
): AIDecision {
return {
action: AIActionType.COMBO,
priority: 9,
reason: "Continuing active combo",
};
}
/**
* Calculate retreat position
*/
private calculateRetreatPosition(context: CombatContext): Position {
const dx = context.playerPosition.x - context.opponentPosition.x;
const dy = context.playerPosition.y - context.opponentPosition.y;
const distance = Math.sqrt(dx * dx + dy * dy);
// Normalize and retreat
const retreatDistance = 150;
const nx = dx / distance;
const ny = dy / distance;
return {
x: Math.max(
context.arenaBounds.x,
Math.min(
context.arenaBounds.x + context.arenaBounds.width - 60,
context.playerPosition.x + nx * retreatDistance
)
),
y: Math.max(
context.arenaBounds.y,
Math.min(
context.arenaBounds.y + context.arenaBounds.height - 180,
context.playerPosition.y + ny * retreatDistance
)
),
};
}
/**
* Calculate approach position
*/
private calculateApproachPosition(context: CombatContext): Position {
const offsetX = (Math.random() - 0.5) * 80;
const offsetY = (Math.random() - 0.5) * 60;
return {
x: Math.max(
context.arenaBounds.x,
Math.min(
context.arenaBounds.x + context.arenaBounds.width - 60,
context.opponentPosition.x + offsetX
)
),
y: Math.max(
context.arenaBounds.y,
Math.min(
context.arenaBounds.y + context.arenaBounds.height - 180,
context.opponentPosition.y + offsetY
)
),
};
}
/**
* Calculate circle position
*/
private calculateCirclePosition(context: CombatContext): Position {
const angle = Math.atan2(
context.opponentPosition.y - context.playerPosition.y,
context.opponentPosition.x - context.playerPosition.x
);
const circleRadius = 150 + Math.random() * 50;
return {
x: Math.max(
context.arenaBounds.x,
Math.min(
context.arenaBounds.x + context.arenaBounds.width - 60,
context.opponentPosition.x + Math.cos(angle + Math.PI / 2) * circleRadius
)
),
y: Math.max(
context.arenaBounds.y,
Math.min(
context.arenaBounds.y + context.arenaBounds.height - 180,
context.opponentPosition.y + Math.sin(angle + Math.PI / 2) * circleRadius
)
),
};
}
/**
* Select counter-stance to opponent's stance (fix for issue #2529466994)
* Implements actual counter logic based on Korean martial arts philosophy
*/
private selectCounterStance(
opponentStance: TrigramStance,
personality: AIPersonality
): TrigramStance {
// Define counter relationships based on trigram philosophy
const stanceCounters: Record<TrigramStance, TrigramStance[]> = {
[TrigramStance.GEON]: [TrigramStance.GAM, TrigramStance.GON], // Heaven countered by Water, Earth
[TrigramStance.TAE]: [TrigramStance.LI, TrigramStance.GEON], // Lake countered by Fire, Heaven
[TrigramStance.LI]: [TrigramStance.GAM, TrigramStance.SON], // Fire countered by Water, Wind
[TrigramStance.JIN]: [TrigramStance.GAN, TrigramStance.GON], // Thunder countered by Mountain, Earth
[TrigramStance.SON]: [TrigramStance.GAN, TrigramStance.GEON], // Wind countered by Mountain, Heaven
[TrigramStance.GAM]: [TrigramStance.GON, TrigramStance.GAN], // Water countered by Earth, Mountain
[TrigramStance.GAN]: [TrigramStance.JIN, TrigramStance.TAE], // Mountain countered by Thunder, Lake
[TrigramStance.GON]: [TrigramStance.SON, TrigramStance.LI], // Earth countered by Wind, Fire
};
const counters = stanceCounters[opponentStance] || [];
// Try to find a counter that's also in favored stances
const favoredCounters = counters.filter((s) =>
personality.favoredStances.includes(s)
);
if (favoredCounters.length > 0) {
return favoredCounters[Math.floor(Math.random() * favoredCounters.length)];
}
// Fallback to any counter stance
if (counters.length > 0) {
return counters[Math.floor(Math.random() * counters.length)];
}
// Last resort: use favored stance
if (personality.favoredStances.length > 0) {
return personality.favoredStances[
Math.floor(Math.random() * personality.favoredStances.length)
];
}
// Ultimate fallback: different stance (issue #2529728009)
const allStances = Object.values(TrigramStance);
const filtered = allStances.filter((s) => s !== opponentStance);
if (filtered.length === 0) {
return opponentStance; // Edge case: same stance
}
return filtered[Math.floor(Math.random() * filtered.length)];
}
/**
* Reset decision state
*/
reset(): void {
this.lastDecisionTime = 0;
this.consecutiveAttacks = 0;
this.lastStanceChange = 0;
}
}
|