Implements the StartupMessage protocol: client generates world_seed in SessionManager.new_game(), sends it after handshake, server uses it to seed SimRng and sample EntanglementConfig. EntanglementConfig samples flat ∈ [25,35]%, intrigue ∈ [15,25]%, mundane as remainder (D-029). Same seed produces identical config (D-010 determinism). Different seeds produce distinct configs in ≥90% of pairs. Protocol flow: HandshakeMessage (server→client) → StartupMessage with world_seed (client→server) → SimRng initialization → tick loop. 10 Rust tests (determinism, variation, bounds, sum invariant). 9 GDScript test stubs + 2 encode tests for client-side pipeline. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+12
-3
@@ -131,10 +131,19 @@ fn main() {
|
||||
std::process::exit(1);
|
||||
});
|
||||
|
||||
tracing::info!("Handshake sent, initializing simulation");
|
||||
// Read client's startup message containing world_seed (#175).
|
||||
// Client sends this immediately after validating the handshake.
|
||||
let startup = bridge.receive_startup().unwrap_or_else(|e| {
|
||||
tracing::error!("Failed to receive startup message: {}", e);
|
||||
std::process::exit(1);
|
||||
});
|
||||
|
||||
// RNG seed: test-mode defaults to 42 for deterministic replay
|
||||
let seed = seed_flag.unwrap_or(if test_mode { 42 } else { 0 });
|
||||
tracing::info!("Handshake complete, initializing simulation");
|
||||
|
||||
// RNG seed: --seed flag overrides client's world_seed (useful for testing).
|
||||
// Production: client sends world_seed via StartupMessage (#175).
|
||||
// Test mode default: 42 for deterministic replay.
|
||||
let seed = seed_flag.unwrap_or(if test_mode { 42 } else { startup.world_seed });
|
||||
|
||||
let mut app = App::new();
|
||||
app.add_plugins(SimulationPlugin);
|
||||
|
||||
Reference in New Issue
Block a user