diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistBootstrap/HyperTwistContractLibrary.cpp b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistBootstrap/HyperTwistContractLibrary.cpp index e7efc77..4015ee7 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistBootstrap/HyperTwistContractLibrary.cpp +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistBootstrap/HyperTwistContractLibrary.cpp @@ -1489,6 +1489,7 @@ FHyperTwistCoachSessionQueueSummary UHyperTwistContractLibrary::MakeSampleTraini return UHyperTwistTrainingCoachLibrary::DeriveCoachSessionQueueSummary( MakeSampleTrainingCoachBrief(), MakeSampleTrainingCoachFollowUpBrief(), + MakeSampleTrainingCoachMemorySnapshot(), MakeSampleTrainingCoachArchivePolicySummary(), MakeSampleTrainingReviewProgramSummary() ); diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingCoachLibrary.cpp b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingCoachLibrary.cpp index 9816d1d..17e7ba5 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingCoachLibrary.cpp +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingCoachLibrary.cpp @@ -2,6 +2,65 @@ namespace HyperTwistTrainingCoachLibraryInternal { + EHyperTwistTrainingCoachGuidanceLane GuidanceLaneFromSourceLabel(const FString& SourceLabel) + { + if (SourceLabel == TEXT("primary-brief")) + { + return EHyperTwistTrainingCoachGuidanceLane::Recommended; + } + if (SourceLabel == TEXT("follow-up-brief")) + { + return EHyperTwistTrainingCoachGuidanceLane::FollowUp; + } + + return EHyperTwistTrainingCoachGuidanceLane::None; + } + + float ResolvePreferredGuidanceQueueBias( + const FString& SourceLabel, + const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot, + const bool bHasCompetingGuidanceEntry) + { + if (CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::None) + { + return 0.0f; + } + + const EHyperTwistTrainingCoachGuidanceLane EntryLane = GuidanceLaneFromSourceLabel(SourceLabel); + if (EntryLane == EHyperTwistTrainingCoachGuidanceLane::None) + { + return 0.0f; + } + + float LanePressure = 0.0f; + if (CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::FollowUp) + { + LanePressure = + 4.0f + + static_cast(CoachMemorySnapshot.FollowUpGuidanceContinueBias) + + (static_cast(CoachMemorySnapshot.FollowUpReadyCoachSequenceCount) * 1.5f) + + (static_cast(CoachMemorySnapshot.ScheduleBlockedFollowUpEventCount) * 2.0f); + } + else + { + LanePressure = + 4.0f + + static_cast(CoachMemorySnapshot.RecommendedGuidanceContinueBias) + + (static_cast(CoachMemorySnapshot.RepeatRecommendationSequenceCount) * 1.5f) + + (CoachMemorySnapshot.bHasRepeatRecommendationPressure ? 4.0f : 0.0f); + } + + const float ClampedBoost = FMath::Clamp(LanePressure, 0.0f, 12.0f); + if (EntryLane == CoachMemorySnapshot.PreferredGuidanceLane) + { + return ClampedBoost; + } + + return bHasCompetingGuidanceEntry + ? -FMath::Clamp(ClampedBoost * 0.5f, 0.0f, 4.0f) + : 0.0f; + } + EHyperTwistCoachPriority PriorityFromScore(const float Score) { if (Score >= 85.0f) @@ -630,6 +689,7 @@ FHyperTwistCoachBrief UHyperTwistTrainingCoachLibrary::DeriveCoachFollowUpBrief( FHyperTwistCoachSessionQueueSummary UHyperTwistTrainingCoachLibrary::DeriveCoachSessionQueueSummary( const FHyperTwistCoachBrief& CurrentBrief, const FHyperTwistCoachBrief& FollowUpBrief, + const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot, const FHyperTwistTrainingCoachArchivePolicySummary& ArchivePolicySummary, const FHyperTwistTrainingReviewProgramSummary& ReviewProgramSummary) { @@ -653,8 +713,10 @@ FHyperTwistCoachSessionQueueSummary UHyperTwistTrainingCoachLibrary::DeriveCoach : (!CurrentBrief.FocusMethodSegmentId.IsEmpty() ? CurrentBrief.FocusMethodSegmentId : ArchivePolicySummary.FocusMethodSegmentId); + const bool bHasCompetingGuidanceEntry = + FollowUpBrief.UserId == Summary.UserId && FollowUpBrief.FocusCaseIds.Num() > 0; - auto AddBriefEntry = [&Summary]( + auto AddBriefEntry = [&Summary, &CoachMemorySnapshot, bHasCompetingGuidanceEntry]( const FString& EntryId, const FString& SourceLabel, const FHyperTwistCoachBrief& Brief, @@ -679,6 +741,16 @@ FHyperTwistCoachSessionQueueSummary UHyperTwistTrainingCoachLibrary::DeriveCoach Entry.FocusCaseIds = Brief.FocusCaseIds; Entry.bRequiresFollowUp = bRequiresFollowUp; Entry.bRequiresArchiveRetentionTuning = bRequiresArchiveRetentionTuning; + Entry.PriorityScore = FMath::Clamp( + Entry.PriorityScore + HyperTwistTrainingCoachLibraryInternal::ResolvePreferredGuidanceQueueBias( + SourceLabel, + CoachMemorySnapshot, + bHasCompetingGuidanceEntry + ), + 0.0f, + 100.0f + ); + Entry.Priority = HyperTwistTrainingCoachLibraryInternal::PriorityFromScore(Entry.PriorityScore); Summary.Entries.Add(Entry); }; diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingSubsystem.cpp b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingSubsystem.cpp index 30cf73d..b6f9787 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingSubsystem.cpp +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingSubsystem.cpp @@ -2135,6 +2135,7 @@ void UHyperTwistTrainingSubsystem::RefreshRepositoryViews() ActiveCoachSessionQueueSummary = UHyperTwistTrainingCoachLibrary::DeriveCoachSessionQueueSummary( ActiveCoachBrief, ActiveCoachFollowUpBrief, + ActiveCoachMemorySnapshot, ActiveCoachArchivePolicySummary, ActiveReviewProgramSummary ); diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingCoachLibrary.h b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingCoachLibrary.h index 6f96825..be86d88 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingCoachLibrary.h +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingCoachLibrary.h @@ -432,6 +432,7 @@ public: static FHyperTwistCoachSessionQueueSummary DeriveCoachSessionQueueSummary( const FHyperTwistCoachBrief& CurrentBrief, const FHyperTwistCoachBrief& FollowUpBrief, + const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot, const FHyperTwistTrainingCoachArchivePolicySummary& ArchivePolicySummary, const FHyperTwistTrainingReviewProgramSummary& ReviewProgramSummary );