Optional GamePlayKit integration #4

Open
opened 2025-10-14 15:33:19 -06:00 by navan · 0 comments
Owner

Originally created by @navanchauhan on 9/15/2025

Summary

Explore adding GamePlayKit-backed search as an optional strategy alongside the native engine implementation.

Goals

  • Define an abstraction that allows swapping between native and GamePlayKit strategists.
  • Bridge engine state into GKGameModel types without regressing performance.
  • Keep Linux builds functional via conditional compilation.

Plan

  1. Strategy Abstraction
    • Introduce a SearchStrategy protocol (or similar) used by the engine loop.
    • Keep the current minimax implementation as one conforming type.
    • Add a GamePlayKit-backed conformer that wraps GKMinmaxStrategist.
  2. Conditional Compilation & Availability
    • Guard imports with #if canImport(GameplayKit) and availability checks.
    • Provide a configuration switch (EngineConfiguration.usesGameplayKit) to opt in.
  3. State Bridging
    • Implement adapters for Game.Position -> GKGameModel, Move -> GKGameModelUpdate, and players.
    • Ensure copies are cheap and thread-safe.
  4. Concurrency & Performance
    • Determine how GK objects interact with Swift concurrency and actors.
    • Benchmark search depth/time against the native engine.
  5. Testing & Documentation
    • Add macOS/iOS unit tests for the GK path; skip on Linux.
    • Document usage, platform requirements, and fallback behavior.

Testing

  • Compare best-move outputs between native and GK strategies on sample positions.
  • Measure search times with and without GK to detect regressions.
  • Run existing regression suite under both strategy configurations.
*Originally created by @navanchauhan on 9/15/2025* ## Summary Explore adding GamePlayKit-backed search as an optional strategy alongside the native engine implementation. ## Goals - Define an abstraction that allows swapping between native and GamePlayKit strategists. - Bridge engine state into `GKGameModel` types without regressing performance. - Keep Linux builds functional via conditional compilation. ## Plan 1. **Strategy Abstraction** - Introduce a `SearchStrategy` protocol (or similar) used by the engine loop. - Keep the current minimax implementation as one conforming type. - Add a GamePlayKit-backed conformer that wraps `GKMinmaxStrategist`. 2. **Conditional Compilation & Availability** - Guard imports with `#if canImport(GameplayKit)` and availability checks. - Provide a configuration switch (`EngineConfiguration.usesGameplayKit`) to opt in. 3. **State Bridging** - Implement adapters for `Game.Position` -> `GKGameModel`, `Move` -> `GKGameModelUpdate`, and players. - Ensure copies are cheap and thread-safe. 4. **Concurrency & Performance** - Determine how GK objects interact with Swift concurrency and actors. - Benchmark search depth/time against the native engine. 5. **Testing & Documentation** - Add macOS/iOS unit tests for the GK path; skip on Linux. - Document usage, platform requirements, and fallback behavior. ## Testing - Compare best-move outputs between native and GK strategies on sample positions. - Measure search times with and without GK to detect regressions. - Run existing regression suite under both strategy configurations.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: navan/swift-chess-neo#4
No description provided.