Introduction:
T(n) is a visual performance generated from a dynamic matrix structure, defined by two core components: an energy cycle that distributes energy across cells, and a population of agents interacting within the grid.
Variables at t(0):
– Execution time → 2,678,400 seconds
– Matrix size → 64 × 64 (base grid dimension)
– Energy types → 1 (distributed across the grid)
– Agent classes → 2 (N = consumers, P = producers)
– Class assignment per agent → 1
Evolution rule:
t(n) = t(n−1) × 2
Start time:
SOLANA ->
5KfqXLAUq9dVZx6hkKEJteno6GtfoA7idv2iWNtwpump
Note:
Conceived and built by GPT‑like systems.
Executed and connected by human.
Scripts for t(0):
MATRIX:defines the grid structure and its dimensions.
# matrix/cell.py
# 26-10-2025
from vars.vars import colors
class CellContent:
def __init__(self, cell_desc: str, cell_type: int, energy: float):
self.desc = cell_desc
self.type = cell_type
self.energy = float(energy)
def __repr__(self):
return f"{self.desc}:{self.type} -> {self.energy}"
class Cell:
def __init__(self, state: int = 0):
self.contents = [
CellContent(colors[1]["desc"], 1, 0),
]
self.state = state
def __repr__(self):
return f"Cell(contents={self.contents}, state={self.state})"
# matrix/matrix.py
# 26-10-2025
import pickle
import statistics
from .cell import Cell
# 28-10-2025
from PIL import Image, ImageDraw, ImageFont
from vars.vars import dead, producer, consumer
# 30-10-2025
from vars.vars import png_path, json_path, buffer_files_png, buffer_files_json
class Matrix:
def __init__(self, n: int):
self.n = n
self.grid = [[Cell() for _ in range(n)] for _ in range(n)]
def get_cell(self, row: int, col: int) -> Cell:
return self.grid[row][col]
def set_cell(self, row: int, col: int, cell: Cell):
self.grid[row][col] = cell
def __repr__(self):
return f"Matrix({self.n}x{self.n})"
def save_pickle(self, filename: str = "matrix.pkl"):
with open(filename, "wb") as f:
pickle.dump(self, f)
@staticmethod
def load_pickle(filename: str = "matrix.pkl"):
with open(filename, "rb") as f:
return pickle.load(f)
def print_states(self):
for row in self.grid:
print(" ".join(str(cell.state) for cell in row))
def average_energy(self) -> float:
energies = [c.energy for row in self.grid for cell in row for c in cell.contents]
return statistics.median(energies) if energies else 0.0
def save_as_image(self, population, path=png_path):
import itertools, os
if not hasattr(self, "_buffer_cycle"):
self._buffer_files = buffer_files_png
self._buffer_cycle = itertools.cycle(self._buffer_files)
buffer_file = next(self._buffer_cycle)
n = self.n
cell_h = 18
cell_w = int(cell_h * 1.618033988)
img_width = n * cell_w
img_height = n * cell_h
img = Image.new("RGB", (img_width, img_height), "black")
draw = ImageDraw.Draw(img)
try:
font = ImageFont.truetype("DejaVuSansMono.ttf", 12)
except:
font = ImageFont.load_default()
for i in range(n):
for j in range(n):
cell = self.get_cell(i, j)
if cell.state == 0:
energy = cell.contents[0].energy if cell.contents else 0
text = f"{energy:5.1f}"
elif cell.state == dead:
text = f"{'*':^5}"
else:
agent_id = cell.state
agent = population.agents.get_by_id(agent_id)
if agent is None:
text = f"{'?':^5}"
else:
if agent.type == producer:
text = f"{'P':^5}"
elif agent.type == consumer:
text = f"{'N':^5}"
else:
text = f"{'?':^5}"
cx = j * cell_w + cell_w/2
cy = i * cell_h + cell_h/2
draw.text((cx, cy), text, font=font, fill="white", anchor="mm")
img.save(buffer_file, format="PNG", optimize=True)
try:
os.remove(path)
except FileNotFoundError:
pass
os.symlink(buffer_file, path)
# 30-10-2025
def save_as_json(self, population, path=json_path):
import itertools, os, json
if not hasattr(self, "_buffer_cycle_json"):
self._buffer_files_json = buffer_files_json
self._buffer_cycle_json = itertools.cycle(self._buffer_files_json)
buffer_file = next(self._buffer_cycle_json)
n = self.n
matrix = []
for i in range(n):
row = []
for j in range(n):
cell = self.get_cell(i, j)
if cell.state == 0:
energy = cell.contents[0].energy if cell.contents else 0
text = f"{energy:5.1f}"
elif cell.state == dead:
text = f"{'*':^5}"
else:
agent_id = cell.state
agent = population.agents.get_by_id(agent_id)
if agent is None:
text = f"{'?':^5}"
else:
if agent.type == producer:
text = f"{'P':^5}"
elif agent.type == consumer:
text = f"{'N':^5}"
else:
text = f"{'?':^5}"
row.append(text)
matrix.append(row)
with open(buffer_file, "w") as f:
json.dump(matrix, f)
try:
os.remove(path)
except FileNotFoundError:
pass
os.symlink(buffer_file, path)
Agents → rules and behaviors of the agent population.
# agents/agentstore.py
# 28-10-2025
from collections import Counter
import bisect
class AgentStore:
def __init__(self):
self._keys = []
self._agents = []
self._agent_map = {}
self.type_counter = Counter()
def add(self, agent):
if agent.id in self._agent_map:
self.remove(self._agent_map[agent.id])
key = (-agent.speed, agent.id)
idx = bisect.bisect_left(self._keys, key)
self._keys.insert(idx, key)
self._agents.insert(idx, agent)
self._agent_map[agent.id] = agent
self.type_counter[agent.type] += 1
def remove(self, agent):
self._agent_map.pop(agent.id, None)
key = (-agent.speed, agent.id)
idx = bisect.bisect_left(self._keys, key)
if idx < len(self._keys) and self._keys[idx] == key and self._agents[idx].id == agent.id:
self._keys.pop(idx)
self._agents.pop(idx)
else:
for j, a in enumerate(self._agents):
if a.id == agent.id:
self._agents.pop(j)
self._keys.pop(j)
break
if agent.type in self.type_counter:
self.type_counter[agent.type] -= 1
if self.type_counter[agent.type] <= 0:
del self.type_counter[agent.type]
def get_by_id(self, agent_id):
return self._agent_map.get(agent_id)
def __iter__(self):
return iter(self._agents)
def __len__(self):
return len(self._agents)
def stats(self):
return dict(self.type_counter)
# agents/agent.py
# 27-10-2025
from abc import ABC, abstractmethod
from matrix.matrix import Matrix
class Agent(ABC):
def __init__(self, x, y, energy=10.0, speed=0, costs=0,id =0, type=0, turn=0):
self.x = x
self.y = y
self.energy = energy
self.speed = speed
self.costs = costs
self.alive = True
self.id = id
self.type = type
self.turn = turn
def move(self, matrix: Matrix, dx, dy):
if not self.alive:
return
new_x = self.x + dx
new_y = self.y + dy
if 0 <= new_x < matrix.n and 0 <= new_y < matrix.n:
current_cell = matrix.get_cell(self.x, self.y)
new_cell = matrix.get_cell(new_x, new_y)
if new_cell.state == 0:
current_cell.state = 0
self.x = new_x
self.y = new_y
new_cell.state = self.id
@abstractmethod
def absorb(self, matrix: Matrix):
pass
@abstractmethod
def transform(self, matrix: Matrix):
pass
@abstractmethod
def release(self, matrix: Matrix):
pass
@abstractmethod
def die(self, matrix: Matrix):
pass
@abstractmethod
def evaluate_cell(self, matrix: Matrix):
pass
@abstractmethod
def fitness(self, matrix: Matrix, x, y):
pass
# agents/producer.py
# 27-10-2025
from matrix.matrix import Matrix
from agents.agents import Agent
from vars.vars import producer, perc_d_pro, dead
import random
class Producer(Agent):
def __init__(self, x, y, energy=10.0, speed=0, costs=0, id=0, turn=0, producer_factor=1):
super().__init__(x, y, energy, speed, costs, id, type=producer, turn=turn)
self.producer_factor = producer_factor
def absorb(self, matrix: Matrix):
cell = matrix.get_cell(self.x, self.y)
available = cell.contents[0].energy if cell.contents else 0.0
base_absorb = 1.0
desired = base_absorb * (self.producer_factor + self.turn)
absorbed = min(desired, available)
self.energy += absorbed
if cell.contents:
cell.contents[0].energy -= absorbed
def transform(self, matrix: Matrix):
pass
def release(self, matrix: Matrix):
pass
def die(self, matrix: Matrix):
self.alive = False
cell = matrix.get_cell(self.x, self.y)
cell.state = dead
def evaluate_cell(self, matrix: Matrix):
pass
def fitness(self, matrix: Matrix, x, y):
self.turn += 1
if not self.alive:
self.energy = max(0, self.energy - self.costs * self.turn)
return
if random.random() < perc_d_pro:
self.die(matrix)
self.energy -= self.costs
return
current_cell = matrix.get_cell(self.x, self.y)
best_dx, best_dy = 0, 0
best_value = current_cell.contents[0].energy if current_cell.contents else 0.0
for dx, dy in ((-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)):
nx, ny = self.x + dx, self.y + dy
if 0 <= nx < matrix.n and 0 <= ny < matrix.n:
cell = matrix.grid[nx][ny]
if cell.state == 0:
net_value = (cell.contents[0].energy if cell.contents else 0.0) - self.costs
if net_value > best_value:
best_value, best_dx, best_dy = net_value, dx, dy
if self.energy <= self.costs:
self.absorb(matrix)
else:
self.move(matrix, best_dx, best_dy)
self.absorb(matrix)
self.energy -= self.costs
# agents/consumer.py
# 28-10-2025
from matrix.matrix import Matrix
from agents.agents import Agent
from vars.vars import dead, consumer, perc_d_cons, producer
import random
class Consumer(Agent):
def __init__(self, x, y, energy=10.0, speed=1, costs=1, id=0, turn=0):
super().__init__(x, y, energy, speed, costs, id, type=consumer, turn=turn)
def absorb(self, matrix: Matrix, population: "Population", dx: int, dy: int): #loop
nx, ny = self.x + dx, self.y + dy
if not (0 <= nx < matrix.n and 0 <= ny < matrix.n):
return
target_cell = matrix.get_cell(nx, ny)
target_id = target_cell.state
target = population.agents.get_by_id(target_id)
if target is None or target.id == self.id:
return
gained = target.energy * 0.9
self.energy += gained
population.agents.remove(target)
target_cell.state = 0
current_cell = matrix.get_cell(self.x, self.y)
current_cell.state = 0
self.x, self.y = nx, ny
target_cell.state = self.id
def transform(self, matrix: Matrix):
pass
def release(self, matrix: Matrix):
pass
def die(self, matrix: Matrix):
self.alive = False
cell = matrix.get_cell(self.x, self.y)
cell.state = dead
def evaluate_cell(self, matrix: Matrix):
pass
def fitness(self, matrix: Matrix, population: "Population"):
self.turn += 1
if not self.alive:
self.energy = max(0, self.energy - self.costs * self.turn)
return
if random.random() < perc_d_cons:
self.die(matrix)
self.energy -= self.costs
return
best_dx, best_dy = 0, 0
best_value = -float("inf")
has_producer_target = False
empty_moves = []
for dx, dy in ((-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)):
nx, ny = self.x + dx, self.y + dy
if 0 <= nx < matrix.n and 0 <= ny < matrix.n:
cell = matrix.get_cell(nx, ny)
if cell.state > 1:
agent = population.agents.get_by_id(cell.state)
if agent and agent.type == producer:
value = agent.energy
if value > best_value:
best_value, best_dx, best_dy = value, dx, dy
has_producer_target = True
elif cell.state == 0:
empty_moves.append((dx, dy))
if has_producer_target:
self.absorb(matrix, population, best_dx, best_dy)
else:
if empty_moves:
dx, dy = random.choice(empty_moves)
self.move(matrix, dx, dy)
else:
pass
self.energy -= self.costs
# agents/population.py
# 27-10-2025
from agents.agents import Agent
from agents.producer import Producer
from agents.consumer import Consumer
from matrix.matrix import Matrix
from vars.vars import population_path, dead, producer, consumer
import random
import pickle
import os
# 28-10-2025
from agents.agentstore import AgentStore
class Population:
def __init__(self, matrix: Matrix, count=2):
self.matrix = matrix
self.agents = AgentStore()
self.count = count
def addsort_agent(self, agent: Agent):
self.agents.add(agent)
def save(self, path=population_path):
data = {
"count": self.count,
"agents": self.agents
}
with open(path, "wb") as f:
pickle.dump(data, f)
def load(self, path=population_path):
if not os.path.exists(path):
self.agents = AgentStore()
self.count = 0
return
with open(path, "rb") as f:
data = pickle.load(f)
self.agents = AgentStore()
self.count = data.get("count", 0)
for agent in data.get("agents", []):
self.agents.add(agent)
ids = [agent.id for agent in self.agents]
self.count = max(ids, default=-1) + 1
def load_into_matrix(self, matrix: Matrix):
for row in matrix.grid:
for cell in row:
cell.state = 0
for agent in self.agents:
if 0 <= agent.x < matrix.n and 0 <= agent.y < matrix.n:
if agent.alive:
matrix.grid[agent.x][agent.y].state = agent.id
else:
matrix.grid[agent.x][agent.y].state = dead
def spawn_producer(self):
avg = self.matrix.average_energy()
for i in range(self.matrix.n):
for j in range(self.matrix.n):
cell = self.matrix.grid[i][j]
cell_energy = cell.contents[0].energy if cell.contents else 0.0
if cell_energy > avg * 2 and cell.state == 0:
if random.random() < 0.8:
x, y = i, j
else:
rx = random.randint(0, self.matrix.n - 1)
ry = random.randint(0, self.matrix.n - 1)
if self.matrix.grid[rx][ry].state == 0:
x, y = rx, ry
else:
x, y = i, j
p = Producer(
x, y,
energy=cell_energy * 0.9,
speed=0,
costs=max(1, avg * 0.5),
id=self.count,
producer_factor=max(1, int(avg // 2))
)
self.matrix.grid[x][y].state = p.id
self.count += 1
self.addsort_agent(p)
if cell.contents:
cell.contents[0].energy = 0
def spawn_consumer(self):
avg = self.matrix.average_energy()
stats = self.agents.stats()
n_producers = stats.get(producer, 0)
n_consumers = stats.get(consumer, 0)
to_spawn = (n_producers // 3) - n_consumers #door
if to_spawn > 0:
for _ in range(to_spawn):
rx = random.randint(0, self.matrix.n - 1)
ry = random.randint(0, self.matrix.n - 1)
cell = self.matrix.grid[rx][ry]
cell_energy = cell.contents[0].energy if cell.contents else 0.0
if cell.state == 0:
c = Consumer(
rx, ry,
energy=cell_energy * 0.9,
speed=1,
costs=max(1, avg * 2),
id=self.count,
turn=0
)
cell.state = c.id
self.count += 1
self.addsort_agent(c)
else:
continue
def cleanup_dead(self):
if random.random() < 0.05:
survivors = AgentStore()
for agent in self.agents:
if not agent.alive and agent.energy <= 0:
cell = self.matrix.get_cell(agent.x, agent.y)
cell.state = 0
else:
survivors.add(agent)
self.agents = survivors
else:
for agent in list(self.agents):
if not agent.alive and agent.energy <= 0:
cell = self.matrix.get_cell(agent.x, agent.y)
cell.state = 0
self.agents.remove(agent)
def run_fitness_cycle(self):
for agent in self.agents:
if agent.type == producer:
agent.fitness(self.matrix, agent.x, agent.y)
elif agent.type == consumer:
agent.fitness(self.matrix, self)
def run(self):
self.cleanup_dead()
self.run_fitness_cycle()
self.spawn_producer()
self.spawn_consumer()
def print_matrix(self):
os.system('cls' if os.name == 'nt' else 'clear')
for i in range(self.matrix.n):
row_repr = []
for j in range(self.matrix.n):
cell = self.matrix.get_cell(i, j)
if cell.state == 0:
energy = cell.contents[0].energy if cell.contents else 0
row_repr.append(f"{energy:5.1f}")
elif cell.state == dead:
row_repr.append(" * ")
else:
agent_id = cell.state
agent = self.agents.get_by_id(agent_id)
if agent is None:
row_repr.append(" ? ")
else:
if agent.type == producer:
row_repr.append(" P ")
else:
row_repr.append(" N ")
print(" ".join(row_repr))
Energy cycle → distribution and flow of energy across cells.
# timeenergy/time_energy.py
# 26-10-2025
import os
from collections import deque
from typing import Deque
from vars.vars import energy_path, timeframe, volatility_path
import statistics
class TimeEnergy:
def __init__(self, maxcount: int = 100):
self.values: Deque[float] = deque(maxlen=maxcount)
self.maxcount: int = maxcount
self.backup: str = energy_path
def add(self, value: float):
self.values.append(float(value))
def save(self):
os.makedirs(os.path.dirname(self.backup), exist_ok=True)
with open(self.backup, "w") as f:
for v in self.values:
f.write(f"{v}\n")
def load(self):
if os.path.exists(self.backup):
with open(self.backup, "r") as f:
lines = f.readlines()
vals = [float(line.strip()) for line in lines if line.strip()]
self.values = deque(vals[-self.maxcount:], maxlen=self.maxcount)
def volatility(self) -> float:
if len(self.values) < 2:
return 0.0
window = list(self.values)[-timeframe:] if len(self.values) >= timeframe else list(self.values)
if len(window) < 2:
return 0.0
return statistics.pstdev(window)
def savevol(self):
vol = self.volatility()
dirname = os.path.dirname(volatility_path)
if dirname:
os.makedirs(dirname, exist_ok=True)
with open(volatility_path, "a") as f:
f.write(f"{vol}\n")
return vol
def __repr__(self):
return f"TimeEnergy(values={self.values})"
Main → orchestrates execution and connects all scripts.
# main.py
# 26-10-2025
import threading
import time
import os
from matrix.matrix import Matrix
from matrix.cell import Cell, CellContent
from vars.vars import backup_path, mc_timeenergy, n_matrix, oasi, population_path, linkw
from timeenergy.time_energy import TimeEnergy
import random
# 27-10-2025
from agents.population import Population
# 29-10-2025
import requests, re
# 30-10-2025
from vars.vars import json_path
from datetime import datetime
def backup_data(m, pop, backup_path, population_path):
backup_dir = os.path.dirname(backup_path)
suffix = datetime.now().strftime("%H_%M")
matrix_file = os.path.join(backup_dir, f"matrix_{suffix}.pkl")
population_file = os.path.join(backup_dir, f"population_{suffix}.pkl")
m.save_pickle(matrix_file)
pop.save(population_file)
for link, target in [(backup_path, matrix_file), (population_path, population_file)]:
if os.path.islink(link) or os.path.exists(link):
os.remove(link)
os.symlink(os.path.basename(target), link)
def distribute_spot(matrix, cx, cy, energy, radius):
n = matrix.n
total_weight = 0.0
cells = []
for i in range(max(0, cx - radius), min(n, cx + radius + 1)):
for j in range(max(0, cy - radius), min(n, cy + radius + 1)):
dx = i - cx
dy = j - cy
dist2 = dx * dx + dy * dy
if dist2 <= radius * radius:
dist = dist2 ** 0.5
w = radius - dist
if w > 0:
cells.append((i, j, w))
total_weight += w
if total_weight > 0:
for i, j, w in cells:
quota = energy * (w / total_weight)
cell = matrix.grid[i][j]
if cell.contents:
quota_per_content = quota / len(cell.contents)
for content in cell.contents:
content.energy += quota_per_content
def loop_energy(te: TimeEnergy, matrix: Matrix, lock, interval=10):
spots = [(random.randint(0, matrix.n-1), random.randint(0, matrix.n-1)) for _ in range(oasi)]
k = 3
radius = max(1, int(matrix.n / ((oasi ** 0.5) * k)))
while True:
if random.random() < 0.05:
if random.random() < 0.01:
headers = {
"User-Agent": "Mozilla/5.0",
"Connection": "close"
}
try:
with requests.get(linkw, headers=headers, timeout=5) as response: #oracle
match = re.search(r'\\"usd_market_cap\\":([0-9\.]+)', response.text)
if match:
value = max(0.0, random.gauss(float(match.group(1)), 5.0))
else:
raise ValueError()
except (requests.exceptions.RequestException, ValueError) as e:
value = max(0.0, random.gauss(10000, 5.0))
else:
value = max(0.0, random.gauss(10000, 5.0))
else:
value = max(0.0, random.gauss(50000, 2.0))
te.add(value)
te.save()
te.savevol()
n_cells = matrix.n * matrix.n
base_quota = (value * 0.1) / n_cells
spot_energy = value * 0.9
with lock:
for row in matrix.grid:
for cell in row:
for content in cell.contents:
content.energy += base_quota
energy_per_spot = spot_energy / oasi
for cx, cy in spots:
distribute_spot(matrix, cx, cy, energy_per_spot, radius)
values = te.values
if len(values) > 1:
mean_val = sum(values) / len(values)
std_val = te.volatility()
vol_rel = (std_val / mean_val) if mean_val > 0 else 0.0
else:
vol_rel = 0.0
for idx, (cx, cy) in enumerate(spots):
if random.random() < min(1.0, vol_rel * 2):
spots[idx] = (random.randint(0, matrix.n-1), random.randint(0, matrix.n-1))
time.sleep(interval)
def loop_run(pop: Population, lock, interval=10):
while True:
with lock:
pop.run()
pop.matrix.save_as_json(pop, path=json_path)
time.sleep(interval)
def main():
te = TimeEnergy(mc_timeenergy)
te.load()
if os.path.exists(backup_path):
m = Matrix.load_pickle(backup_path)
else:
m = Matrix(n_matrix)
pop = Population(m)
if os.path.exists(population_path):
pop.load(population_path)
matrix_lock = threading.Lock()
t0 = threading.Thread(target=loop_energy, args=(te, m, matrix_lock, 2), daemon=True)
t0.start()
t1 = threading.Thread(target=loop_run, args=(pop, matrix_lock, 1), daemon=True)
t1.start()
while True:
backup_data(m, pop, backup_path, population_path)
te.save()
time.sleep(60)
if __name__ == "__main__":
main()
# vars/vars.py
# 26-10-2025
backup_path = "/home/bitnami/tconn.online/backup/matrix.pkl"
energy_path = "/home/bitnami/tconn.online/backup/energy.pkl"
volatility_path = "/home/bitnami/tconn.online/backup/volatily.pkl"
population_path = "/home/bitnami/tconn.online/backup/population.pkl"
colors = {
0: {"desc": "VOID"},
1: {"desc": "SUN"},
}
mc_timeenergy = 360
timeframe = 6
n_matrix = 64
oasi = 5
# 27-10-2025
producer = 1
consumer = 2
dead = 1
perc_d_pro = 0.01
# 28-10-2025
perc_d_cons = 0.01
# 30-10-2025
json_path = "/opt/bitnami/wordpress/matrix.json"
png_path = "/opt/bitnami/wordpress/matrix.png"
# 02-11-2025
linkw = "https://pump.fun/coin/5KfqXLAUq9dVZx6hkKEJteno6GtfoA7idv2iWNtwpump"