[server] avg_time_seconds merge produces wrong value when losing side has more wins #23

Closed
opened 2026-05-19 18:44:34 +00:00 by funman300 · 0 comments
Owner

File

solitaire_sync/src/merge.rs lines 116–127

Description

The merge takes max(local_total_time, remote_total_time) and divides by max(games_won). This misattributes time when the device with more wins has a lower total time.

Example: local has 100 wins × 300 s avg (total = 30,000 s); remote has 50 wins × 1,000 s avg (total = 50,000 s). Merge gives 50,000 / 100 = 500 s/win — but the correct average for the 100-win device is 300 s.

Additionally, games_lost is merged with max() independently of games_played and games_won, so after a divergent merge games_won + games_lost > games_played is possible, producing win rates above 100%.

Fix

For avg_time_seconds: use the average from whichever side contributed merged_games_won. For games_lost: derive it as merged_games_played - merged_games_won after merging, rather than taking max() independently.

## File `solitaire_sync/src/merge.rs` lines 116–127 ## Description The merge takes `max(local_total_time, remote_total_time)` and divides by `max(games_won)`. This misattributes time when the device with more wins has a lower total time. Example: local has 100 wins × 300 s avg (total = 30,000 s); remote has 50 wins × 1,000 s avg (total = 50,000 s). Merge gives `50,000 / 100 = 500 s/win` — but the correct average for the 100-win device is 300 s. Additionally, `games_lost` is merged with `max()` independently of `games_played` and `games_won`, so after a divergent merge `games_won + games_lost > games_played` is possible, producing win rates above 100%. ## Fix For `avg_time_seconds`: use the average from whichever side contributed `merged_games_won`. For `games_lost`: derive it as `merged_games_played - merged_games_won` after merging, rather than taking `max()` independently.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: funman300/Ferrous-Solitaire#23