Skip to content

fix: normalize BatteryLevel to 0-1 range in simulator#335

Merged
from2001 merged 2 commits intodevelopfrom
claude/issue-334-20260213-0804
Feb 13, 2026
Merged

fix: normalize BatteryLevel to 0-1 range in simulator#335
from2001 merged 2 commits intodevelopfrom
claude/issue-334-20260213-0804

Conversation

@from2001
Copy link
Collaborator

@from2001 from2001 commented Feb 13, 2026

Fixes #334

Changed battery simulation from 0-100 percentage range to 0-1 normalized range to match real device behavior:

  • BATTERY_INITIAL_MIN: 50.0 → 0.5
  • BATTERY_INITIAL_MAX: 100.0 → 1.0
  • BATTERY_DRAIN_RATE: 10.0/60.0 → 0.5/1200.0 (adjusted to drain from 100% to 50% in 20 minutes per collaborator request)
  • Updated all log messages to show normalized values
  • Improved precision from .1f to .2f for better accuracy

Generated with Claude Code

Fixes #334

Changed battery simulation from 0-100 percentage range to 0-1
normalized range to match real device behavior:
- BATTERY_INITIAL_MIN: 50.0 → 0.5
- BATTERY_INITIAL_MAX: 100.0 → 1.0
- BATTERY_DRAIN_RATE: 10.0/60.0 → 0.1/60.0
- Updated all log messages to show normalized values
- Improved precision from .1f to .2f for better accuracy

Co-authored-by: Masahiro Yamaguchi <from2001@users.noreply.github.com>
@from2001
Copy link
Collaborator Author

@claude Change the drain rate and logic so that buttery life will be 50% in 20 mins.

@claude
Copy link
Contributor

claude bot commented Feb 13, 2026

Claude finished @from2001's task in 2m 1s —— View job


Battery drain rate updated successfully ✓

  • Read current battery drain implementation
  • Calculate new drain rate for 50% battery in 20 minutes
  • Update BATTERY_DRAIN_RATE constant
  • Run code quality checks (black, ruff, mypy, pytest) (tools not available in GitHub Actions environment)
  • Commit and push changes

Summary

Updated the battery drain rate in client_simulator.py to ensure battery life drains from 100% to 50% in exactly 20 minutes.

Changes:

  • Changed BATTERY_DRAIN_RATE from 0.1 / 60.0 to 0.5 / 1200.0 (≈0.000417 per second)
  • Updated comment to reflect new behavior: "50% in 20 mins"

Math:

  • To drain from 1.0 to 0.5 in 20 minutes (1200 seconds)
  • Drain amount needed: 0.5
  • Rate: 0.5 / 1200 = 0.000417 per second

Note: Please run code quality checks locally (black, ruff, mypy, pytest) before merging, as these tools are not available in the GitHub Actions environment.

--- |

Changed drain rate from 0.1/60.0 to 0.5/1200.0 per second to ensure
battery drains from 100% to 50% in exactly 20 minutes as requested.

Co-authored-by: Masahiro Yamaguchi <from2001@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes issue #334 by normalizing the battery level range from 0-100 to 0-1 in the simulator to match real device behavior. The change ensures consistency between simulated clients and actual Unity devices, which use Unity's SystemInfo.batteryLevel API that returns values in the 0.0-1.0 range.

Changes:

  • Normalized battery simulation constants from percentage (0-100) to normalized range (0-1)
  • Updated all battery-related log messages to reflect normalized values and improved precision
  • Changed formatting precision from .1f to .2f for consistency with Unity client's F2 format

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@from2001 from2001 marked this pull request as ready for review February 13, 2026 12:26
@from2001 from2001 merged commit d3ed148 into develop Feb 13, 2026
13 checks passed
@from2001 from2001 deleted the claude/issue-334-20260213-0804 branch February 13, 2026 12:26
from2001 added a commit that referenced this pull request Feb 14, 2026
Resolve merge conflicts:
- benchmark/ files: Accept develop deletion (PR #336)
- client_simulator.py: Auto-merged successfully (PR #335 battery fix + message ID rename)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

BatteryLevel scale mismatch: Simulator sends 0–100, devices use 0–1

2 participants