Skip to content

Add configurable time bias factor to karma calculation algorithm - #1

Draft
jolutz with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-b3f1e48e-a883-4e6f-a12c-f6ac2bf99bc5
Draft

jolutz with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-b3f1e48e-a883-4e6f-a12c-f6ac2bf99bc5

Conversation

Copilot AI commented Jul 12, 2025

Copy link
Copy Markdown

Overview

This PR implements a configurable bias factor for the average time calculation in the karma algorithm, addressing the requirement to make the bias towards the average of the time over the remaining laps configurable from the settings section.

Changes Made

Algorithm Updates

  • Modified core calculation functions to use a configurable bias factor:
    • fallback_strategy(): Uses (remaining_target / remaining_needed) * bias_factor
    • select_candidate(): Uses ((target - current_sum) / remaining_needed) * bias_factor
  • Updated function signatures throughout the call chain to pass the bias parameter
  • Added bias factor to the KarmaArgs struct for worker communication

Configuration

  • Added new constants in src/config.rs:
    • DEFAULT_TIME_BIAS_FACTOR = 1.0
    • MIN_TIME_BIAS_FACTOR = 0.5
    • MAX_TIME_BIAS_FACTOR = 2.0

UI Implementation

  • Added "Time Bias Factor" input field in the settings section
  • Implemented proper validation with range checking (0.5 to 2.0)
  • Added helpful user guidance explaining the effect of different values
  • Integrated with existing state management and validation patterns

Behavior

The bias factor controls car selection preferences:

  • 1.0 = Normal behavior (exact average) - maintains current algorithm
  • < 1.0 = Prefer faster cars (bias toward lower lap times)
  • > 1.0 = Prefer slower cars (bias toward higher lap times)

Example

With target 9000ms, current sum 3000ms, and 2 remaining cars needed:

  • Base average: 3000ms
  • Bias 0.5 → Adjusted average: 1500ms (prefers faster cars)
  • Bias 1.0 → Adjusted average: 3000ms (current behavior)
  • Bias 1.5 → Adjusted average: 4500ms (prefers slower cars)

Screenshot

Time Bias Factor UI

The new field appears in the Settings section with clear labeling and help text to guide users.

Backward Compatibility

  • Default bias factor is 1.0, maintaining existing algorithm behavior
  • No breaking changes to current workflows
  • All existing functionality preserved

Files Modified

  • src/config.rs - Added bias factor configuration constants
  • src/lib.rs - Updated core algorithm functions and signatures
  • src/main.rs - Added UI controls, state management, and validation
  • src/worker_agent.rs - Updated worker parameters

The implementation provides users with fine-grained control over the car selection algorithm while ensuring no disruption to existing usage patterns.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.unpkg.com
    • Triggering command: /tmp/cargo-installhd9p7S/release/build/minify-html-common-afec95f0a85adebb/build-script-build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: jolutz <81515870+jolutz@users.noreply.github.com>
Copilot AI changed the title [WIP] Make the bias towards the average of the time over the remaining laps configurable from the settings section. Add configurable time bias factor to karma calculation algorithm Jul 12, 2025
Copilot AI requested a review from jolutz July 12, 2025 08:05
@jolutz

jolutz commented Jul 12, 2025

Copy link
Copy Markdown
Owner

The parameter shouldn't control how fast the car is but how strongly the selection is biased towards the average

… time

Co-authored-by: jolutz <81515870+jolutz@users.noreply.github.com>

Copilot AI commented Jul 12, 2025

Copy link
Copy Markdown
Author

The parameter shouldn't control how fast the car is but how strongly the selection is biased towards the average

Fixed in commit 465fb18. The bias factor now controls how strongly the selection is biased towards the average time, rather than shifting the target time itself. The algorithm now calculates the true mathematical average and uses the bias factor to control the weighting strength in the selection process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants