Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

11.9 KB
Raw Blame
#!/usr/bin/env python3
"""Original ASCII portraits for the gallery, inspired by terminal-art traditions.

These are new drawings, not copied cowsay/Joan Stark/Nyan Cat assets.
Six poses per creature: two calm, two playful, two asleep. % = eye, ? = mouth.
Everything emitted is printable ASCII. See prototype/habitat/CREATURE_GALLERY.md.
"""
from pathlib import Path
import json

ROOT = Path(__file__).resolve().parents[1]
COLS, ROWS = 25, 9
portraits = []

def add(name, lines, alternate, play_a, play_b, sleep_a, sleep_b):
    base = lines.splitlines()
    assert len(base) <= ROWS
    base += [''] * (ROWS - len(base))
    poses = [base]
    for patch in (alternate, play_a, play_b, sleep_a, sleep_b):
        pose = base.copy()
        for row, value in patch.items():
            pose[row] = value
        poses.append(pose)
    for pose in poses:
        for line in pose:
            assert len(line) <= COLS, (name, len(line), line)
            assert all(32 <= ord(c) <= 126 for c in line)
        assert sum(row.count('%') for row in pose) == 2, (name, pose)
    portraits.append((name, poses))

add('Miso', r'''
      /\       /\
     /  \_____/  \
    (   %     %   )
    (=     ?     =)
     /           \__
    /|           |  )
   (_|____/ \____|_/''',
    {1:"      /\\_____/  \\", 5:"     /           \\   )", 6:"    /|           |__/", 7:"   (_|____/ \\____|)"},
    {0:'         *', 1:"      /\\       /\\", 2:"     /  \\_____/  \\", 3:"    (   %     %   )", 4:"    (=     ?     =)", 5:"   / /           \\ \\", 6:"  (_/|           |\\_)", 7:"     |___/   \\___|", 8:'        .     .'},
    {0:'', 1:"      /\\       /\\", 2:"     /  \\_____/  \\", 3:"  \\ (   %     %   ) /", 4:"   \\(=     ?     =)/", 5:"     /           \\", 6:"     |           |", 7:"     |___/   \\___|", 8:'       *       *'},
    {0:'',1:'',2:'',3:"     /\\____/\\",4:"    ( %    % )___",5:"    (=  ?  =)    `.",6:"     (_________   )",7:"      `--------\\_/"},
    {0:'',1:'',2:'',3:"     /\\____/\\",4:"    ( %    % )____",5:"    (=  ?  =)     )",6:"     (_________  /",7:"      `--------\\/"})

add('Hopper', r'''
      .--.   .--.
     ( %  ) (  % )
    / `--'   `--' \
   (       ?       )
    \  ._______.  /
     / /       \ \
   _/ /         \ \_
  (___)         (___)''',
    {4:"   (       ?       )",5:"    \\  ._______.  /",6:"    / /         \\ \\",7:"   (_/           \\_)",8:"     )           ("},
    {0:'     *           *',1:'      .--.   .--.',2:'     ( %  ) (  % )',3:"    / `--'   `--' \\",4:'   (       ?       )',5:"    \\  ._______.  /",6:"   _/ /       \\ \\_",7:"  (__/         \\__)",8:''},
    {0:'      .--.   .--.',1:'     ( %  ) (  % )',2:"    / `--'   `--' \\",3:'   (       ?       )',4:"    \\  ._______.  /",5:"     / /       \\ \\",6:"     | |       | |",7:"     \\_)       (_/",8:'    .             .'},
    {0:'',1:'',2:'',3:'      .--.   .--.',4:'     ( %  ) (  % )',5:"    / `--'   `--' \\",6:'   (       ?       )',7:"    \\_____________/",8:"   (___)       (___)"},
    {0:'',1:'',2:'',3:'      .--.   .--.',4:'     ( %  ) (  % )',5:"   /  `--'   `--'  \\",6:'  (        ?        )',7:"   \\_______________/",8:"   (___)       (___)"})

