This post is also available in Chinese
Introduction
In the modern game development process, the importance of innovation and creativity goes without saying. However, even for the most talented developers, inspiration can run dry. To solve this problem, we created a GPT-4-based assistant tool we call Game Copilot. This tool is a chat room containing eleven agents, designed to help game entrepreneurs brainstorm and optimize games.
Working Mechanism
How does Game Copilot work? It leverages the powerful capabilities of GPT-4, providing essential game elements such as world views, mechanics, gameplay, and characters to provide inspiration for developers. It can demonstrate high divergence and reference past games, novels, and current world backgrounds to help developers build unique and engaging game experiences.
Project Information
Game Copilot is primarily suitable for independent studios and RPG game development. Whether you’re a game entrepreneur or a developer seeking new inspiration, Game Copilot can help you.
To improve ease of use, we’ve integrated WeCom (Enterprise WeChat) through wechaty, enabling users to record their inspiration and iterate anywhere, anytime. Whether on a crowded bus or in a relaxing café, just open WeCom and easily access Game Copilot.
Web version: Experience Link WeCom Bot version: Under development.
Backend Architecture
Technology
- Package Manager: Poetry
- Backend Framework: FastAPI
- Database: MongoDB and Beanie
Get Started
- Install Poetry and
poetry install
- Prepare MongoDB. The easiest way is using docker:
docker run --rm -p 27017:27017 mongo
- Install
game-copilot-agent-v2
and generate access key - Uncomment
.env
file and fill in the required information - Run
uvicorn src.main:app --reload
Game Design Workflow
- Register and Login
- Start a Game: Since we are using paid API for generating, each user will have a limit on the number of games they can design.
- Primary Information Collector: User will chat with an information collector agent. Then generate a basic description of the game user wants to design.
- Design Iteration:
- Firstly, user will chat with a group of agents, including an ideation agent and critic agents. They will help user brainstorm fancy ideas and give feedbacks on those ideas and current game design.
- When user is satisfied with new ideas and comments, they can issue a full game design iteration.
- After a full design is generated, user can review and modify the design.
- More specifically, user can issue a “command”, such as “add some new ideas in here” or “give me more options for this part”.
- Agents will generate the requested result.
- User and Agents chat with each other to discuss the result.
- Finally, user can choose to accept or reject the modification.
- This “Design Iteration” can be repeated several times until user is satisfied with the result.
Data Model
- User: Very basic and common design
- email, username, (hashed)password, email validation, type
- In addition, a game limit counter is used
- Game:
- user id, create time, design stage
- title: string
- Revision: Store all chat messages, commands and designs.
- game id, create time, is closed
- type: collect-info, co-design, review-design
- iteration: int
- Record:
- revision id, create time
- is agent, agent name
- type: chat, command, design
- command type: add, more-options
- content: string
- Relations: User has-many Games, Game has-many Revisions, GameRevision has-many Records
- Structure
- Game: collect-info - co-design - review-design - co-design - review-design - …
- Every “Revision” starts with a “Bootstrap” operation and ends with a “Finalize” operation.
- Revision(collect-info): bootstrap - chat - chat - … - chat - design
- Revision(co-design): bootstrap - chat - chat - … - chat - todo-list - confirm - design
- Revision(review-design): bootstrap - chat - chat - … - chat - design
Required “Agent” API
- Common Description
- All API should be invoked with an “agent-token” in request body.
{ "token": "<token>"}
- All API except
bootstrap
message should be invoked with a “session-id” (may be generated byuuid.uuid4().hex
) in request body.{ "session_id": "<uuid>" }
- Reset message (Force terminate session):
{ "type": "reset" }
- Error message:
{ "type": "error", "detailed": "<str>" }
, For example:- Invalid session id
- Invalid message scheme/format
- Unexpected message type
- All API should be invoked with an “agent-token” in request body.
/api/collect-info/
- C -> S:
{ "type": "bootstrap" }
- S -> C:
{ "type": "session", "session_id": "<uuid>" }
- C -> S:
{ "type": "chat-user", "content": "<msg>" }
- S -> C:
{ "type": "chat-agent-name", "name": "<name>" }
{ "type": "chat-agent", "content": "<msg>" }
{ "type": "chat-agent-fin", "end": "<bool>" }
- C -> S:
{ "type": "end" }
- S -> C:
{ "type": "design", "content": "<design>" }
- C -> S:
/api/co-design/
- C -> S:
{ "type": "bootstrap", "design": "<design>" }
- S -> C:
{ "type": "session", "session_id": "<uuid>" }
- C -> S:
{ "type": "chat-user", "content": "<msg>" }
- S -> C:
{ "type": "chat-agent-name", "name": "<name>" }
{ "type": "chat-agent", "content": "<msg>" }
{ "type": "chat-agent-fin" }
- C -> S:
{ "type": "end" }
- S -> C:
{ "type": "summary", "content": "<content>" }
- C -> S:
{ "type": "confirm", "content": "<content>" }
- S -> C:
{ "type": "design", "content": "<design>" }
- C -> S:
/api/review-design/
- C -> S:
{ "type": "bootstrap" }
- S -> C:
{ "type": "session", "session_id": "<uuid>" }
- C -> S:
{ "type": "add|more-options", "design": "<design>", "target": "<target>", "extra": "<extra>" }
- S -> C:
{ "type": "result", "content": "<content>" }
- C -> S:
{ "type": "chat-user", "content": "<msg>" }
- S -> C:
{ "type": "chat-agent-name", "name": "<name>" }
{ "type": "chat-agent", "content": "<msg>" }
{ "type": "chat-agent-fin" }
- C -> S:
Frontend API
/login/
/signup/
- RESTful API
/users/
/users/{uid}
/users/{uid}/games/
/users/{uid}/games/{gid}
/users/{uid}/games/{gid}/revision
/users/{uid}/games/{gid}/revision/{rid}
/users/{uid}/games/{gid}/revision/{rid}/records
- Server-Side Events (Prefix:
/users/{uid}/games/{gid}/revision/{rid}/records
)/chat
/reset
/collect/end
/codesign/end
/codesign/confirm
/review/command
/review/submit
- Process:
- Create game:
POST /users/{uid}/games
- Create revision (with types):
POST /users/{uid}/games/{gid}
- Collect-Info
- Chat:
POST .../chat
- End:
POST .../end-collection
- Chat:
- Co-Design
- Chat:
POST .../chat
- End:
POST .../end-co-design
- Confirm:
POST .../confirm-summary
- Chat:
- Create game:
Backend TODO
- Legends:
- :white_circle: Not started
- :construction: In progress
- :eight_pointed_black_star: Backend code finished. Need to be tested and integrated with frontend or agents.
- :white_check_mark: Done!
- :thought_balloon: Need to be discussed / Blocked by other tasks
- Authentication:
- :white_check_mark: Signup
- :white_check_mark: Login
- :white_circle: Email verification
- :white_circle: Password reset
- User:
- :white_check_mark: Get info
- :white_circle: Update info
- :white_circle: Delete account
- :white_circle: Get user list
- Game:
- :white_check_mark: Get user’s game list
- :white_check_mark: Create game
- :white_check_mark: Get game info
- Revision:
- :white_check_mark: Get game’s revision list
- :construction: Create revision
- :white_check_mark: Get revision info
- Record:
- :eight_pointed_black_star: Get revision’s record list
- :eight_pointed_black_star: User chat
- :eight_pointed_black_star: Collect info end
- :eight_pointed_black_star: Co-design end
- :eight_pointed_black_star: Co-design confirm
- :eight_pointed_black_star: Review design command
- :eight_pointed_black_star: Review design submit
- Agent Interaction:
- :eight_pointed_black_star: Collect info
- :eight_pointed_black_star: Co-design
- :eight_pointed_black_star: Review design
- :thought_balloon: Session recovery
- Others
- :white_circle: Deploy to Zeabur