""" Test script for Fractal Coordinate Decoder Demonstrates Heat Code → ZoneRect mapping """ import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from logos.fractal_engine import LogosFractalEngine def test_fractal_addressing(): """Test fractal coordinate decoding""" engine = LogosFractalEngine(min_bucket_size=64) # Test canvas size canvas_size = (1024, 768) # Test various heat codes test_cases = [ ("00000000", "All zeros - should map to top-left"), ("FFFFFFFF", "All ones - should map to bottom-right"), ("AAAAAAAA", "Alternating pattern"), ("12345678", "Mixed pattern"), ("80000000", "MSB set - top-right path"), ("40000000", "Second bit set - bottom-left path"), ("C0000000", "Top two bits set - bottom-right path"), ] print("=" * 80) print("Fractal Coordinate Decoder Test") print("=" * 80) print(f"Canvas Size: {canvas_size[0]}x{canvas_size[1]}") print(f"Minimum Bucket Size: 64px") print() for hex_code, description in test_cases: heat_int = int(hex_code, 16) zone_rect = engine.resolve_fractal_address(heat_int, canvas_size) x, y, w, h = zone_rect print(f"Heat Code: {hex_code} ({description})") print(f" -> ZoneRect: x={x:4d}, y={y:4d}, w={w:4d}, h={h:4d}") print(f" -> Center: ({x + w//2}, {y + h//2})") print() # Test bucket coordinate mapping print("=" * 80) print("Bucket Coordinate Mapping Test") print("=" * 80) print(f"Buckets: 16x12 (for 1024x768 canvas with ~64px buckets)") print() num_buckets_x = 16 num_buckets_y = 12 for hex_code, description in test_cases[:5]: # Test first 5 heat_int = int(hex_code, 16) bucket_x, bucket_y = engine.fractal_to_bucket_coords( heat_int, num_buckets_x, num_buckets_y ) print(f"Heat Code: {hex_code}") print(f" -> Bucket: ({bucket_x}, {bucket_y})") print() if __name__ == "__main__": test_fractal_addressing()