ML Camera System
ML Camera System
Section titled “ML Camera System”The ML (Machine Learning) camera system learns from player preferences to provide personalized camera experiences.
Overview
Section titled “Overview”The ML system:
- Tracks player viewing preferences
- Evaluates camera quality metrics
- Detects obstructions and issues
- Adapts camera positioning over time
- Personalizes per player
Enabling ML
Section titled “Enabling ML”Location: config/witness/config.json
{ "mlCamera": { "enabled": true, "learningRate": 0.01, "saveInterval": 300, "minDataPoints": 100 }}How It Works
Section titled “How It Works”Data Collection
Section titled “Data Collection”The system tracks:
- Camera Positions: Where cameras are placed
- Player Actions: How players interact with camera
- Quality Metrics: Obstruction, distance, angles
- Preferences: Which angles players view longest
- Context: Battle format, Pokemon species, moves
Learning Process
Section titled “Learning Process”- Observation: System observes camera usage
- Evaluation: Rates camera positions by quality
- Training: Updates model with new data
- Prediction: Suggests optimal camera positions
- Refinement: Continuous improvement
Quality Scoring
Section titled “Quality Scoring”Cameras are scored on:
- Visibility: Is action clearly visible?
- Obstruction: Are there blocks in the way?
- Distance: Is camera distance appropriate?
- Angle: Is viewing angle good?
- Framing: Are Pokemon well-framed?
Player Preferences
Section titled “Player Preferences”Tracking Preferences
Section titled “Tracking Preferences”The system learns:
{ "player_uuid": { "preferred_distance": 8.5, "preferred_height": 2.8, "preferred_angle": 12.0, "camera_sensitivity": 0.05, "orbit_preference": 0.6, "format_preferences": { "singles": { "distance": 7.0, "height": 2.5 }, "doubles": { "distance": 11.0, "height": 3.5 } } }}Preference Indicators
Section titled “Preference Indicators”Players influence ML through:
- View Duration: Longer views indicate good angles
- Camera Adjustments: Manual adjustments teach preferences
- Battle Replay: Watching replays shows preferred angles
- Format Selection: Format-specific preferences
Configuration
Section titled “Configuration”ML Configuration File
Section titled “ML Configuration File”Location: config/witness/ml_config.json
{ "features": { "trackPlayerPreference": true, "trackCameraQuality": true, "trackObstructions": true, "adaptToFormat": true, "learnFromReplays": false }, "weights": { "distance": 0.3, "angle": 0.25, "height": 0.2, "orbit": 0.15, "focus": 0.1 }, "training": { "batchSize": 10, "epochs": 5, "validationSplit": 0.2, "minBatchSize": 5 }, "quality": { "obstructionPenalty": 0.5, "boundaryPenalty": 0.3, "distancePenalty": 0.2, "framingBonus": 0.4 }, "persistence": { "saveInterval": 300, "autoBackup": true, "backupCount": 5 }}Feature Configuration
Section titled “Feature Configuration”Track Player Preference
Section titled “Track Player Preference”{ "trackPlayerPreference": true}Learns individual player preferences for camera positioning.
Track Camera Quality
Section titled “Track Camera Quality”{ "trackCameraQuality": true}Evaluates and scores camera positions for quality.
Track Obstructions
Section titled “Track Obstructions”{ "trackObstructions": true}Detects when terrain blocks view and avoids those positions.
Adapt to Format
Section titled “Adapt to Format”{ "adaptToFormat": true}Learns different preferences for singles, doubles, etc.
Weight Configuration
Section titled “Weight Configuration”Adjust how much each factor influences decisions:
{ "weights": { "distance": 0.3, // Camera distance importance "angle": 0.25, // Viewing angle importance "height": 0.2, // Camera height importance "orbit": 0.15, // Orbit movement importance "focus": 0.1 // Focus target importance }}Higher values = more influence on decisions.
Training Parameters
Section titled “Training Parameters”Batch Size
Section titled “Batch Size”{ "batchSize": 10}Number of data points per training batch. Higher = more stable, slower.
Epochs
Section titled “Epochs”{ "epochs": 5}Training iterations per batch. Higher = better learning, slower.
Validation Split
Section titled “Validation Split”{ "validationSplit": 0.2}Percentage of data used for validation (0.0-1.0).
Quality Metrics
Section titled “Quality Metrics”Obstruction Detection
Section titled “Obstruction Detection”The system detects:
- Blocks between camera and Pokemon
- Terrain blocking view
- Other entities in the way
- Weather/particle interference
Penalty applied when obstructions found:
{ "obstructionPenalty": 0.5}Boundary Detection
Section titled “Boundary Detection”Checks if camera is:
- Outside battle area
- In invalid positions
- Too close to boundaries
{ "boundaryPenalty": 0.3}Distance Evaluation
Section titled “Distance Evaluation”Rates camera distance:
- Too close: Penalty
- Too far: Penalty
- Optimal range: Bonus
{ "distancePenalty": 0.2}Framing Bonus
Section titled “Framing Bonus”Rewards good framing:
- Pokemon centered
- Action visible
- Appropriate zoom
{ "framingBonus": 0.4}Model Storage
Section titled “Model Storage”File Locations
Section titled “File Locations”Models stored in config/witness/ml/:
ml/├── global_model.json # Server-wide model├── players/│ ├── player_uuid_1.json # Per-player models│ └── player_uuid_2.json└── backups/ ├── global_backup_1.json └── global_backup_2.jsonModel Structure
Section titled “Model Structure”{ "version": "1.0", "lastUpdated": "2025-10-01T12:00:00Z", "dataPoints": 523, "parameters": { "distance": { "mean": 8.2, "variance": 1.4, "confidence": 0.85 }, "angle": { "mean": 12.5, "variance": 2.1, "confidence": 0.78 } }, "formatSpecific": { "singles": { ... }, "doubles": { ... } }}Commands
Section titled “Commands”View ML Status
Section titled “View ML Status”/witness ml statusShows:
- Learning enabled/disabled
- Data points collected
- Model confidence levels
- Recent learning activity
View Player Preferences
Section titled “View Player Preferences”/witness ml preferences [player]Display learned preferences for a player.
Reset ML Data
Section titled “Reset ML Data”/witness ml reset [player]Reset ML data for player or globally.
Force Training
Section titled “Force Training”/witness ml trainForce immediate training cycle (admin only).
Performance Considerations
Section titled “Performance Considerations”Memory Usage
Section titled “Memory Usage”ML system uses additional memory:
- ~1KB per player model
- ~10KB for global model
- ~5KB per backup
Monitor with: /witness ml memory
Training Impact
Section titled “Training Impact”Training has minimal performance impact:
- Runs asynchronously
- Batched processing
- Configurable intervals
Data Storage
Section titled “Data Storage”Models saved periodically:
- Default: Every 5 minutes
- Configurable via
saveInterval - Automatic backups
Best Practices
Section titled “Best Practices”Initial Setup
Section titled “Initial Setup”- Start with ML disabled
- Collect baseline data with static cameras
- Enable ML after 100+ battles
- Monitor initial learning phase
Tuning Learning Rate
Section titled “Tuning Learning Rate”- Higher (0.05-0.1): Fast learning, less stable
- Medium (0.01-0.05): Balanced
- Lower (0.001-0.01): Slow learning, more stable
Start with 0.01 and adjust based on results.
Data Requirements
Section titled “Data Requirements”Minimum data points for reliable learning:
- Global Model: 100+ battles
- Player Model: 20+ battles
- Format Model: 50+ battles of that format
Monitoring Quality
Section titled “Monitoring Quality”Regularly check:
/witness ml qualityLook for:
- High confidence scores (>0.7)
- Consistent preferences
- Low obstruction rates
Troubleshooting
Section titled “Troubleshooting”ML Not Learning
Section titled “ML Not Learning”Symptoms: Preferences not changing
Solutions:
- Check
minDataPointsthreshold - Verify
enabled: true - Check file permissions
- Review logs for errors
Poor Camera Choices
Section titled “Poor Camera Choices”Symptoms: ML suggests bad angles
Solutions:
- Increase
minDataPoints - Lower
learningRate - Reset and retrain
- Adjust quality weights
High Memory Usage
Section titled “High Memory Usage”Symptoms: Memory growing over time
Solutions:
- Reduce
backupCount - Increase
saveInterval - Clean old player models
- Limit
batchSize
Advanced Configuration
Section titled “Advanced Configuration”Custom Quality Function
Section titled “Custom Quality Function”Define custom quality evaluation:
{ "customQuality": { "enabled": true, "function": "weighted_average", "factors": { "visibility": 0.4, "distance": 0.3, "angle": 0.2, "aesthetic": 0.1 } }}Format-Specific Learning
Section titled “Format-Specific Learning”Different learning rates per format:
{ "formatLearning": { "singles": { "learningRate": 0.02, "minDataPoints": 50 }, "doubles": { "learningRate": 0.015, "minDataPoints": 75 } }}