add('Pip', r'''       /\   /\
      /  \ /  \
      |  | |  |
      |  |_|  |
     /  %   %  \
     \    ?    /
     /|       |\
    (_|__u_u__|_)
''',
    {0:"       /\\",1:"      /  \\  __",2:"      |  | / /",3:"      |  |/ /"},
    {0:"       /\\   /\\",1:"      /  \\ /  \\",2:"      |  |_|  |",3:"     /  %   %  \\",4:"     \\    ?    /",5:"   _/ /       \\ \\_",6:"  (__/|       |\\__)",7:"      |__u_u__|",8:'       .   .'},
    {0:"      /\\     /\\",1:"     /  \\   /  \\",2:"     \\   \\_/   /",3:"     /  %   %  \\",4:"     \\    ?    /",5:"     /|       |\\",6:"    (_|       |_)",7:"      |__u_u__|",8:'      *     *'},
    {0:'',1:'',2:"      ____  ____",3:"     /  __\\/__  \\",4:"     \\ ( %  % ) /",5:"      \\(  ?   )/",6:"      /       \\",7:"     (___u_u___)"},
    {0:'',1:'',2:"      ____  ____",3:"     /  __\\/__  \\",4:"     \\ ( %  % ) /",5:"      \\(  ?   )/",6:"     /         \\",7:"    (____u_u____)"})

add('Rook', r'''        .---.
       /     \
       | % % |
       |  ?  |
      /|     |\
     / |     | \
     \_|     |_/
       / ___ \
      (_/   \_)''',
    {4:"      /|     |\\__",5:"     / |     |___)",6:"     \\_|     |",7:"       / ___ \\",8:"      (_/   \\_)"},
    {0:'         .---.',1:"        /     \\",2:'        | % % |',3:"    __  |  ?  |",4:"   (  \\_|     |\\",5:"    \\___|     | \\",6:"        |     |_/ ",7:"        / ___ \\",8:"       (_/   \\_)"},
    {0:'       .---.',1:"      /     \\",2:'      | % % |',3:"      |  ?  |  __",4:"     /|     |_/  )",5:"    / |     |___/",6:"    \\_|     |",7:"      / ___ \\",8:"     (_/   \\_)"},
    {0:'',1:'        .---.',2:"       /     \\",3:'       | % % |',4:'       |  ?  |',5:"      /|     |\\",6:"     ( |     | )",7:"      \\|_____|/",8:"      (___ ___)"},
    {0:'',1:'        .---.',2:"       /     \\",3:'       | % % |',4:'       |  ?  |',5:"     / |     | \\",6:"    (  |     |  )",7:"     \\_|_____|_/",8:"      (___ ___)"})

add('Moo', r'''
      /)       (\
   __/ \_______/ \__
  (___  %     %  ___)
      |  _____  |
      | (o   o) |
      |  \_?_/  |
      /         \
     (____/ \____)''',
    {2:"  ___/ \\_______/ \\___",3:" (____  %     %  ____)",6:"      |  ( ? )  |"},
    {0:'     *         *',1:"      /)       (\\",2:"   __/ \\_______/ \\__",3:"  (___  %     %  ___)",4:"      |  _____  |",5:"      | (o   o) |",6:"      |  \\_?_/  |",7:"    __/         \\__",8:"   (___/     \\___)"},
    {0:'       *   *',1:"     /)         (\\",2:"  __/ \\_________/ \\__",3:" (____  %     %  ____)",4:"      |  _____  |",5:"      | (o   o) |",6:"      |  ( ? )  |",7:"      /         \\",8:"     (____/ \\____)"},
    {0:'',1:'',2:"      /)       (\\",3:"   __/ \\_______/ \\__",4:"  (___  %     %  ___)",5:"      |  _____  |",6:"      | (o ? o) |",7:"       \\_______/",8:"     (____/ \\____)"},
    {0:'',1:'',2:"      /)       (\\",3:"  ___/ \\_______/ \\___",4:" (____  %     %  ____)",5:"      |  _____  |",6:"      | (o ? o) |",7:"       \\_______/",8:"     (____/ \\____)"})

