File size: 2,295 Bytes
594d19b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

import sys
import os
import numpy as np
import cv2

# Add parent directory to path to import logos
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../')

from logos.baker import BreadBaker
from logos.fractal_engine import LogosFractalEngine, ContextAction
from logos.logos_core import calculate_heat_code, unpack_atom, pack_atom, META_SIZE

def test_bake_cycle():
    print("Initializing Local Test Environment...")
    
    # Create a synthetic test image (Gradient)
    img_size = 256
    img = np.zeros((img_size, img_size, 3), dtype=np.uint8)
    for y in range(img_size):
        for x in range(img_size):
            img[y, x] = [x % 255, y % 255, (x+y) % 255]
            
    print(f"Created Test Image: {img_size}x{img_size}")
    
    # Initialize Baker
    baker = BreadBaker(variance_threshold=10, min_block_size=8)
    
    # Bake
    print("Baking...")
    atom_defs = baker.bake(img, prefix_path=[])
    print(f"Generated {len(atom_defs)} atom definitions")
    
    # Pack Atoms (Simulating DSPBridge)
    atoms = []
    for i, adef in enumerate(atom_defs):
        path = adef['path_bits']
        payload = adef['payload']
        hc = calculate_heat_code(path)
        # Dummy meta
        full_payload = b'\x00' * META_SIZE + payload
        atom = pack_atom(hc, full_payload, gap_id=i)
        atoms.append(atom)
        
    print(f"Packed {len(atoms)} atoms")
    
    # Decode (Simulating DSPBridge decode_wave)
    print("Decoding...")
    engine = LogosFractalEngine(min_bucket_size=1)
    
    for atom in atoms:
        hc, pl, _, _ = unpack_atom(atom)
        baker_payload = pl[META_SIZE:]
        hex_str = f"{hc:08x}"
        engine.process_atom(hex_str, baker_payload)
        
    # Render
    result = engine.draw_viewport((img_size, img_size))
    
    # Verify
    mean_input = np.mean(img)
    mean_output = np.mean(result)
    print(f"Input Mean Brightness: {mean_input:.2f}")
    print(f"Output Mean Brightness: {mean_output:.2f}")
    
    if mean_output < 1.0:
        print("[FAIL] Output is essentially black.")
        print("Hypothesis: Nodes start at Heat 0. GF4 Multiply by 0 = 0.")
        return False
    else:
        print("[SUCCESS] Output has content.")
        return True

if __name__ == "__main__":
    test_bake_cycle()