-
Notifications
You must be signed in to change notification settings - Fork 118
Open
Description
Code Framework Overview
- ./restart.sh starts main.py
- The browser loads index.html, which is the Unity frontend, and sends {"uri":"command.auth.Register","method":"POST","data":{"nickname":"Mayor","email":"Lixing@163.com","cryptoPWD":"123456"}} to the backend
- The on_message function in main.py receives the message and calls the execute method of the Register Class in the command.auth.Register folder
- command.auth.login_base initializes NPCs and the map
- When the tick button is clicked on the web frontend, {"uri":"command.tick.Tick","method":"POST","data":{}} is sent to the backend. Similarly, the backend calls the execute method of the TickStarter Class in the command.starter.TickStarter folder
- TickStarter actually invokes tick.py in the project directory. The asyncio.create_task(call_timetick(websocket)) sends a message to the backend to start command/timetick/Tick.py
- Tick-related configurations are detailed in config/app.json. For example, setting tick_count_limit=1 and manually running tick.py allows for step-by-step debugging
- command/timetick/Tick.py contains the main logic for the agent. It is somewhat complex and can be refactored in the future to add custom logic such as TickChat, TickMove, etc.
- The tick program and backend, as well as the frontend and backend, communicate through port 8000 (fixed). We mainly focus on frontend-backend communication. For example, websocket.send() at line 42 in command/timetick/Tick.py sends a message to the frontend to trigger character movement.
- Backend data is persisted in both snapshot/app.json and a MySQL database.
- Note that NPCs have states. Initially, they are in the "inited" state, and after the first tick, they transition to the "movings" state. Sometimes, if an NPC is not in the "movings" state, it won't execute the "movings" logic.
"inited":[],"movings":["NPC-10002"],"chatted":[],"using":["NPC-10001","NPC-10002"],"cache":[]
I also fix some bugs, please refer to https://github.com/asdqsczser/AgentSims/blob/main/README.md.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels