diff --git a/spatial/generator.py b/spatial/generator.py index edcb453..62c24a7 100644 --- a/spatial/generator.py +++ b/spatial/generator.py @@ -144,15 +144,22 @@ def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0): # nothing. Without it "something was removed" and "the target lost support" # are the same event on every sample, and a one-bit rule fits the whole # family -- measured: that rule scores 1.000 here while knowing no physics. + # the causal variable is drawn, not fixed. Until it was, "there is a contact" + # and "the contact carries load" were the same event inside the family, so a + # constant answer fit it and the model never had to look at geometry -- which + # is exactly what the report kept showing. + dx = rng.choice((-13, -6, 0, 3, 6, 13)) + dy = rng.choice((-9, 0, 0, 0, 9)) ents = [Entity("G", "ground", attrs={"plane": 0}), Entity("P", "block", attrs={"box": [40, 40, 0, 60, 60, 20]}), - Entity("T", "block", attrs={"box": [42, 42, 20, 58, 58, 36]}), + Entity("T", "block", attrs={"box": [42 + dx, 42 + dy, 20, 58 + dx, 58 + dy, 36]}), Entity("D", "block", attrs={"box": [80, 40, 0, 100, 60, 16]})] edges = [Edge("kPG", "contact", "P", "G"), Edge("kPT", "contact", "T", "P"), Edge("kDG", "contact", "D", "G")] top = None if n_blocks >= 3: - ents.append(Entity("U", "block", attrs={"box": [44, 44, 36, 56, 56, 48]})) + ents.append(Entity("U", "block", + attrs={"box": [44 + dx, 44 + dy, 36, 56 + dx, 56 + dy, 48]})) edges.append(Edge("kTU", "contact", "U", "T")) top = "U" vis_edges = {e.eid for e in edges} @@ -185,7 +192,19 @@ def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0): def _build_freedom(rng, n_cons: int, hidden: int): - axes = list(DOF_AXES) + ["tz"] # a 7th constraint repeats tz: redundant + # the axes are drawn, so a family spans both verdicts with the same entity + # count: six mates that cover every axis lock the part, six that cover five + # do not, and the difference is invisible from the shape of the scene + axes = list(DOF_AXES) + if n_cons == 7: + rng.shuffle(axes) + axes = axes + [rng.choice(axes)] # a redundant 7th mate, last + else: + if rng.random() < 0.5: # drop one, repeat another + drop = rng.randrange(len(axes)) + dup = rng.choice([a for i, a in enumerate(axes) if i != drop]) + axes = [a for i, a in enumerate(axes) if i != drop] + [dup] + rng.shuffle(axes) ents = [Entity("P", "part", attrs={"x": 0, "y": 0, "z": 0})] edges, visible = [], set() for i in range(n_cons):