tostido commited on
Commit
d7d4a7e
·
1 Parent(s): d7a37f1

🔧 Fix null gates ignoring slider (was always spawning 5)

Browse files
Files changed (2) hide show
  1. src/lattice.py +6 -5
  2. src/streamlit_app.py +1 -3
src/lattice.py CHANGED
@@ -58,14 +58,14 @@ class Hyperlattice:
58
  instant transit to distant regions (wormholes).
59
  """
60
 
61
- def __init__(self, dimensions: Tuple[int, int, int] = (8, 8, 8)):
62
  self.dimensions = dimensions
63
  self.graph = nx.DiGraph()
64
  self.nodes: Dict[str, LatticeNode] = {}
65
  self.null_gates: Dict[str, str] = {} # gate_id -> connected_gate_id
66
- self._build_base_lattice()
67
 
68
- def _build_base_lattice(self):
69
  """Build the initial 3D grid structure."""
70
  dx, dy, dz = self.dimensions
71
 
@@ -102,8 +102,9 @@ class Hyperlattice:
102
  weight = 1.0 + np.random.random() * 0.5
103
  self.graph.add_edge(source, target, weight=weight)
104
 
105
- # Add null gates (random wormholes)
106
- self._add_null_gates(num_gates=5)
 
107
 
108
  def _add_null_gates(self, num_gates: int = 5):
109
  """Add null gate pairs (wormholes) connecting distant regions."""
 
58
  instant transit to distant regions (wormholes).
59
  """
60
 
61
+ def __init__(self, dimensions: Tuple[int, int, int] = (8, 8, 8), num_null_gates: int = 0):
62
  self.dimensions = dimensions
63
  self.graph = nx.DiGraph()
64
  self.nodes: Dict[str, LatticeNode] = {}
65
  self.null_gates: Dict[str, str] = {} # gate_id -> connected_gate_id
66
+ self._build_base_lattice(num_null_gates=num_null_gates)
67
 
68
+ def _build_base_lattice(self, num_null_gates: int = 0):
69
  """Build the initial 3D grid structure."""
70
  dx, dy, dz = self.dimensions
71
 
 
102
  weight = 1.0 + np.random.random() * 0.5
103
  self.graph.add_edge(source, target, weight=weight)
104
 
105
+ # Add null gates (random wormholes) - only if requested
106
+ if num_null_gates > 0:
107
+ self._add_null_gates(num_gates=num_null_gates)
108
 
109
  def _add_null_gates(self, num_gates: int = 5):
110
  """Add null gate pairs (wormholes) connecting distant regions."""
src/streamlit_app.py CHANGED
@@ -121,9 +121,7 @@ def init_simulation():
121
  agents = st.session_state.num_agents
122
  gates = st.session_state.num_gates
123
 
124
- st.session_state.lattice = Hyperlattice(dimensions=(size, size, size))
125
- if gates > 5:
126
- st.session_state.lattice._add_null_gates(gates - 5)
127
  st.session_state.swarm = QuineSwarm(st.session_state.lattice, initial_agents=agents)
128
  st.session_state.cascade = CascadeBridge(session_id=f"stream_{int(time.time())}")
129
  st.session_state.step_count = 0
 
121
  agents = st.session_state.num_agents
122
  gates = st.session_state.num_gates
123
 
124
+ st.session_state.lattice = Hyperlattice(dimensions=(size, size, size), num_null_gates=gates)
 
 
125
  st.session_state.swarm = QuineSwarm(st.session_state.lattice, initial_agents=agents)
126
  st.session_state.cascade = CascadeBridge(session_id=f"stream_{int(time.time())}")
127
  st.session_state.step_count = 0