world

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionIntent

type ActionIntent struct {
	ActorID                  string                 `json:"actor_id"`
	Action                   string                 `json:"action"`
	TargetLocation           string                 `json:"target_location,omitempty"`
	TargetEntity             string                 `json:"target_entity,omitempty"`
	TargetAgent              string                 `json:"target_agent,omitempty"`
	Speech                   string                 `json:"speech,omitempty"`
	InternalReasoningSummary string                 `json:"internal_reasoning_summary,omitempty"`
	ProposedEffects          map[string]interface{} `json:"proposed_effects,omitempty"`
}

type Clock

type Clock struct {
	Tick         int64 `json:"tick"`
	SimTimeUnix  int64 `json:"sim_time_unix"`
	LastAdvance  int64 `json:"last_advance_unix"`
	TickDuration int64 `json:"tick_duration_sec"`
}

type Engine

type Engine struct{}

func NewEngine

func NewEngine() *Engine

func (*Engine) AppendRecentEvent

func (e *Engine) AppendRecentEvent(state *WorldState, evt WorldEvent, maxRecent int)

func (*Engine) ApplyIntent

func (e *Engine) ApplyIntent(state *WorldState, npc *NPCState, intent ActionIntent) WorldDelta

func (*Engine) BuildUserEvent

func (e *Engine) BuildUserEvent(state *WorldState, input, locationID, actorID string) WorldEvent

func (*Engine) EnsureNPCState

func (e *Engine) EnsureNPCState(blueprint NPCBlueprint, state NPCState) NPCState

func (*Engine) EnsureWorld

func (e *Engine) EnsureWorld(state *WorldState)

func (*Engine) NextTick

func (e *Engine) NextTick(state *WorldState) int64

func (*Engine) Snapshot

func (e *Engine) Snapshot(state WorldState, npcStates map[string]NPCState, recentEvents []WorldEvent, pendingIntents int, limit int) SnapshotSummary

func (*Engine) VisibleEventsForNPC

func (e *Engine) VisibleEventsForNPC(state WorldState, npc NPCState, events []WorldEvent, scope int) []WorldEvent

type Entity

type Entity struct {
	ID         string                 `json:"id"`
	Name       string                 `json:"name,omitempty"`
	Type       string                 `json:"type,omitempty"`
	LocationID string                 `json:"location_id,omitempty"`
	Placement  *EntityPlacement       `json:"placement,omitempty"`
	State      map[string]interface{} `json:"state,omitempty"`
}

type EntityPlacement

type EntityPlacement struct {
	Model    string     `json:"model,omitempty"`
	Scale    [3]float64 `json:"scale,omitempty"`
	Rotation [3]float64 `json:"rotation,omitempty"`
	Offset   [3]float64 `json:"offset,omitempty"`
}

type GoalSet

type GoalSet struct {
	ShortTerm []string `json:"short_term,omitempty"`
	LongTerm  []string `json:"long_term,omitempty"`
}

type Location

type Location struct {
	ID          string   `json:"id"`
	Name        string   `json:"name,omitempty"`
	Description string   `json:"description,omitempty"`
	Neighbors   []string `json:"neighbors,omitempty"`
	Model       string   `json:"model,omitempty"`
}

type NPCBlueprint

type NPCBlueprint struct {
	NPCID           string   `json:"npc_id"`
	DisplayName     string   `json:"display_name,omitempty"`
	Kind            string   `json:"kind,omitempty"`
	Role            string   `json:"role,omitempty"`
	Persona         string   `json:"persona,omitempty"`
	Traits          []string `json:"traits,omitempty"`
	Faction         string   `json:"faction,omitempty"`
	HomeLocation    string   `json:"home_location,omitempty"`
	DefaultGoals    []string `json:"default_goals,omitempty"`
	PerceptionScope int      `json:"perception_scope,omitempty"`
	ScheduleHint    string   `json:"schedule_hint,omitempty"`
	WorldTags       []string `json:"world_tags,omitempty"`
	MemoryNamespace string   `json:"memory_namespace,omitempty"`
	PromptFile      string   `json:"prompt_file,omitempty"`
}

type NPCState

type NPCState struct {
	NPCID                string                 `json:"npc_id"`
	ProfileRef           string                 `json:"profile_ref,omitempty"`
	CurrentLocation      string                 `json:"current_location,omitempty"`
	Goals                GoalSet                `json:"goals,omitempty"`
	Beliefs              map[string]string      `json:"beliefs,omitempty"`
	Mood                 string                 `json:"mood,omitempty"`
	Relationships        map[string]string      `json:"relationships,omitempty"`
	Inventory            map[string]int         `json:"inventory,omitempty"`
	Assets               map[string]interface{} `json:"assets,omitempty"`
	PrivateMemorySummary string                 `json:"private_memory_summary,omitempty"`
	Status               string                 `json:"status,omitempty"`
	LastActiveTick       int64                  `json:"last_active_tick,omitempty"`
	CurrentRoomID        string                 `json:"current_room_id,omitempty"`
}

type PlayerState

type PlayerState struct {
	PlayerID        string `json:"player_id"`
	DisplayName     string `json:"display_name,omitempty"`
	CurrentLocation string `json:"current_location,omitempty"`
	Status          string `json:"status,omitempty"`
	LastActionTick  int64  `json:"last_action_tick,omitempty"`
}

type QuestState

