"""Public numerical constants and serialization; no environment or task oracle."""
import hashlib, json, math
CAP = dict(cells=216, edges=540, development_ticks=1024,
           development_messages=4096, development_bytes=65536,
           development_queue=2048, local_development_bytes=2048,
           model_bytes=1048576, messages_per_transaction=1024,
           task_queue=512, incoming_per_cell=16, interface_slots=1, output_records=16,
           episode_ticks=110000, construction_seconds=2)
DEADLINE = 3 * (CAP['cells']-1) * 2 + 2  # independent simple-path physical bound
GAP = DEADLINE + 2
def canonical(x): return json.dumps(x,sort_keys=True,separators=(',',':'))
def digest(x): return hashlib.sha256(canonical(x).encode()).hexdigest()
def seed(*x): return int.from_bytes(hashlib.sha256('/'.join(map(str,x)).encode()).digest()[:8],'big')
def delay(p,q): return max(1,math.ceil(math.dist(p,q)))
class BudgetError(Exception): pass
class IntegrityError(Exception): pass
