hytopia 0.1.77 → 0.1.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -66,7 +66,7 @@ The singleton instance of the game server.
66
66
  </td></tr>
67
67
  <tr><td>
68
68
 
69
- [modelManager](./server.gameserver.modelmanager.md)
69
+ [modelRegistry](./server.gameserver.modelregistry.md)
70
70
 
71
71
 
72
72
  </td><td>
@@ -76,7 +76,7 @@ The singleton instance of the game server.
76
76
 
77
77
  </td><td>
78
78
 
79
- [ModelManager](./server.modelmanager.md)
79
+ [ModelRegistry](./server.modelregistry.md)
80
80
 
81
81
 
82
82
  </td><td>
@@ -1,13 +1,13 @@
1
1
  <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
2
 
3
- [Home](./index.md) &gt; [server](./server.md) &gt; [GameServer](./server.gameserver.md) &gt; [modelManager](./server.gameserver.modelmanager.md)
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [GameServer](./server.gameserver.md) &gt; [modelRegistry](./server.gameserver.modelregistry.md)
4
4
 
5
- ## GameServer.modelManager property
5
+ ## GameServer.modelRegistry property
6
6
 
7
7
  The model manager for the game server.
8
8
 
9
9
  **Signature:**
10
10
 
11
11
  ```typescript
12
- get modelManager(): ModelManager;
12
+ get modelRegistry(): ModelRegistry;
13
13
  ```
package/docs/server.md CHANGED
@@ -195,7 +195,7 @@ Manages Light instances in a world.
195
195
  </td></tr>
196
196
  <tr><td>
197
197
 
198
- [ModelManager](./server.modelmanager.md)
198
+ [ModelRegistry](./server.modelregistry.md)
199
199
 
200
200
 
201
201
  </td><td>
@@ -1,8 +1,8 @@
1
1
  <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
2
 
3
- [Home](./index.md) &gt; [server](./server.md) &gt; [ModelManager](./server.modelmanager.md) &gt; [getBoundingBox](./server.modelmanager.getboundingbox.md)
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [ModelRegistry](./server.modelregistry.md) &gt; [getBoundingBox](./server.modelregistry.getboundingbox.md)
4
4
 
5
- ## ModelManager.getBoundingBox() method
5
+ ## ModelRegistry.getBoundingBox() method
6
6
 
7
7
  Retrieves the bounding box of a model.
8
8
 
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [ModelRegistry](./server.modelregistry.md) &gt; [instance](./server.modelregistry.instance.md)
4
+
5
+ ## ModelRegistry.instance property
6
+
7
+ The global ModelRegistry instance as a singleton.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ static readonly instance: ModelRegistry;
13
+ ```
@@ -1,31 +1,31 @@
1
1
  <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
2
 
3
- [Home](./index.md) &gt; [server](./server.md) &gt; [ModelManager](./server.modelmanager.md)
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [ModelRegistry](./server.modelregistry.md)
4
4
 
5
- ## ModelManager class
5
+ ## ModelRegistry class
6
6
 
7
7
  Manages model data for all known models of the game.
8
8
 
9
9
  **Signature:**
10
10
 
11
11
  ```typescript
12
- export default class ModelManager
12
+ export default class ModelRegistry
13
13
  ```
14
14
 
15
15
  ## Remarks
16
16
 
17
- The ModelManager is created internally as a global singletone accessible with the static property `ModelManager.instance`<!-- -->.
17
+ The ModelRegistry is created internally as a global singletone accessible with the static property `ModelRegistry.instance`<!-- -->.
18
18
 
19
- The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `ModelManager` class.
19
+ The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `ModelRegistry` class.
20
20
 
21
21
  ## Example
22
22
 
23
23
 
24
24
  ```typescript
25
- import { ModelManager } from 'hytopia';
25
+ import { ModelRegistry } from 'hytopia';
26
26
 
