# Per-Level Scoring System ## Overview The AI Code Review environment now tracks individual scores for each difficulty level (easy, medium, hard), with a threshold of **≥0.7 (70%)** required to pass each level. ## Scoring Structure ### Reward System For each action (line flagging), the agent receives: - **+1.0**: Correctly flag an issue that exists and hasn't been found yet - **+0.2**: Partial credit - flag a line near an issue (within 1-2 lines distance) that hasn't been found - **-0.2**: Incorrect flag (false positive or duplicate) - **0.0**: No action taken (line_number = None) ### Level Scores After completing all steps in a level (reaching max_steps), the score is calculated as: ``` level_score = number_of_issues_correctly_found / total_issues_in_level ``` Each level has predetermined issues: - **Easy**: 3 issues (max_steps: 8) - **Medium**: 4 issues (max_steps: 12) - **Hard**: 5 issues (max_steps: 18) ### Pass Criteria - **Easy**: score ≥ 0.7 (find ≥ 2 out of 3 issues) - **Medium**: score ≥ 0.7 (find ≥ 3 out of 4 issues) - **Hard**: score ≥ 0.7 (find ≥ 4 out of 5 issues) ## API Endpoints ### `/level-scores` (GET) Returns individual scores for each difficulty level: ```json { "easy": 0.667, "medium": 1.0, "hard": 0.8, "all_levels_passed": false } ``` ### `/score` (GET) Returns the current level's progress score: ```json { "score": 0.75 } ``` ## Training Objective The agent should achieve: - Minimum 70% accuracy on easy tasks - Minimum 70% accuracy on medium tasks - Minimum 70% accuracy on hard tasks This ensures the agent learns to identify bugs reliably across all difficulty levels before moving to more complex code review tasks. ## Example Scenario **Easy Level (3 issues to find)** - Episode runs for max 8 steps - Agent flags 3 lines correctly: +1.0 each - Agent flags 5 wrong lines: -0.2 each - Total issues found: 3/3 = **1.0 (100%)** - Status: **PASS** ✓ **Medium Level (4 issues to find)** - Episode runs for max 12 steps - Agent flags 3 lines correctly: +1.0 each - Agent makes false positives: -0.2 each - Total issues found: 3/4 = **0.75 (75%)** - Status: **PASS** ✓ **Hard Level (5 issues to find)** - Episode runs for max 18 steps - Agent flags 3 lines correctly: +1.0 each - Agent makes errors and near-misses: +0.2 each - Total issues found: 3/5 = **0.6 (60%)** - Status: **FAIL** ✗