Add the fixed-tick Simulation, the EntityRegistry with never-reused IDs, SimRng's named seeded streams, and the 14-byte PlayerCommand used by humans, bots and the network. state_hash is a SHA-256 over a canonical encoding of the state. Movement is a flat placeholder until the v0.2 character controller. Tests replay a 24-player command log over 10,000 ticks and scan src/sim for unseeded randomness and presentation code. Closes #5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.0 KiB
GDScript
36 lines
1.0 KiB
GDScript
extends TestCase
|
|
|
|
|
|
func test_same_seed_and_name_give_the_same_rolls() -> void:
|
|
assert_eq(_rolls(SimRng.new(42), "loot"), _rolls(SimRng.new(42), "loot"))
|
|
|
|
|
|
func test_different_seeds_give_different_rolls() -> void:
|
|
assert_ne(_rolls(SimRng.new(42), "loot"), _rolls(SimRng.new(43), "loot"))
|
|
|
|
|
|
func test_different_streams_give_different_rolls() -> void:
|
|
var rng: SimRng = SimRng.new(42)
|
|
assert_ne(_rolls(rng, "loot"), _rolls(rng, "weapons"))
|
|
|
|
|
|
func test_extra_rolls_in_one_stream_do_not_disturb_another() -> void:
|
|
var noisy: SimRng = SimRng.new(42)
|
|
_rolls(noisy, "loot")
|
|
assert_eq(_rolls(noisy, "weapons"), _rolls(SimRng.new(42), "weapons"))
|
|
|
|
|
|
func test_stream_names_are_sorted() -> void:
|
|
var rng: SimRng = SimRng.new(1)
|
|
rng.stream("zebra")
|
|
rng.stream("alpha")
|
|
assert_eq(rng.stream_names(), ["alpha", "zebra"] as Array[String])
|
|
|
|
|
|
func _rolls(rng: SimRng, stream_name: String) -> Array[int]:
|
|
var results: Array[int] = []
|
|
var stream: RandomNumberGenerator = rng.stream(stream_name)
|
|
for _index: int in 16:
|
|
results.append(stream.randi())
|
|
return results
|