From 13f598d0bf2228e9720a946c77dfa7d89a7e7103 Mon Sep 17 00:00:00 2001 From: axiomlogicnexus Date: Mon, 27 Apr 2026 19:11:55 +0200 Subject: [PATCH] Bias queue ordering by recovery action --- .../HyperTwistTrainingCoachLibrary.cpp | 65 ++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingCoachLibrary.cpp b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingCoachLibrary.cpp index b2849f0..d0ff669 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingCoachLibrary.cpp +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingCoachLibrary.cpp @@ -131,6 +131,62 @@ namespace HyperTwistTrainingCoachLibraryInternal return 0.0f; } + float ResolvePreferredRecoveryActionQueueBias( + const FString& SourceLabel, + const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot, + const bool bHasCompetingGuidanceEntry, + const bool bHasArchiveEntry) + { + if (!CoachMemorySnapshot.bNeedsScheduleFrictionRecovery + || CoachMemorySnapshot.PreferredQueueRecoveryAction == EHyperTwistTrainingQueueRecoveryAction::None) + { + return 0.0f; + } + + const EHyperTwistTrainingCoachGuidanceLane EntryLane = GuidanceLaneFromSourceLabel(SourceLabel); + const bool bMatchesPreferredLane = + EntryLane != EHyperTwistTrainingCoachGuidanceLane::None + && EntryLane == CoachMemorySnapshot.PreferredGuidanceLane; + + if (CoachMemorySnapshot.PreferredQueueRecoveryAction + == EHyperTwistTrainingQueueRecoveryAction::PromoteDeferred) + { + if (bMatchesPreferredLane) + { + return 5.0f; + } + if (SourceLabel == TEXT("archive-policy") && bHasArchiveEntry) + { + return -2.5f; + } + if (bHasCompetingGuidanceEntry && EntryLane != EHyperTwistTrainingCoachGuidanceLane::None) + { + return -2.0f; + } + + return 0.0f; + } + + if (CoachMemorySnapshot.PreferredQueueRecoveryAction + == EHyperTwistTrainingQueueRecoveryAction::LaunchRecovery) + { + if (bMatchesPreferredLane) + { + return 2.5f; + } + if (SourceLabel == TEXT("archive-policy") && bHasArchiveEntry && bHasCompetingGuidanceEntry) + { + return -1.5f; + } + if (bHasCompetingGuidanceEntry && EntryLane != EHyperTwistTrainingCoachGuidanceLane::None) + { + return -0.75f; + } + } + + return 0.0f; + } + float ResolvePreferredGuidanceSignalBias( const EHyperTwistTrainingCoachGuidanceLane SignalLane, const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot, @@ -1021,8 +1077,15 @@ FHyperTwistCoachSessionQueueSummary UHyperTwistTrainingCoachLibrary::DeriveCoach bHasFollowUpEntry, bHasArchiveEntry ); + const float RecoveryActionBias = + HyperTwistTrainingCoachLibraryInternal::ResolvePreferredRecoveryActionQueueBias( + SourceLabel, + CoachMemorySnapshot, + bHasCompetingGuidanceEntry, + bHasArchiveEntry + ); Entry.PriorityScore = FMath::Clamp( - Entry.PriorityScore + GuidanceBias + ArchiveCompetitionBias, + Entry.PriorityScore + GuidanceBias + ArchiveCompetitionBias + RecoveryActionBias, 0.0f, 100.0f );