Place a Completed-Game Analysis Library on Phone or Server
Compare phone and server execution of a provided analysis library, preserve game and version identity, and expose honest results when execution or connectivity fails.
Problem statement
For this exercise, assume a mobile game produces an immutable completed-game record and a provided black-box library computes suggestions for that record. Choose whether analysis runs on the player's phone or on a server, and compare the advantages and disadvantages of both. A hybrid is optional.
The library's internal game logic is provided; designing its algorithm, training a model, reconstructing a game or distributing static hint packs is outside scope.
A player requests analysis of one completed game and sees suggestions with the exact game and library version, or an explicit pending, invalid or unavailable outcome. No result for another game or a newer library version may silently replace the requested result.
The app retains the completed record while an accepted analysis is pending; retries must not create a different logical request. Server execution requires the player's permission to transmit the game record and an authenticated owner-scoped request and result. A phone-only design may keep records local.
Library versions are immutable compatible packages with a verifiable identity. For phone execution, activate only a complete verified package within the device budget. For server execution, pin a compatible version when accepting work.
A disconnected device can run a retained compatible package or show pending/unavailable according to the chosen placement; it cannot claim to know the newest server version.
Compare update effort, device CPU, memory, battery/thermal impact, privacy and network dependence and server capacity, then defend one coherent policy. There is no requirement to return a newly computed result while offline.
What to build
- Accept or retain one immutable completed-game analysis request, with explicit identity, validation and permission outcomes.
- Run the provided compatible library under a defended phone, server or optional hybrid policy without silently changing the requested game or version.
- Show versioned suggestions or a meaningful pending, invalid or unavailable outcome; make retry and reconnection resolve the same logical request.
- Make compatible immutable library versions available and activate only verified complete packages; preserve the identity of in-flight work and previously returned results.
At scale
- For this exercise, a game record is at most 100 KiB. A compatible library package occupies 20 MiB on disk; measured peak working memory, including its loaded code and input, is 32 MiB on the reference phone. The app may reserve at most 64 MiB of RAM for analysis and 40 MiB of disk for library packages. Temporary staging and retained active packages count toward that disk budget.
- For this exercise, the reference phone uses four CPU-seconds per game with an analysis budget of five CPU-seconds per game. A reference server uses 0.2 CPU-seconds per game; peak offered load is 100 analyses per second and the initial worker pool has 32 vCPUs. These are sizing measurements, not guarantees about end-to-end wall time.
- For this exercise, target a result within five seconds at p95 for admitted work under the healthy measured device/server and online-network profile. Include transfer, queueing and computation in that measurement; impose bounded admission and expose pending or unavailable when the target cannot be met. No online target applies to a disconnected device.
- For this exercise, game and library version identity is mandatory even during a release, duplicate request or lost response. Server status and results are owner-restricted; transmission is permission-controlled. A result is retained with its original identity rather than relabeled as a result from the latest version.