fix: balancing tie fold - #176
Conversation
📝 WalkthroughWalkthroughModifies the balanced-team tiebreak logic in CFBG.cpp: level-sum tiebreaking now compares average item level directly, and candidate group level sums are no longer pre-folded into context totals before team resolution. Updates accompanying documentation comments in CFBG.h and CFBG.conf.dist to reflect the revised semantics. ChangesBalanced team tiebreak refinement
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant SelectBalancedGroups
participant ctx as TeamBalanceContext
participant ResolveBalancedTeam
SelectBalancedGroups->>ctx: compute avgIlvlA/avgIlvlH without folding candidate SumPlayerLevel
SelectBalancedGroups->>ResolveBalancedTeam: request team decision
ResolveBalancedTeam->>ctx: compare levelSumA vs levelSumH
alt levels balanced
ResolveBalancedTeam->>ctx: compare avgIlvlA vs avgIlvlH
ResolveBalancedTeam-->>SelectBalancedGroups: return chosen team (keep pick on exact tie)
else levels unbalanced
ResolveBalancedTeam-->>SelectBalancedGroups: return chosen team by level sum
end
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/CFBG.cpp (1)
784-792: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winAt formation,
ctx.avgIlvlA/Hholds unnormalized sums rather than averages, creating team-size bias in the unconditional tiebreaker logic.At formation time (
bg == nullptr),ctx.avgIlvlA/Hare assignedstagedIlvlSumvalues, which accumulate raw sums of individual player ilvls (line 44:SumAverageItemLevel += player->GetAverageItemLevel()). During reinforcement, these fields hold true averages fromGetBGTeamAverageItemLevel()(line 151:return sum / count). Lines 227–233 compare these values directly without normalization, causing the formation-time comparison to weight team size: a larger team appears to have higher "average" ilvl even if per-player gear is identical. This bias now applies unconditionally to allCFBG.BalancedTeams = 1queues, not just whenIsEnableAvgIlvl()was explicitly enabled.Normalize
stagedIlvlSumby player count before assignment toctx.avgIlvlA/H, or compute a true average at formation time.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/CFBG.cpp` around lines 784 - 792, The formation-time tiebreaker in CFBG::BalancedTeams is using raw staged item-level sums instead of true averages, which biases comparisons toward larger teams. Update the formation path where ctx.avgIlvlA and ctx.avgIlvlH are assigned from stagedIlvlSum so they are normalized by each team’s player count, matching the behavior of GetBGTeamAverageItemLevel used when bg is present. Keep the fix localized to the average item-level calculation in CFBG::BalancedTeams / ctx initialization so the unconditional tiebreaker logic compares like-for-like averages.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/CFBG.cpp`:
- Around line 784-792: The formation-time tiebreaker in CFBG::BalancedTeams is
using raw staged item-level sums instead of true averages, which biases
comparisons toward larger teams. Update the formation path where ctx.avgIlvlA
and ctx.avgIlvlH are assigned from stagedIlvlSum so they are normalized by each
team’s player count, matching the behavior of GetBGTeamAverageItemLevel used
when bg is present. Keep the fix localized to the average item-level calculation
in CFBG::BalancedTeams / ctx initialization so the unconditional tiebreaker
logic compares like-for-like averages.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: dc697b8a-0978-4a18-a316-c7d9024e8008
📒 Files selected for processing (3)
conf/CFBG.conf.distsrc/CFBG.cppsrc/CFBG.h
Summary by CodeRabbit