M8: Complete offline match
`make match` plays one whole match from the lobby to the results and back to the lobby: one scripted player and 23 bots on a local server, with no script errors. - CommandLog records the seed, the rules and every command the server is given. MatchReplay plays a log again with nobody thinking and ends on the same state hash; `make match` saves the log, reads it back and checks that. - ServerLoop.submit() is now the one way commands reach the simulation, so a recording server sees them all. - ScriptedPlayer plays a human seat: it drops, loots, fights and flees as a bot does, and also cuts driftwood and builds a breakwater and a wall. - Bots draw randomness from their own per-bot generators, not the simulation's streams. A bot thinking no longer changes the simulation's state, which a replay without bots needs. - MatchView and EntityView draw a match from one Simulation: terrain, sea, points of interest, props, pieces, players, the barge, items and chests, with stand-in shapes for the art pass to replace. - `make match-captures` renders eight stages of the recorded match. Closes #31 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
extends TestCase
|
||||
|
||||
## The scripted player from issue M8: a stand-in for a person, which also harvests and
|
||||
## builds, things bots don't do yet.
|
||||
|
||||
|
||||
func test_a_scripted_seat_sends_commands_like_anyone_else() -> void:
|
||||
var loop: ServerLoop = ServerLoop.new(99, 1, 1)
|
||||
loop.play_humans_by_script()
|
||||
assert_eq(loop.scripted.size(), 1)
|
||||
assert_eq(loop.scripted[0].player_id, 1)
|
||||
assert_eq(loop.bots.size(), 1)
|
||||
for _index: int in Tuning.TICK_RATE_HZ * 24:
|
||||
loop.run_tick()
|
||||
assert_ne(loop.sim.entities.find(1).drop_state, Drop.ABOARD, "the scripted player leapt from the barge")
|
||||
|
||||
|
||||
func test_harvests_driftwood_and_builds_with_it() -> void:
|
||||
# Seed 2 is the match `make match` plays: the player lands, finds a weapon, cuts
|
||||
# driftwood and puts up a breakwater and a wall about a minute in.
|
||||
var loop: ServerLoop = ServerLoop.new(2, 1, 23)
|
||||
loop.play_humans_by_script()
|
||||
var player: ScriptedPlayer = loop.scripted[0]
|
||||
var placed: int = 0
|
||||
var harvests: int = 0
|
||||
while loop.ticks < 2400 and player.step != ScriptedPlayer.DONE:
|
||||
loop.run_tick()
|
||||
for event: Dictionary in loop.sim.events:
|
||||
if event["type"] == "piece_placed" and event["player"] == player.player_id:
|
||||
placed += 1
|
||||
elif event["type"] == "harvest" and event["player"] == player.player_id:
|
||||
harvests += 1
|
||||
assert_eq(player.step, ScriptedPlayer.DONE)
|
||||
assert_true(harvests >= 3, "swung at props %d times" % harvests)
|
||||
assert_true(player.harvested >= ScriptedPlayer.WANTED_DRIFTWOOD, "harvested %d" % player.harvested)
|
||||
assert_eq(player.built, 2)
|
||||
assert_eq(placed, 2)
|
||||
var kinds: Array[int] = []
|
||||
for piece: StructureSet.Piece in loop.sim.structures.pieces.values():
|
||||
if piece.owner == player.player_id:
|
||||
kinds.append(piece.kind)
|
||||
kinds.sort()
|
||||
assert_eq(kinds, [StructureSet.WALL, StructureSet.BREAKWATER] as Array[int])
|
||||
assert_false(loop.sim.entities.find(player.player_id).eliminated)
|
||||
Reference in New Issue
Block a user