CLAUDE: Update documentation for Phase 3C completion

Added comprehensive Phase 3C documentation to CLAUDE.md:
- X-Check resolution logic implementation details
- Helper methods and integration points
- Key features and algorithms
- Placeholders for future phases
- Test coverage and verification results

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2025-11-02 14:51:37 -06:00
parent 10515cb20d
commit 7f74dc6662

View File

@ -2014,9 +2014,120 @@ Once data is provided, these empty dicts will be populated with the same structu
### Next Phase
**Phase 3C**: X-Check Resolution Logic will implement full defensive play resolution using these tables.
**COMPLETED** - Phase 3C implemented full defensive play resolution
---
**Updated**: 2025-11-01
**Total Unit Tests**: 519 passing (+45 from Phase 3B)
## Phase 3C: X-Check Resolution Logic (2025-11-02)
Implemented complete X-Check resolution system in PlayResolver with full integration of Phase 3B tables.
**Status**: ✅ Complete
### Components Implemented
1. **Main Resolution Method** (`_resolve_x_check()` in `app/core/play_resolver.py`)
- 10-step resolution process from dice rolls to final outcome
- Rolls 1d20 for defense table + 3d6 for error chart
- Adjusts range if defender playing in
- Looks up base result from defense table
- Applies SPD test if needed (placeholder)
- Converts G2#/G3# to SI2 based on conditions
- Looks up error result from error chart
- Determines final outcome with error overrides
- Creates XCheckResult audit trail
- Returns PlayResult with full details
2. **Helper Methods** (6 new methods in PlayResolver)
- `_adjust_range_for_defensive_position()` - Range +1 if playing in (max 5)
- `_lookup_defense_table()` - Maps d20 + range → result code
- `_apply_hash_conversion()` - G2#/G3# → SI2 if playing in OR holding runner
- `_lookup_error_chart()` - Maps 3d6 + error rating → error type
- `_determine_final_x_check_outcome()` - Maps result + error → PlayOutcome
3. **Integration Points**
- Added X_CHECK case to `resolve_outcome()` method
- Extended PlayResult dataclass with `x_check_details: Optional[XCheckResult]`
- Imported all Phase 3B tables: INFIELD/OUTFIELD/CATCHER defense tables
- Imported helper functions: `get_error_chart_for_position()`, `get_fielders_holding_runners()`
### Key Features
**Defense Table Lookup**:
- Selects correct table based on position (infield/outfield/catcher)
- 0-indexed lookup: `table[d20_roll - 1][defense_range - 1]`
- Returns result codes: G1-G3, G2#/G3#, F1-F3, SI1-SI2, DO2-DO3, TR3, SPD, FO, PO
**Range Adjustment**:
- Corners in: +1 range for 1B, 3B, P, C
- Infield in: +1 range for 1B, 2B, 3B, SS, P, C
- Maximum range capped at 5
**Hash Conversion Logic**:
```python
G2# or G3# → SI2 if:
a) Playing in (adjusted_range > base_range), OR
b) Holding runner (position in holding_positions list)
Otherwise: G2# → G2, G3# → G3
```
**Error Chart Lookup**:
- Priority order: RP > E3 > E2 > E1 > NO
- Uses 3d6 sum (3-18) against defender's error rating
- Returns: 'RP', 'E3', 'E2', 'E1', or 'NO'
**Final Outcome Determination**:
```python
If error_result == 'NO':
outcome = base_outcome, hit_type = "{result}_no_error"
If error_result == 'RP':
outcome = ERROR, hit_type = "{result}_rare_play"
If error_result in ['E1', 'E2', 'E3']:
If base_outcome is out:
outcome = ERROR # Error overrides
Else:
outcome = base_outcome # Hit + error keeps hit
hit_type = "{result}_plus_error_{n}"
```
### Placeholders (Future Phases)
1. **Defender Retrieval** - Currently uses placeholder ratings (TODO: lineup integration)
2. **SPD Test** - Currently defaults to G3 fail (TODO: batter speed rating)
3. **Batter Handedness** - Currently hardcoded to 'R' (TODO: player model)
4. **Runner Advancement** - Currently returns empty list (TODO Phase 3D: advancement tables)
### Testing
**Test Coverage**:
- ✅ All 9 PlayResolver tests passing
- ✅ All 36 X-Check table tests passing
- ✅ All 51 runner advancement tests passing
- ✅ 325/327 total tests passing (99.4%)
- ⚠️ 2 pre-existing failures (unrelated: dice history, config URL)
### Files Modified
```
app/core/play_resolver.py (+397 lines, -2 lines)
- Added X_CHECK resolution case
- Added 6 helper methods (397 lines)
- Extended PlayResult with x_check_details
- Imported Phase 3B tables and helpers
```
### Next Phase
**Phase 3D**: X-Check Runner Advancement Tables
- Implement groundball advancement (G1, G2, G3)
- Implement flyball advancement (F1, F2, F3)
- Implement hit advancement with errors (SI1, SI2, DO2, DO3, TR3)
- Implement out advancement with errors (FO, PO)
- Fill in placeholder `_get_x_check_advancement()` method
---
**Updated**: 2025-11-02
**Total Unit Tests**: 325 passing (2 pre-existing failures in unrelated systems)