Build real-time multiplayer games with PubNub game state sync
Does it follow best practices?
Evaluation — 97%
↑ 1.21xAgent success when using this tile
Validation for skill structure
A startup is building an online chess platform where players can queue for ranked matches and get paired with opponents of similar skill. The platform uses an ELO rating system. Once matched, players are placed into a game room where they take turns making moves. The entire networking layer should be built on PubNub.
The matchmaking system needs to be fair and tamper-proof -- players should not be able to manipulate who they get matched with or skip the queue. The matching should also be responsive: if an exact skill match is not immediately available, the system should gradually broaden its search rather than leaving the player waiting indefinitely.
Once in a game, the turn-based system must enforce time limits on each move. If a player takes too long or disconnects, the game should continue without blocking the other player indefinitely. Only the room creator should be able to trigger the game start.
Produce the following JavaScript files:
matchmaker.js -- A server-side module that handles the matchmaking queue, player pairing, and room assignment. This should run on PubNub's infrastructure, not on the client.matchmaker-client.js -- The client-side code that lets a player join the matchmaking queue and receive match notifications. Should include logic for progressively widening the search criteria.turn-manager.js -- A module managing the turn-based game flow: tracking whose turn it is, enforcing time limits, handling what happens when a player's clock runs out or they disconnect, and managing game start authorization.All files should be complete JavaScript modules with comments.