add('Boo', r'''
       .-------.
     .'         '.
    /   %     %   \
   |       ?       |
   |               |
   |               |
    \_/\___/\___/\_/
''',
    {7:"    \\___/\\___/\\___/"},
    {0:'     *         *',1:'       .-------.',2:"     .'         '.",3:"  __/   %     %   \\__",4:" (         ?         )",5:"  \\                 /",6:"   |               |",7:"    \\_/\\___/\\___/\\_/",8:''},
    {0:'          *',1:'       .-------.',2:"     .'         '.",3:"   _/   %     %   \\_",4:"  (        ?        )",5:"   |               |",6:"   |               |",7:"    \\___/\\___/\\___/",8:''},
    {0:'',1:'',2:'',3:'       .-------.',4:"     .'  %   %  '.",5:"    /      ?      \\",6:"   |               |",7:"    \\_/\\___/\\___/\\_/"},
    {0:'',1:'',2:'',3:'       .-------.',4:"     .'  %   %  '.",5:"   /       ?       \\",6:"  |                 |",7:"   \\__/\\___/\\___/\\__/"})

add('Sprout', r'''            .-.
      .-.   \ /
      \ /    |
       \_____|
             |  ()
      .------|---.
      |  %    %  |
      |    ?     |
      '----------' ''',
    {0:'           .-.',1:"     .-.   \\ /",2:"     \\ /    |",3:"      \\_____|",4:"            |   ()",5:"      .-----|----."},
    {0:'        .-@-.',1:'       (@ @ @)',2:"        '-@-'",3:"     (\\   |   /)",4:"      \\___|__/",5:"      .---|------.",6:"      |  %    %  |",7:"      |    ?     |",8:r"      '----------'"},
    {0:'        .-@-.    *',1:'       (@ @ @)',2:"        '-@-'",3:"    (\\    |    /)",4:"     \\____|___/",5:"      .---|------.",6:"      |  %    %  |",7:"      |    ?     |",8:r"      '----------'"},
    {0:'',1:'',2:"      .----.",3:"     ( )    \\  ()",4:"             | /",5:"      .------|---.",6:"      |  %    %  |",7:"      |    ?     |",8:r"      '----------'"},
    {0:'',1:'',2:"       .---.",3:"      ( )   \\  ()",4:"             | /",5:"      .------|---.",6:"      |  %    %  |",7:"      |    ?     |",8:r"      '----------'"})

add('Drift', r'''
       .-------.
     .' . . . . '.
    /   %     %   \
   (       ?       )
    '---.---.---.-'
       /  |  |  \
       \  |  |  /
        J U  J U''',
    {1:'        .-----.',2:"      .' . . . '.",3:"     /  %     %  \\",4:"    (      ?      )",5:r"     '--.---.---.'",6:"        \\  |  /",7:"        /  |  \\",8:"        U  J  U"},
    {0:'     o          o',1:'        .-----.',2:"      .' . . . '.",3:"     /  %     %  \\",4:"    (      ?      )",5:r"     '--.---.---.'",6:"     __/  | |  \\__",7:"    (   __/ \\__   )",8:"       (       )"},
    {0:'          o',1:'       .-------.',2:"     .' . . . . '.",3:"    /   %     %   \\",4:"   (       ?       )",5:r"    '---.---.---.-'",6:"       /  |  |  \\",7:"      (  /    \\  )",8:"       ) U    J ("},
    {0:'',1:'',2:'       .-------.',3:"     .'  %   %  '.",4:"    (      ?      )",5:r"     '---.---.---'",6:"        / | | \\",7:"        U U J U",8:''},
    {0:'',1:'',2:'       .-------.',3:"     .'  %   %  '.",4:"   (       ?       )",5:r"    '----.---.----'",6:"        \\ | | /",7:"         JUUJ",8:''})

