import numpy as np def run_simulation(agents, steps, noise, coupling): n = len(agents) history = [] state = agents.copy() for _ in range(steps): new_state = state.copy() for i in range(n): interaction = np.mean(state) - state[i] new_state[i] += coupling * interaction new_state += np.random.normal(0, noise, size=n) new_state = np.clip(new_state, 0, 1) history.append(new_state.copy()) state = new_state return history