Add two-stage charged-crystal demo and original art set.
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
extends SceneTree
|
||||
|
||||
const WorldSimulation = preload("res://src/simulation/world_simulation.gd")
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
var first := _run_factory()
|
||||
var second := _run_factory()
|
||||
var mana_pause := _run_mana_pause_resume()
|
||||
var bridge_result := _run_bridge_factory()
|
||||
var failures: Array[String] = []
|
||||
|
||||
if int(first["refined"]) < 20:
|
||||
failures.append("Expected at least 20 refined crystals, got %d." % int(first["refined"]))
|
||||
if first["fingerprint"] != second["fingerprint"]:
|
||||
failures.append("Identical fixed-tick runs produced different fingerprints.")
|
||||
if int(first["items"]) != int(second["items"]):
|
||||
failures.append("Identical runs produced different in-flight item counts.")
|
||||
if not bool(mana_pause["stopped_without_mana"]):
|
||||
failures.append("Machine produced output without a connected mana network.")
|
||||
if not bool(mana_pause["paused_exactly"]):
|
||||
failures.append("Disconnecting mana did not preserve the unfinished recipe.")
|
||||
if not bool(mana_pause["resumed"]):
|
||||
failures.append("Machine did not resume its unfinished recipe after mana reconnection.")
|
||||
if int(bridge_result["refined"]) < 20:
|
||||
failures.append("Bridge-bound machine did not sustain production.")
|
||||
|
||||
if failures.is_empty():
|
||||
print("SIMULATION_SMOKE_OK refined=%d fingerprint=%s items=%d" % [
|
||||
int(first["refined"]),
|
||||
String(first["fingerprint"]),
|
||||
int(first["items"]),
|
||||
])
|
||||
quit(0)
|
||||
else:
|
||||
for failure in failures:
|
||||
push_error(failure)
|
||||
quit(1)
|
||||
|
||||
|
||||
func _run_factory() -> Dictionary:
|
||||
var simulation := WorldSimulation.new()
|
||||
simulation.place_building(WorldSimulation.KIND_SOURCE, Vector2i(-3, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_BELT, Vector2i(-2, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_BELT, Vector2i(-1, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_MACHINE, Vector2i(0, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_MANA_SOURCE, Vector2i(0, 2), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_MANA_PIPE, Vector2i(0, 1), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_BELT, Vector2i(1, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_BELT, Vector2i(2, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_SINK, Vector2i(3, 0), 0)
|
||||
|
||||
for _tick in range(1800):
|
||||
simulation.step()
|
||||
|
||||
return {
|
||||
"refined": simulation.get_refined_count(),
|
||||
"fingerprint": simulation.state_fingerprint(),
|
||||
"items": simulation.items.size(),
|
||||
}
|
||||
|
||||
|
||||
func _run_mana_pause_resume() -> Dictionary:
|
||||
var simulation := WorldSimulation.new()
|
||||
simulation.place_building(WorldSimulation.KIND_SOURCE, Vector2i(-3, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_BELT, Vector2i(-2, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_BELT, Vector2i(-1, 0), 0)
|
||||
var machine_id := simulation.place_building(WorldSimulation.KIND_MACHINE, Vector2i(0, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_BELT, Vector2i(1, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_BELT, Vector2i(2, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_SINK, Vector2i(3, 0), 0)
|
||||
|
||||
for _tick in range(200):
|
||||
simulation.step()
|
||||
var stopped_without_mana: bool = (
|
||||
simulation.get_refined_count() == 0
|
||||
and simulation.buildings[machine_id]["status"] == &"no_mana"
|
||||
)
|
||||
|
||||
simulation.place_building(WorldSimulation.KIND_MANA_SOURCE, Vector2i(0, 2), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_MANA_PIPE, Vector2i(0, 1), 0)
|
||||
for _tick in range(10):
|
||||
simulation.step()
|
||||
var remaining_before_disconnect: int = int(simulation.buildings[machine_id]["completion_tick"]) - simulation.tick_index
|
||||
simulation.remove_building(Vector2i(0, 1))
|
||||
var paused_remaining: int = int(simulation.buildings[machine_id]["remaining_ticks"])
|
||||
for _tick in range(100):
|
||||
simulation.step()
|
||||
var paused_exactly: bool = (
|
||||
simulation.get_refined_count() == 0
|
||||
and paused_remaining == remaining_before_disconnect
|
||||
and int(simulation.buildings[machine_id]["completion_tick"]) == -1
|
||||
)
|
||||
|
||||
simulation.place_building(WorldSimulation.KIND_MANA_PIPE, Vector2i(0, 1), 0)
|
||||
for _tick in range(120):
|
||||
simulation.step()
|
||||
return {
|
||||
"stopped_without_mana": stopped_without_mana,
|
||||
"paused_exactly": paused_exactly,
|
||||
"resumed": simulation.get_refined_count() > 0,
|
||||
}
|
||||
|
||||
|
||||
func _run_bridge_factory() -> Dictionary:
|
||||
var simulation := WorldSimulation.new()
|
||||
simulation.place_building(WorldSimulation.KIND_SOURCE, Vector2i(-3, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_BELT, Vector2i(-2, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_BELT, Vector2i(-1, 0), 0)
|
||||
var machine_id := simulation.place_building(WorldSimulation.KIND_MACHINE, Vector2i(0, 1), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_BELT, Vector2i(1, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_BELT, Vector2i(2, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_SINK, Vector2i(3, 0), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_MANA_SOURCE, Vector2i(0, 3), 0)
|
||||
simulation.place_building(WorldSimulation.KIND_MANA_PIPE, Vector2i(0, 2), 0)
|
||||
var configured := simulation.configure_machine_bridge(
|
||||
machine_id,
|
||||
Vector2i(-1, 0),
|
||||
Vector2i(1, 0)
|
||||
)
|
||||
if not configured:
|
||||
return {"refined": 0}
|
||||
for _tick in range(1800):
|
||||
simulation.step()
|
||||
return {"refined": simulation.get_refined_count()}
|
||||
Reference in New Issue
Block a user