add('Bolt', r'''           o
           |
      .----'----.
      |  %   %  |
      |   [?]   |
    o-+---------+-o
      |   [=]   |
      '----+----'
          / \ ''',
    {0:'            o',1:"           /",5:"    o-+---------+--o"},
    {0:'           *',1:'           |',2:"   o  .----'----.",3:"   |  |  %   %  |",4:"   \\__|   [?]   |",5:"      +---------+--o",6:"      |   [=]   |",7:r"      '----+----'",8:"         _/ \\_"},
    {0:'           o',1:'           |',2:"      .----'----.  o",3:"      |  %   %  |  |",4:"      |   [?]   |__/",5:"   o--+---------+",6:"      |   [=]   |",7:r"      '----+----'",8:"          /\\"},
    {0:'',1:'',2:"      .----o----.",3:"      |  %   %  |",4:"      |   [?]   |",5:"      +---------+",6:"     o|   [-]   |o",7:r"      '----+----'",8:"          / \\"},
    {0:'',1:'',2:"      .----o----.",3:"      |  %   %  |",4:"      |   [?]   |",5:"      +---------+",6:"     o|   [ ]   |o",7:r"      '----+----'",8:"          / \\"})

add('Echo', r'''
   /\               /\
  /  \   /\_/\     /  \
 /    \_(%   %)___/    \
(        \ ? /          )
 \  /\    \_/    /\    /
  \/  \   / \   /  \__/
       \_/   \_/
''',
    {1:'',2:"        /\\_/\\",3:"  /\\___(%   %)___/\\",4:" /      \\ ? /      \\",5:"(   /\\   \\_/   /\\   )",6:" \\_/  \\  / \\  /  \\_/",7:"       \\/   \\/"},
    {0:"  /\\                 /\\",1:" /  \\    /\\_/\\      /  \\",2:"/    \\__(%   %)____/    \\",3:"\\        \\ ? /          /",4:" \\  /\\    \\_/    /\\    /",5:"  \\/  \\   / \\   /  \\__/",6:"       \\_/   \\_/",7:'',8:''},
    {0:'',1:'',2:"        /\\_/\\",3:"       (%   %)",4:"    ___/\\ ? /\\___",5:"   /     \\_/     \\",6:"  / /\\   / \\   /\\ \\",7:"  \\/  \\_/   \\_/  \\/",8:''},
    {0:'',1:'',2:"        /\\_/\\",3:"       (%   %)",4:"      / \\ ? / \\",5:"     /\\  \\_/  /\\",6:"     \\ \\ / \\ / /",7:"      \\ V   V /",8:r"       '-----'"},
    {0:'',1:'',2:"        /\\_/\\",3:"       (%   %)",4:"     /  \\ ? /  \\",5:"    /\\   \\_/   /\\",6:"    \\ \\  / \\  / /",7:"     \\  V   V  /",8:r"      '-------'"})

assert len(portraits) == 10
dest = ROOT / 'main/ui/habitat/creature_art.inc'
with dest.open('w') as out:
    out.write('// Generated by gen_creature_art.py; original drawings. Printable ASCII only.\n')
    out.write('static const char *const names[HT_ORIGINAL_CREATURES] = {')
    out.write(','.join(json.dumps(name) for name, _ in portraits))
    out.write('};\nstatic const char art[HT_ORIGINAL_CREATURES][6][HT_CREATURE_ROWS][HT_CREATURE_COLS+1] = {\n')
    for name, poses in portraits:
        out.write('    { // ' + name + '\n')
        for pose in poses:
            out.write('        {\n')
            for line in pose:
                out.write('            ' + json.dumps(line.ljust(COLS)) + ',\n')
            out.write('        },\n')
        out.write('    },\n')
    out.write('};\n')
print(f'{len(portraits)} original creatures, {len(portraits)*6} poses, {COLS}x{ROWS} cells')