AgentSkillsCN

add-material

向 Asciicker 材料系统中新增特定地形材质定义(如泥土、石头、沙子等)。当需要添加新材料、定义地形类型,或扩展材料调色板时,可使用此功能。

SKILL.md
--- frontmatter
name: add-material
description: Add a new terrain material definition (dirt, stone, sand, etc.) to the Asciicker material system. Use when adding new materials, defining terrain types, or expanding the material palette.
allowed-tools: Read, Edit, Bash

Add Material Skill

Adds a new terrain material definition to the Asciicker material system.

Material System Overview

The material system supports 256 materials (IDs 0-255):

  • Material 0: Water (blue-gray, , ! glyphs)
  • Material 1: Grass (green, " ' ` glyphs)
  • Materials 2-255: Available for new materials

Each material has:

  • 4 elevation ramps (for height variation)
  • 16 shade levels (for lighting/shadows)
  • Background color (RGB)
  • Foreground color (RGB)
  • Glyph (ASCII character)

Quick Start: Add a New Material

Example: Adding Dirt (Material 2)

  1. Open asciiid.cpp
  2. Find the material initialization code (around line 483)
  3. Add material definition after grass

Material Definition Template

cpp
// MATERIAL X: [NAME] (explicitly defined)
uint8_t [name]_bg_base[3] = {R, G, B};      // Background base color
uint8_t [name]_fg_base[3] = {R, G, B};      // Foreground base color
uint8_t [name]_glyphs[4] = {'A', 'B', 'C', 'D'}; // Glyphs for 4 ramps

for (int r = 0; r < 4; r++)  // For each elevation ramp
{
    for (int s = 0; s < 16; s++)  // For each shade level
    {
        float shade_factor = 1.0f - (s / 16.0f) * 0.6f;  // Darken by up to 60%

        m[X].shade[r][s].bg[0] = (uint8_t)([name]_bg_base[0] * shade_factor);
        m[X].shade[r][s].bg[1] = (uint8_t)([name]_bg_base[1] * shade_factor);
        m[X].shade[r][s].bg[2] = (uint8_t)([name]_bg_base[2] * shade_factor);

        m[X].shade[r][s].fg[0] = (uint8_t)([name]_fg_base[0] * shade_factor);
        m[X].shade[r][s].fg[1] = (uint8_t)([name]_fg_base[1] * shade_factor);
        m[X].shade[r][s].fg[2] = (uint8_t)([name]_fg_base[2] * shade_factor);

        m[X].shade[r][s].glyph = [name]_glyphs[r];
    }
}

Common Material Types

Dirt/Soil:

  • Background: Brown RGB(139, 90, 43)
  • Foreground: Light brown RGB(205, 133, 63)
  • Glyphs: :, ;, ., ,

Stone/Rock:

  • Background: Dark gray RGB(70, 70, 70)
  • Foreground: Light gray RGB(150, 150, 150)
  • Glyphs: #, , ,

Sand:

  • Background: Sandy yellow RGB(238, 214, 175)
  • Foreground: Light yellow RGB(255, 248, 220)
  • Glyphs: ., ·, °, ˙

Snow:

  • Background: White RGB(240, 248, 255)
  • Foreground: Bright white RGB(255, 255, 255)
  • Glyphs: *, , ·, ˙

Lava:

  • Background: Dark red RGB(139, 0, 0)
  • Foreground: Orange RGB(255, 140, 0)
  • Glyphs: ~, , , ~

Code Location

Material definitions are in asciiid.cpp:

  • Water (Material 0): Lines ~450-482
  • Grass (Material 1): Lines ~483-516
  • Add new materials here: After line 516

After Adding a Material

  1. Rebuild the editor: make -f makefile_asciiid_mac
  2. Test in editor:
    • Launch editor: ./.run/asciiid
    • Set brush to new Material ID
    • Paint on terrain
    • Verify colors and glyphs appear correctly
  3. Document: Add material to MATERIAL_SYSTEM_EXPLAINED.md

Instructions

When the user asks to add a new material:

  1. Ask for material details:
    • Name (dirt, stone, sand, etc.)
    • Base colors (or suggest common colors)
    • Glyphs (or suggest thematic characters)
  2. Read asciiid.cpp to find material initialization section
  3. Add material definition after existing materials
  4. Rebuild editor
  5. Provide testing instructions

Related Files