```python
import bpy, math, random
from mathutils import Vector

# ============================================================
# YGG-1 compact deep-space survey spacecraft
# ============================================================

# Clear scene
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)
for datablocks in (bpy.data.meshes, bpy.data.curves, bpy.data.materials, bpy.data.cameras, bpy.data.lights):
    pass

# ----------------------------
# Materials
# ----------------------------
def mat_principled(name, color, metallic=0.0, roughness=0.4, emission=None, emission_strength=0.0,
                   transmission=0.0, alpha=1.0):
    m = bpy.data.materials.new(name)
    m.diffuse_color = (*color, alpha)
    m.use_nodes = True
    bs = m.node_tree.nodes.get("Principled BSDF")
    bs.inputs["Base Color"].default_value = (*color, 1)
    bs.inputs["Metallic"].default_value = metallic
    bs.inputs["Roughness"].default_value = roughness
    if "Transmission Weight" in bs.inputs:
        bs.inputs["Transmission Weight"].default_value = transmission
    if emission:
        bs.inputs["Emission Color"].default_value = (*emission, 1)
        bs.inputs["Emission Strength"].default_value = emission_strength
    bs.inputs["Alpha"].default_value = alpha
    if alpha < 1:
        m.surface_render_method = 'DITHERED'
    return m

pearl = mat_principled("Pearl White Ceramic Composite", (0.72, 0.77, 0.79), metallic=0.18, roughness=0.25)
pearl2 = mat_principled("Warm Ceramic Highlight", (0.92, 0.90, 0.82), metallic=0.08, roughness=0.3)
gunmetal = mat_principled("Dark Gunmetal Structure", (0.035, 0.055, 0.075), metallic=0.72, roughness=0.28)
heat = mat_principled("Heat Resistant Graphite", (0.012, 0.018, 0.026), metallic=0.45, roughness=0.22)
window = mat_principled("Smoked Transparent Canopy", (0.015, 0.055, 0.075), metallic=0.18, roughness=0.12,
                        emission=(0.01, 0.05, 0.08), emission_strength=0.25, transmission=0.65, alpha=0.52)
amber = mat_principled("Warm Amber Console", (0.8, 0.18, 0.025), emission=(1.0, 0.16, 0.015), emission_strength=5.0)
cyan = mat_principled("Maglev Cyan Violet", (0.03, 0.25, 0.8), metallic=0.1, roughness=0.18,
                      emission=(0.02, 0.24, 1.0), emission_strength=7.0)
violet = mat_principled("Field Violet", (0.16, 0.03, 0.55), metallic=0.1, roughness=0.2,
                        emission=(0.24, 0.025, 0.9), emission_strength=5.0)
engine = mat_principled("Contained White Blue Engine", (0.45, 0.75, 1.0), metallic=0.05, roughness=0.14,
                        emission=(0.55, 0.85, 1.0), emission_strength=18.0)
sensor = mat_principled("Sensor Glass", (0.015, 0.12, 0.18), metallic=0.25, roughness=0.1,
                        emission=(0.01, 0.12, 0.22), emission_strength=1.5)
textmat = mat_principled("Designation Marking", (0.55, 0.68, 0.72), metallic=0.35, roughness=0.28)

# ----------------------------
# Helpers
# ----------------------------
def smooth(obj):
    if obj.type == 'MESH':
        for p in obj.data.polygons:
            p.use_smooth = True

def bevel(obj, amount=0.15, segments=3):
    mod = obj.modifiers.new("Engineered edge radii", 'BEVEL')
    mod.width = amount
    mod.segments = segments
    mod.limit_method = 'ANGLE'
    return obj

def cube_obj(name, loc, scale, material, bevel_amt=0.0):
    bpy.ops.mesh.primitive_cube_add(location=loc)
    o = bpy.context.object
    o.name = name
    o.dimensions = scale
    bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
    o.data.materials.append(material)
    if bevel_amt:
        bevel(o, bevel_amt, 3)
    return o

def uv_obj(name, loc, scale, material, segments=32, rings=16):
    bpy.ops.mesh.primitive_uv_sphere_add(segments=segments, ring_count=rings, location=loc)
    o = bpy.context.object
    o.name = name
    o.scale = scale
    bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
    o.data.materials.append(material)
    smooth(o)
    return o

def ico_obj(name, loc, scale, material, subdivisions=2):
    bpy.ops.mesh.primitive_ico_sphere_add(subdivisions=subdivisions, location=loc)
    o = bpy.context.object
    o.name = name
    o.scale = scale
    bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
    o.data.materials.append(material)
    bevel(o, 0.08, 2)
    smooth(o)
    return o

def beam(name, a, b, width, depth, material, bevel_amt=0.12):
    a, b = Vector(a), Vector(b)
    mid = (a+b)/2
    vec = b-a
    bpy.ops.mesh.primitive_cube_add(location=mid)
    o = bpy.context.object
    o.name = name
    o.dimensions = (width, depth, vec.length)
    o.rotation_mode = 'QUATERNION'
    o.rotation_quaternion = Vector((0,0,1)).rotation_difference(vec.normalized())
    bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
    o.data.materials.append(material)
    if bevel_amt:
        bevel(o, bevel_amt, 4)
    return o

def cyl_between(name, a, b, radius, material, vertices=12):
    a, b = Vector(a), Vector(b)
    vec = b-a
    bpy.ops.mesh.primitive_cylinder_add(vertices=vertices, radius=radius, depth=vec.length,
                                        location=(a+b)/2)
    o = bpy.context.object
    o.name = name
    o.rotation_mode = 'QUATERNION'
    o.rotation_quaternion = Vector((0,0,1)).rotation_difference(vec.normalized())
    o.data.materials.append(material)
    smooth(o)
    return o

def point_light(name, loc, color, energy, radius=1.0):
    data = bpy.data.lights.new(name, 'POINT')
    data.energy = energy
    data.color = color
    data.shadow_soft_size = radius
    o = bpy.data.objects.new(name, data)
    bpy.context.collection.objects.link(o)
    o.location = loc
    return o

# ----------------------------
# Central compact hull
# ----------------------------
uv_obj("Muscular central pressure hull", (0.15, 0, 0), (2.55, 1.38, 1.28), pearl)
uv_obj("Aft power-system mass", (1.55, 0, 0), (1.45, 1.22, 1.14), gunmetal)
ico_obj("Tightly resolved forward hull", (-1.85, 0, 0.02), (1.28, 1.02, 0.88), pearl2, 2)
uv_obj("Narrow nose", (-2.72, 0, 0.04), (0.72, 0.68, 0.59), pearl, 32, 16)

# underside structural keel, not a weapon
cube_obj("Dark lower structural keel", (0.35, 0, -1.05), (3.55, 0.72, 0.30), heat, 0.12)

# rear service boundary
cube_obj("Aft service boundary", (1.72, -1.20, 0), (0.07, 0.035, 1.35), gunmetal, 0.02)
cube_obj("Port service hatch", (0.20, -1.385, -0.32), (0.78, 0.035, 0.46), gunmetal, 0.08)

# ----------------------------
# Small faceted cockpit
# ----------------------------
canopy = uv_obj("Low faceted transparent cockpit canopy", (-1.62, 0, 0.69), (0.98, 0.72, 0.43), window, 16, 8)
# cockpit frame rails
beam("Cockpit port frame", (-2.35,-0.63,0.55), (-1.35,-0.70,0.91), 0.075, 0.08, gunmetal, 0.025)
beam("Cockpit starboard frame", (-2.35,0.63,0.55), (-1.35,0.70,0.91), 0.075, 0.08, gunmetal, 0.025)
# interior seat and console, deliberately small
uv_obj("Compact pilot seat", (-1.50, 0.10, 0.23), (0.26, 0.27, 0.48), heat, 16, 8)
cube_obj("Amber survey console", (-1.84, -0.22, 0.48), (0.13, 0.28, 0.08), amber, 0.025)
point_light("Cockpit amber glow", (-1.85,-0.25,0.52), (1.0,0.12,0.015), 22, 0.5)

# sensors, flush and non-weapon-like
for i, (x,z,s) in enumerate([(-2.48,0.28,0.16), (-1.95,-0.62,0.12), (-0.72,-0.94,0.15)]):
    uv_obj("Flush survey aperture %02d" % i, (x,-0.70 if i != 2 else -1.34,z), (s,0.035,s*0.55), sensor, 16, 8)

# ----------------------------
# Three bent rear-swept wings
# ----------------------------
# Each is built from a short base and a much longer rearward segment.
wing_defs = [
    ("Port",    (1.62,-1.48,0.00), (1.96,-2.66,0.00), (5.72,-5.05,0.00), -1),
    ("Starboard",(1.62,1.48,0.00), (1.96,2.66,0.00), (5.72,5.05,0.00),  1),
    ("Dorsal",  (1.62,0.00,1.38), (1.96,0.00,2.55), (5.72,0.00,4.95),  1),
]

for label, root, elbow, tip, side in wing_defs:
    # magnetic receiver/base, floating from hull
    beam(label+" short armored receiver base", root, elbow, 1.20, 0.90, pearl, 0.18)
    # elbow reinforcement gives broad, smooth engineered bend
    uv_obj(label+" armored elbow", elbow, (0.70,0.70,0.58), pearl, 20, 10)
    # long rearward wing
    beam(label+" long swept propulsion wing", elbow, tip, 1.18, 0.92, pearl, 0.20)
    # dark heat-resistant inset channel running through inner/long segment
    off = Vector((0, -0.01, -0.16)) if label == "Dorsal" else Vector((0,0,-0.16))
    channel_end = Vector(tip) + (Vector(elbow)-Vector(tip)).normalized()*0.35 + off
    channel_start = Vector(elbow) + (Vector(tip)-Vector(elbow)).normalized()*0.22 + off
    beam(label+" recessed propulsion channel", channel_start, channel_end, 0.58, 0.38, heat, 0.10)
    # contained white-blue energy core, inset rather than external flame
    core_start = Vector(elbow) + (Vector(tip)-Vector(elbow)).normalized()*0.40 + off*0.9
    core_end = Vector(tip) + (Vector(elbow)-Vector(tip)).normalized()*0.95 + off*0.9
    beam(label+" contained white blue engine core", core_start, core_end, 0.25, 0.18, engine, 0.06)
    # radiator strips on outside of long segment
    radiator_offset = Vector((0, 0.48*side, 0)) if label != "Dorsal" else Vector((0.48,0,0))
    beam(label+" satin radiator channel", Vector(elbow)+radiator_offset+Vector((0.2,0,0)),
         Vector(tip)+radiator_offset+Vector((-0.65,0,0)), 0.10, 0.06, gunmetal, 0.025)
    # maglev cradle on hull side / top
    cradle_loc = (1.60, -1.05 if label=="Port" else 1.05 if label=="Starboard" else 0,
                  1.02 if label=="Dorsal" else 0)
    cube_obj(label+" recessed emitter cradle", cradle_loc, (0.48,0.34,0.72) if label!="Dorsal" else (0.48,0.72,0.34),
             heat, 0.08)
    # receiver plate at wing root
    plate_loc = Vector(root) + (Vector(elbow)-Vector(root)).normalized()*0.10
    cube_obj(label+" magnetic receiver plate", plate_loc,
             (0.25,0.72,0.60) if label!="Dorsal" else (0.25,0.60,0.72), gunmetal, 0.06)
    # visible empty gap field filaments: terminate before each solid part
    gap_a = Vector(cradle_loc) + (Vector(root)-Vector(cradle_loc)).normalized()*0.20
    gap_b = Vector(root) - (Vector(root)-Vector(cradle_loc)).normalized()*0.20
    axis = (gap_b-gap_a).normalized()
    sidevec = Vector((0,0,1)) if label!="Dorsal" else Vector((0,1,0))
    for j in range(3):
        shift = sidevec * (j-1)*0.17
        cyl_between(label+" suspended maglev filament %d"%j, gap_a+shift, gap_b+shift, 0.025, cyan, 8)
    point_light(label+" engine light", Vector(core_start), (0.25,0.65,1.0), 85, 1.3)
    point_light(label+" maglev field light", (Vector(gap_a)+Vector(gap_b))/2, (0.16,0.1,1.0), 20, 0.45)

# ----------------------------
# YGG-1 designation
# ----------------------------
bpy.ops.object.text_add(location=(-0.55, -1.405, 0.34), rotation=(math.pi/2, 0, 0))
txt = bpy.context.object
txt.name = "YGG-1 serial designation"
txt.data.body = "YGG-1"
txt.data.align_x = 'CENTER'
txt.data.align_y = 'CENTER'
txt.data.size = 0.38
txt.data.extrude = 0.012
txt.data.bevel_depth = 0.004
txt.data.materials.append(textmat)

# Small anodized accent stripe
beam("Anodized port accent", (-1.25,-1.39,0.62), (0.45,-1.39,0.62), 0.055, 0.025, violet, 0.02)

# ----------------------------
# Groundless starfield
# ----------------------------
world = bpy.context.scene.world
world.use_nodes = True
bg = world.node_tree.nodes.get("Background")
bg.inputs["Color"].default_value = (0.0015,0.003,0.009,1)
bg.inputs["Strength"].default_value = 0.025

random.seed(19)
star_mat = mat_principled("Distant stars", (0.5,0.65,1.0), emission=(0.55,0.72,1.0), emission_strength=3.0)
for i in range(180):
    # broad shell around craft, avoiding immediate foreground
    v = Vector((random.uniform(-30,30), random.uniform(-30,30), random.uniform(-22,22)))
    if v.length < 15:
        v.normalize(); v *= random.uniform(17,28)
    r = random.choice([0.012,0.018,0.025,0.035])
    uv_obj("Star_%03d"%i, v, (r,r,r), star_mat, 8, 4)

# ----------------------------
# Lighting and camera
# ----------------------------
# large cool key and restrained warm rim
ld = bpy.data.lights.new("Cool survey key", 'AREA')
ld.energy = 1100
ld.color = (0.48,0.68,1.0)
ld.shape = 'DISK'
ld.size = 8
lo = bpy.data.objects.new("Cool survey key", ld)
bpy.context.collection.objects.link(lo)
lo.location = (-8,-10,10)
lo.rotation_euler = (math.radians(28),0,math.radians(-38))

ld2 = bpy.data.lights.new("Warm ceramic rim", 'AREA')
ld2.energy = 850
ld2.color = (1.0,0.28,0.08)
ld2.size = 5
lo2 = bpy.data.objects.new("Warm ceramic rim", ld2)
bpy.context.collection.objects.link(lo2)
lo2.location = (7,7,5)
lo2.rotation_euler = (math.radians(65),0,math.radians(135))

def look_at(obj, target):
    obj.rotation_euler = (Vector(target)-obj.location).to_track_quat('-Z','Y').to_euler()

cam_data = bpy.data.cameras.new("Presentation Camera")
cam = bpy.data.objects.new("Presentation Camera", cam_data)
bpy.context.collection.objects.link(cam)
cam.location = (-14.5,-17.5,9.2)
cam_data.lens = 52
cam_data.sensor_width = 36
look_at(cam, (1.0,0,0.25))
bpy.context.scene.camera = cam

# ----------------------------
# Render settings
# ----------------------------
scene = bpy.context.scene
scene.render.engine = 'BLENDER_EEVEE_NEXT'
scene.render.resolution_x = 1536
scene.render.resolution_y = 1536
scene.render.resolution_percentage = 100
scene.render.image_settings.file_format = 'PNG'
scene.render.film_transparent = False
scene.render.filepath = "/tmp/ygg1_presentation.png"

scene.view_settings.look = 'AgX - Medium High Contrast'
scene.render.image_settings.color_mode = 'RGBA'

# Slight atmospheric compositing only for cinematic contrast
scene.use_nodes = True
nt = scene.node_tree
nt.nodes.clear()
rl = nt.nodes.new('CompositorNodeRLayers')
gl = nt.nodes.new('CompositorNodeGlare')
gl.glare_type = 'FOG_GLOW'
gl.quality = 'HIGH'
gl.threshold = 1.2
gl.size = 7
comp = nt.nodes.new('CompositorNodeComposite')
nt.links.new(rl.outputs['Image'], gl.inputs['Image'])
nt.links.new(gl.outputs['Image'], comp.inputs['Image'])

# Save complete scene
bpy.ops.wm.save_as_mainfile(filepath="/tmp/YGG-1_survey_ship.blend")
bpy.ops.render.render(write_still=True)
```