Tic-Tac-Toe Multiplayer
Mission Brief
Implement a tamper-resistant client-server multiplayer architecture in Unity where clients submit unvalidated move intents via RPCs and the server acts as the single source of truth.
Key Systems Engineered
Server-Authoritative RPC Move Validation (GameManager.cs)
Clients invoke [Rpc(SendTo.Server)] ClickedOnGridPositionRpc(x, y, playerType). The server independently validates turn ownership (playerType == currentPlayablePlayerType.Value) and cell vacancy before mutating authoritative board state and broadcasting [Rpc(SendTo.ClientsAndHost)] visual triggers.
Automatic State Replication via NetworkVariable<T>
Tracks currentPlayablePlayerType, playerCrossScore, and playerCircleScore as NetworkVariables whose OnValueChanged callbacks drive local UI updates across connected clients without manual score-sync packets.
Precomputed 8-Line Win Evaluator & Deterministic Session Bootstrapping
Builds all 8 winning Line structs (3 grid coords, center cell reference, and Horizontal/Vertical/DiagonalA/DiagonalB orientation enum) once in Awake(), and auto-starts the match on the server the instant ConnectedClientsList.Count == 2.
Implementation Details
Architecture & Deep Dive
This project implements server-authoritative multiplayer using Unity’s Netcode for GameObjects (NGO). Clients send move intents as RPCs, but the server independently validates turn ownership and cell vacancy before accepting any move, preventing client-side cheating.
Game state is replicated automatically via NetworkVariable<T>, with UI updates driven by OnValueChanged callbacks rather than manual synchronization packets. The win evaluator precomputes all 8 winning line configurations once at startup.