type QuestState struct {
	ID           string   `json:"id"`
	Title        string   `json:"title,omitempty"`
	Status       string   `json:"status,omitempty"`
	OwnerNPCID   string   `json:"owner_npc_id,omitempty"`
	Participants []string `json:"participants,omitempty"`
	Summary      string   `json:"summary,omitempty"`
}

type RenderedResult

type RenderedResult struct {
	Text         string         `json:"text,omitempty"`
	Tick         int64          `json:"tick,omitempty"`
	Intents      []ActionIntent `json:"intents,omitempty"`
	RecentEvents []WorldEvent   `json:"recent_events,omitempty"`
}

type RoomState

type RoomState struct {
	ID              string   `json:"id"`
	Name            string   `json:"name,omitempty"`
	Kind            string   `json:"kind,omitempty"`
	Status          string   `json:"status,omitempty"`
	LocationID      string   `json:"location_id,omitempty"`
	Model           string   `json:"model,omitempty"`
	TaskSummary     string   `json:"task_summary,omitempty"`
	LinkedQuestID   string   `json:"linked_quest_id,omitempty"`
	AssignedNPCIDs  []string `json:"assigned_npc_ids,omitempty"`
	CreatedTick     int64    `json:"created_tick,omitempty"`
	UpdatedTick     int64    `json:"updated_tick,omitempty"`
	ReleaseOnFinish bool     `json:"release_on_finish,omitempty"`
}

type SnapshotSummary

type SnapshotSummary struct {
	WorldID            string              `json:"world_id,omitempty"`
	Tick               int64               `json:"tick,omitempty"`
	SimTimeUnix        int64               `json:"sim_time_unix,omitempty"`
	Player             PlayerState         `json:"player,omitempty"`
	Locations          map[string]Location `json:"locations,omitempty"`
	Entities           map[string]Entity   `json:"entities,omitempty"`
	NPCCount           int                 `json:"npc_count,omitempty"`
	ActiveNPCs         []string            `json:"active_npcs,omitempty"`
	Quests             []QuestState        `json:"quests,omitempty"`
	Rooms              []RoomState         `json:"rooms,omitempty"`
	RecentEvents       []WorldEvent        `json:"recent_events,omitempty"`
	PendingIntentCount int                 `json:"pending_intent_count,omitempty"`
	Occupancy          map[string][]string `json:"occupancy,omitempty"`
	EntityOccupancy    map[string][]string `json:"entity_occupancy,omitempty"`
	RoomOccupancy      map[string][]string `json:"room_occupancy,omitempty"`
	NPCStates          map[string]NPCState `json:"npc_states,omitempty"`
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(workspace string) *Store

func (*Store) AppendWorldEvent

func (s *Store) AppendWorldEvent(evt WorldEvent) error

func (*Store) Events

func (s *Store) Events(limit int) ([]WorldEvent, error)

func (*Store) LoadNPCStates

func (s *Store) LoadNPCStates() (map[string]NPCState, error)

func (*Store) LoadWorldState

func (s *Store) LoadWorldState() (WorldState, error)

func (*Store) SaveNPCState

func (s *Store) SaveNPCState(id string, state NPCState) error

func (*Store) SaveNPCStates

func (s *Store) SaveNPCStates(items map[string]NPCState) error

func (*Store) SaveWorldState

func (s *Store) SaveWorldState(state WorldState) error

type WorldDelta

type WorldDelta struct {
	Applied         bool         `json:"applied"`
	Reason          string       `json:"reason,omitempty"`
	Intent          ActionIntent `json:"intent"`
	Event           *WorldEvent  `json:"event,omitempty"`
	NPCStateChanged bool         `json:"npc_state_changed,omitempty"`
}

type WorldEvent

type WorldEvent struct {
	ID         string                 `json:"id"`
	Type       string                 `json:"type"`
	Source     string                 `json:"source,omitempty"`
	ActorID    string                 `json:"actor_id,omitempty"`
	LocationID string                 `json:"location_id,omitempty"`
	Content    string                 `json:"content,omitempty"`
	VisibleTo  []string               `json:"visible_to,omitempty"`
	Payload    map[string]interface{} `json:"payload,omitempty"`
	Tick       int64                  `json:"tick"`
	CreatedAt  int64                  `json:"created_at"`
}

type WorldState

type WorldState struct {
	WorldID      string                 `json:"world_id"`
	Clock        Clock                  `json:"clock"`
	Player       PlayerState            `json:"player"`
	Locations    map[string]Location    `json:"locations,omitempty"`
	GlobalFacts  map[string]interface{} `json:"global_facts,omitempty"`
	Entities     map[string]Entity      `json:"entities,omitempty"`
	Rooms        map[string]RoomState   `json:"rooms,omitempty"`
	ActiveQuests map[string]QuestState  `json:"active_quests,omitempty"`
	RecentEvents []WorldEvent           `json:"recent_events,omitempty"`
}

func DefaultWorldState

func DefaultWorldState() WorldState

type WorldTickRequest

type WorldTickRequest struct {
	Source        string       `json:"source,omitempty"`
	ActorID       string       `json:"actor_id,omitempty"`
	UserInput     string       `json:"user_input,omitempty"`
	LocationID    string       `json:"location_id,omitempty"`
	ForceStep     bool         `json:"force_step,omitempty"`
	CatchUpTicks  int          `json:"catch_up_ticks,omitempty"`
	MaxNPCPerTick int          `json:"max_npc_per_tick,omitempty"`
	VisibleEvents []WorldEvent `json:"visible_events,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL