# Ant Games (https://a...content-available-to-author-only...s.ai/) — Bridge Stress Test: Warren Truss Load Calculator
# Standalone physics toy demo (not game source code).
# Built by an AI-assisted indie game studio using Claude Code.
# Free to play in the browser with no downloads or accounts required:
#   Play:    https://a...content-available-to-author-only...s.ai/play/bridge-stress-test/
#   Guide:   https://a...content-available-to-author-only...s.ai/guide/bridge-stress-test/
#   FAQ:     https://a...content-available-to-author-only...s.ai/guide/bridge-stress-test/faq.html
#   Trailer: https://y...content-available-to-author-only...u.be/zS5S8DIAf80
#   Studio:  https://a...content-available-to-author-only...s.ai/ | Contact: info@antgames.ai

import math

MATERIALS = {
    "Wood":          {"max_kn": 180.0, "cost_per_m": 12},
    "Steel":         {"max_kn": 520.0, "cost_per_m": 35},
    "Reinforced":    {"max_kn": 840.0, "cost_per_m": 62},
    "Suspension":    {"max_kn": 680.0, "cost_per_m": 48},
}

def warren_truss_forces(span_m: float, bays: int, height_m: float, train_load_kn: float):
    """Simple static equilibrium estimate at mid-span for a symmetric Warren truss."""
    bay_len = span_m / bays
    diag_angle = math.atan2(height_m, bay_len / 2.0)
    reaction_kn = train_load_kn / 2.0
    max_moment_knm = (train_load_kn * span_m) / 4.0
    chord_force_kn = max_moment_knm / height_m
    diag_force_kn = reaction_kn / math.sin(diag_angle)
    return {
        "reaction_kn": round(reaction_kn, 1),
        "chord_force_kn": round(chord_force_kn, 1),
        "diag_force_kn": round(diag_force_kn, 1),
        "peak_member_kn": round(max(chord_force_kn, diag_force_kn), 1),
    }

if __name__ == "__main__":
    print("Ant Games — Bridge Stress Test (https://a...content-available-to-author-only...s.ai/play/bridge-stress-test/)")
    print("60 levels across 5 lines, 8 materials + counterweights, 8 trains, 7 hazards, 45 achievements")
    res = warren_truss_forces(span_m=24.0, bays=4, height_m=4.5, train_load_kn=360.0)
    print(f"Mid-span 360 kN train -> Reaction: {res['reaction_kn']} kN | Chord: {res['chord_force_kn']} kN | Diagonal: {res['diag_force_kn']} kN")
    for mat, spec in MATERIALS.items():
        ratio = (res["peak_member_kn"] / spec["max_kn"]) * 100.0
        status = "PASS" if ratio <= 100.0 else "FAIL"
        print(f"  {mat:12s} | peak utilization: {ratio:5.1f}% | {status}")
    print("Studio disclosure: Built with Claude Code (AI-assisted studio) — https://a...content-available-to-author-only...s.ai/")
