extends SceneTree ## SITE 7 contract — the imported shop: ## - it builds, with racks AND bins ## - the cascade came off the shop's own data: racks hold bins via `supported_by` ## - smashing one rack releases exactly ITS bins, and no others ## - the real genre labels survived the import ## ## Godot --headless --path game --script dev/probe_store.gd func _initialize() -> void: var main: Node = (load("res://main.tscn") as PackedScene).instantiate() get_root().add_child(main) await process_frame main._load_level("store") for i in 70: await physics_frame var racks: Array = [] var bins: Array = [] var labelled := 0 for n in get_nodes_in_group("smashable"): var s := n as Smashable if s == null: continue if s.supports.size() > 0: racks.append(s) if s.freeze: bins.append(s) if s.has_meta("label"): labelled += 1 print("racks holding bins: %d frozen bins: %d labelled bins: %d" % [ racks.size(), bins.size(), labelled]) if racks.is_empty() or bins.is_empty(): print("FAIL: the shop did not import (no racks holding bins)") quit(1) return if labelled < 20: print("FAIL: the real genre labels did not survive the import") quit(1) return # find the rack carrying the most bins and knock it over var best: Smashable = racks[0] for r in racks: if r.supports.size() > best.supports.size(): best = r var mine: Array = [] for b in best.supports: if is_instance_valid(b): mine.append(b) var others: Array = [] for b in bins: if is_instance_valid(b) and not mine.has(b): others.append(b) var others_frozen_before := 0 for b in others: if (b as RigidBody3D).freeze: others_frozen_before += 1 print("smashing '%s' — it carries %d bins" % [best.name, mine.size()]) best.smash(Vector3(0, 1, 0), 999.0) await physics_frame await physics_frame var released := 0 for b in mine: if is_instance_valid(b) and not (b as RigidBody3D).freeze: released += 1 var others_still := 0 for b in others: if is_instance_valid(b) and (b as RigidBody3D).freeze: others_still += 1 print("its bins released: %d/%d other bins still frozen: %d/%d" % [ released, mine.size(), others_still, others_frozen_before]) if released == mine.size() and others_still == others_frozen_before: print("STORE OK") quit(0) else: print("FAIL: cascade released the wrong set of bins") quit(1)