mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-07 00:07:30 +08:00
Seed starter world for world mind
This commit is contained in:
@@ -61,8 +61,8 @@ func TestWorldRuntimeHandleUserInputInitializesState(t *testing.T) {
|
||||
t.Fatalf("snapshot failed: %v", err)
|
||||
}
|
||||
data, _ := json.Marshal(snapshot)
|
||||
if !strings.Contains(string(data), "\"npc_count\":1") {
|
||||
t.Fatalf("expected snapshot npc_count=1, got %s", string(data))
|
||||
if !strings.Contains(string(data), "\"npc_count\":2") {
|
||||
t.Fatalf("expected snapshot npc_count=2 with main included, got %s", string(data))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,6 +172,45 @@ func TestWorldRuntimeCreateEntityAndGet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorldRuntimeIncludesMainWorldMindFromConfigProfile(t *testing.T) {
|
||||
workspace := t.TempDir()
|
||||
manager := tools.NewAgentManager(nil, workspace, nil)
|
||||
runtime := NewWorldRuntime(workspace, manager.ProfileStore(), tools.NewAgentDispatcher(manager), manager)
|
||||
|
||||
items, err := runtime.NPCList()
|
||||
if err != nil {
|
||||
t.Fatalf("npc list failed: %v", err)
|
||||
}
|
||||
if len(items) == 0 {
|
||||
t.Fatalf("expected main world mind to appear in npc list")
|
||||
}
|
||||
data, _ := json.Marshal(items)
|
||||
if !strings.Contains(string(data), `"npc_id":"main"`) {
|
||||
t.Fatalf("expected main in npc list, got %s", string(data))
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorldRuntimeSeedsStarterEntities(t *testing.T) {
|
||||
workspace := t.TempDir()
|
||||
manager := tools.NewAgentManager(nil, workspace, nil)
|
||||
runtime := NewWorldRuntime(workspace, manager.ProfileStore(), tools.NewAgentDispatcher(manager), manager)
|
||||
|
||||
worldOut, err := runtime.WorldGet()
|
||||
if err != nil {
|
||||
t.Fatalf("world get failed: %v", err)
|
||||
}
|
||||
worldState, ok := worldOut["world_state"].(world.WorldState)
|
||||
if !ok {
|
||||
t.Fatalf("unexpected world_state payload: %T", worldOut["world_state"])
|
||||
}
|
||||
if _, ok := worldState.Entities["notice-board"]; !ok {
|
||||
t.Fatalf("expected notice-board starter entity")
|
||||
}
|
||||
if _, ok := worldState.Entities["waystone"]; !ok {
|
||||
t.Fatalf("expected waystone starter entity")
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorldRuntimeUpdateEntityPlacement(t *testing.T) {
|
||||
workspace := t.TempDir()
|
||||
manager := tools.NewAgentManager(nil, workspace, nil)
|
||||
@@ -303,7 +342,7 @@ func TestWorldRuntimeSnapshotIncludesEntityOccupancyAfterInteract(t *testing.T)
|
||||
t.Fatalf("snapshot failed: %v", err)
|
||||
}
|
||||
data, _ := json.Marshal(snap)
|
||||
if !strings.Contains(string(data), `"entity_occupancy":{"square":["statue"]}`) {
|
||||
if !strings.Contains(string(data), `"square":["statue","waystone"]`) {
|
||||
t.Fatalf("expected entity occupancy for statue, got %s", string(data))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user