27
- const modelManager = ModelManager.instance;
28
- const boundingBox = modelManager.getBoundingBox('models/player.gltf');
27
+ const modelRegistry = ModelRegistry.instance;
28
+ const boundingBox = modelRegistry.getBoundingBox('models/player.gltf');
29
29
  ```
30
30
 
31
31
  ## Properties
@@ -53,7 +53,7 @@ Description
53
53
  </th></tr></thead>
54
54
  <tbody><tr><td>
55
55
 
56
- [instance](./server.modelmanager.instance.md)
56
+ [instance](./server.modelregistry.instance.md)
57
57
 
58
58
 
59
59
  </td><td>
@@ -65,12 +65,12 @@ Description
65
65
 
66
66
  </td><td>
67
67
 
68
- [ModelManager](./server.modelmanager.md)
68
+ [ModelRegistry](./server.modelregistry.md)
69
69
 
70
70
 
71
71
  </td><td>
72
72
 
73
- The global PlayerManager instance as a singleton.
73
+ The global ModelRegistry instance as a singleton.
74
74
 
75
75
 
76
76
  </td></tr>
@@ -96,7 +96,7 @@ Description
96
96
  </th></tr></thead>
97
97
  <tbody><tr><td>
98
98
 
99
- [getBoundingBox(modelUri)](./server.modelmanager.getboundingbox.md)
99
+ [getBoundingBox(modelUri)](./server.modelregistry.getboundingbox.md)
100
100
 
101
101
 
102
102
  </td><td>
@@ -0,0 +1,47 @@
1
+ # Hytopia Multi Agent Demo
2
+
3
+ This demo codebase provides an example for building multi Agent AI systems in Hytopia. The server has the following features:
4
+ - Multiple AI agents with unique pathfinding, behaviour and capabilities
5
+ - Chat bubbles for agent speech
6
+ - Side bar UI for viewing Agent actions
7
+
8
+ ## How do Agents work in Hytopia?
9
+ Game Agents are driven by a combination of game-specific action logic, world state representation, and Large Language Models.
10
+
11
+ At a high level, to integrate agents into your game, you need to think about these three pieces.
12
+
13
+ ### World State Representation
14
+ Your Agents need to know what is going on in the game. Where are they? What is around them? etc..
15
+ In this demo, the following data is available in the Agent's personal state:
16
+ - Their location
17
+ - Entities around them
18
+ - The status of any ongoing actions ("Behaviors")
19
+ - Items in their inventory
20
+
21
+ For more information on this, see the [`getCurrentState()`](src/BaseAgent.ts#L205) function in BaseAgent. Each behavior returns their Agent-specific state as a string, which we group together into an object and stringify it for the Agent's prompt.
22
+ States are prepended to each prompt to the agent.
23
+
24
+ ### Actions
25
+ Actions are things that people and agents do in your game. In this simple demo, the things people do are simple: they go places, they say things, and some of them do profession-specific tasks like Fishing and Mining.
26
+
27
+ Going places means going to specific locations (by coordinates), or going to a person or thing (by name). This means Bob can go to Jim, without knowing where Jim is. Bob might also decide to go to the Pier, since Jim is a Fisherman and one would expect the town fisherman to be at the pier.
28
+
29
+ Saying things is simple, but the weeds of what that means is also game specific. In this demo, when agents speak, other agents can hear them in close proximity, but for the sake of the demo we also show their messages globally in chat. Speaking also spawns a chat bubble UI template. See the [`agent-chat template`](assets/ui/index.html#L178) for more info on this.
30
+
31
+ Actions also interact with LLMs. Since actions are called by the LLM, we need to show the LLM how to call them.
32
+ Some agent frameworks use tool calling/function calling, which is very popular with OpenAI.
33
+ You can do this if you want, but I prefer XML. XML takes less output tokens, is very natural for LLMs to write (billions of html pages parsed). Most importantly, valid XML can be easily regexed out of any text, intermingled with other thoughts from the LLM. Many benchmarks show creativity in language models decreasing as output format is increasingly restricted.
34
+
35
+ In this demo, an action can be called by an LLM simply by outputting text like this:
36
+ `<action type="speak">...</action>`
37
+
38
+ Another benefit of this approach is that models with very little infrastructure around their APIs can all output valid XML, so you can easily use whatever model or provider you want.
39
+
40
+ ### Large Language Models
41
+ LLM's act as a router and brain for the agent, converting state representations and inputs into a sequence of actions.
42
+ LLM's need to be prompted. You will not get a spontaneous output without an input. In a game, this means you need to decide when Agent's make decisions. In this demo I show two common techniques:
43
+ - Response Triggers: when a Player speaks to an Agent, they will respond immediately. This lets players have some immediate control over influencing agent behaviours, and makes it easy to test your prompts with quick feedback. This is best for smaller player counts.
44
+ - Game Steps: as you can imagine, the above response triggers will not work at scale. Imagine 100 players in an area all talking to the same agent. You would not want it to respond outloud to everyone in the area. Instead, you can take a page out of the playbook of turn-based strategy games. Divide your game time into turns (a step could be every 5 seconds, 10 seconds, whatever you want), and each turn, you trigger each agent with the new state since their last turn. Players don't need to be limited by turns, but this makes your agents a bit simpler to manage. You can see an example of how this works in the idle detection of the agents in this repo. If an agent has not been triggered by a player in the last 30 seconds, they wake up and can decide what to do next.
45
+
46
+ ## What's next?
47
+ We want to continue to make AI Agents accessible for developers of Hytopia games. This means more game-specific demos, more tooling, and a standardized Agent implementation that you can import as a plugin into your games. More on this soon :)