AgentSkillsCN

architecture

快速参考 Petri 的架构模式。在阅读大量代码之前使用,帮助您理解当前的设计模式。

SKILL.md
--- frontmatter
name: architecture
description: "Quick reference to Petri's architecture patterns. Use before reading lots of code to understand current design patterns."

Architecture Quick Reference

Read docs/architecture.md for the complete reference. Key patterns:

Core Design

  • MVU Architecture: Bubble Tea Model-View-Update, rendering diffs automatic
  • Intent System: Characters calculate Intent, then intents applied atomically
  • Multi-Stat Urgency: Tiers 0-4, highest wins; tie-breaker: Thirst > Hunger > Energy
  • Stat Fallback: If intent can't be fulfilled, falls through to next urgent stat

Data Structures

  • Sparse Grid + Indexed Slices: O(1) character lookups via grid, separate slices for entities
  • Simple Flags over ECS: Boolean flags (Edible, Poisonous) not full ECS. Can evolve later.

Item Model

  • Descriptive attributes (ItemType, Color, Pattern, Texture) - opinions form on these
  • Functional attributes (Edible, Poisonous, Healing) - capabilities, no opinions
  • Optional property structs: EdibleProperties, PlantProperties, ContainerData

Key Patterns to Check

PatternWhere DocumentedWhen Relevant
Orders and Actionsarchitecture.md § OrdersAdding player-directed tasks
Pickup/Vessel helpersarchitecture.md § Pickup ActivityItem manipulation
Component Procurementarchitecture.md § ComponentMulti-step gathering activities
Activity Registryarchitecture.md § ActivityAdding new activities
Recipe Systemarchitecture.md § RecipeAdding craftable items
Feature Passabilityarchitecture.md § FeatureMap elements, movement
Position Handlingarchitecture.md § PositionCoordinates, distance

Common Pitfalls

  • Game time vs wall clock: UI indicators that work when paused need time.Now()
  • Sorting stability: Use sort.SliceStable with deterministic tiebreakers for merged map data
  • View transitions: Add dimension safeguards when switching rendering approaches

Next step: Read the specific section of docs/architecture.md relevant to your task, then explore the code files listed there.