|
@@ -11,9 +11,24 @@
|
|
|
|
|
|
## 使用
|
|
|
|
|
|
-```powershell
|
|
|
-python .\main_module.py
|
|
|
```
|
|
|
+python .\main_module.py -h
|
|
|
+---usage: main_module.py [-h] -n NAME -t TYPE -c CLASSNAME -i ID
|
|
|
+
|
|
|
+---生成文字游戏
|
|
|
+
|
|
|
+---optional arguments:
|
|
|
+--- -h, --help show this help message and exit
|
|
|
+--- -n NAME, --name NAME config文件夹中配置的文件夹名称
|
|
|
+--- -t TYPE, --type TYPE 开始的第一个组件的类型
|
|
|
+--- -c CLASSNAME, --classname CLASSNAME
|
|
|
+--- 开始的第一个组件的classname
|
|
|
+--- -i ID, --id ID 开始的第一个组件的id
|
|
|
+
|
|
|
+python .\main_module.py -n example -t Chat -c input -i 1
|
|
|
+```
|
|
|
+
|
|
|
+**重新开始需要删除游戏配置文件中的module_output文件夹中的内容,其中保存了游戏进度; 若不删除,建议根据进度自行修改启动命令中的`-t Chat -c input -i 1`部分,使之在正确的组件上启动**
|
|
|
|
|
|
## 配置介绍
|
|
|
|
|
@@ -88,10 +103,12 @@ python .\main_module.py
|
|
|
}
|
|
|
```
|
|
|
|
|
|
- 若无下一个组件,则填入None
|
|
|
+ 若无下一个组件,则填入
|
|
|
|
|
|
```json
|
|
|
- "next_module": None
|
|
|
+ "next_module": {
|
|
|
+ "type": "End"
|
|
|
+ }
|
|
|
```
|
|
|
|
|
|
#### Judgement
|
|
@@ -119,7 +136,496 @@ python .\main_module.py
|
|
|
5. **output**: 与Chat中的output相同
|
|
|
6. **next_module**: 与Chat中的next_module相同
|
|
|
|
|
|
+## Example
|
|
|
+
|
|
|
+```json
|
|
|
+{
|
|
|
+ "Chat": [
|
|
|
+ {
|
|
|
+ "class": "input",
|
|
|
+ "id": 1,
|
|
|
+ "input": {
|
|
|
+ "user_input": "user_input.json",
|
|
|
+ "input_module_prompt":"prompt/input.json",
|
|
|
+ "json_declare":"prompt/json_declare.json"
|
|
|
+ },
|
|
|
+ "prompt_input":{
|
|
|
+ "style":"user_input['style']",
|
|
|
+ "story":"user_input['story']",
|
|
|
+ "declare":"input_module_prompt['declare']",
|
|
|
+ "json_declare":"json_declare['json_declare']"
|
|
|
+ },
|
|
|
+ "prompt": "prompt/input.json",
|
|
|
+ "output": "{class_output_data}",
|
|
|
+ "next_module": {
|
|
|
+ "type": "Chat",
|
|
|
+ "class": "value",
|
|
|
+ "id": 1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "class": "value",
|
|
|
+ "id": 1,
|
|
|
+ "input": {
|
|
|
+ "intro": "module_output/Chat_input_output.json",
|
|
|
+ "value_1_module_prompt":"prompt/value_1.json"
|
|
|
+ },
|
|
|
+ "prompt_input":{
|
|
|
+ "intro":"intro['故事简介']",
|
|
|
+ "npc":"intro['角色设定']",
|
|
|
+ "value_system":"intro['数值系统']",
|
|
|
+ "target":"intro['游戏通关所需条件']",
|
|
|
+ "output_type":"value_1_module_prompt['output_type']"
|
|
|
+ },
|
|
|
+ "prompt": "prompt/value_1.json",
|
|
|
+ "output": "{class_output_data}",
|
|
|
+ "next_module": {
|
|
|
+ "type": "Chat",
|
|
|
+ "class": "event",
|
|
|
+ "id": 1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "class": "event",
|
|
|
+ "id": 1,
|
|
|
+ "input": {
|
|
|
+ "user_input": "user_input.json",
|
|
|
+ "event_module_prompt":"prompt/event_1.json",
|
|
|
+ "intro": "module_output/Chat_input_output.json",
|
|
|
+ "value": "module_output/Chat_value_output.json",
|
|
|
+ "json_declare":"prompt/json_declare.json"
|
|
|
+ },
|
|
|
+ "prompt_input":{
|
|
|
+ "style":"user_input['style']",
|
|
|
+ "story":"user_input['story']",
|
|
|
+ "intro":"intro['故事简介']",
|
|
|
+ "npc":"intro['角色设定']",
|
|
|
+ "value_system":"intro['数值系统']",
|
|
|
+ "target":"intro['游戏通关所需条件']",
|
|
|
+ "output_type":"event_module_prompt['output_type']",
|
|
|
+ "json_declare":"json_declare['json_declare']",
|
|
|
+ "value":"value['value']"
|
|
|
+ },
|
|
|
+ "prompt": "prompt/event_1.json",
|
|
|
+ "output": "{class_output_data_append}",
|
|
|
+ "next_module": {
|
|
|
+ "type": "Chat",
|
|
|
+ "class": "value",
|
|
|
+ "id": 2
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "class": "value",
|
|
|
+ "id": 2,
|
|
|
+ "input": {
|
|
|
+ "intro": "module_output/Chat_input_output.json",
|
|
|
+ "value_1_module_prompt":"prompt/value_1.json",
|
|
|
+ "value": "module_output/Chat_value_output.json",
|
|
|
+ "event": "module_output/Chat_event_output.json"
|
|
|
+ },
|
|
|
+ "prompt": "prompt/value_2.json",
|
|
|
+ "prompt_input":{
|
|
|
+ "intro":"intro['故事简介']",
|
|
|
+ "npc":"intro['角色设定']",
|
|
|
+ "value_system":"intro['数值系统']",
|
|
|
+ "target":"intro['游戏通关所需条件']",
|
|
|
+ "event":"event['class_output_data'][-4:]",
|
|
|
+ "value":"value['value']",
|
|
|
+ "output_type":"value_1_module_prompt['output_type']"
|
|
|
+ },
|
|
|
+ "output": "{class_output_data}",
|
|
|
+ "next_module": {
|
|
|
+ "type": "Judgement",
|
|
|
+ "class": "Boolean",
|
|
|
+ "id": 1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "class": "event",
|
|
|
+ "id": 2,
|
|
|
+ "input": {
|
|
|
+ "user_input": "user_input.json",
|
|
|
+ "event_module_prompt":"prompt/event_2.json",
|
|
|
+ "intro": "module_output/Chat_input_output.json",
|
|
|
+ "value": "module_output/Chat_value_output.json",
|
|
|
+ "json_declare":"prompt/json_declare.json",
|
|
|
+ "event": "module_output/Chat_event_output.json",
|
|
|
+ "interact":"module_output/Interact_choose_output.json"
|
|
|
+ },
|
|
|
+ "prompt_input":{
|
|
|
+ "style":"user_input['style']",
|
|
|
+ "story":"user_input['story']",
|
|
|
+ "intro":"intro['故事简介']",
|
|
|
+ "npc":"intro['角色设定']",
|
|
|
+ "value_system":"intro['数值系统']",
|
|
|
+ "target":"intro['游戏通关所需条件']",
|
|
|
+ "output_type":"event_module_prompt['output_type']",
|
|
|
+ "json_declare":"json_declare['json_declare']",
|
|
|
+ "value":"value['value']",
|
|
|
+ "event":"event['class_output_data'][-4:]",
|
|
|
+ "interact":"interact['class_output_data'][-1]"
|
|
|
+ },
|
|
|
+ "prompt": "prompt/event_2.json",
|
|
|
+ "output": "{class_output_data_append}",
|
|
|
+ "next_module": {
|
|
|
+ "type": "Judgement",
|
|
|
+ "class": "Boolean",
|
|
|
+ "id": 2
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "class": "event",
|
|
|
+ "id": 3,
|
|
|
+ "input": {
|
|
|
+ "user_input": "user_input.json",
|
|
|
+ "event_module_prompt":"prompt/event_3.json",
|
|
|
+ "intro": "module_output/Chat_input_output.json",
|
|
|
+ "value": "module_output/Chat_value_output.json",
|
|
|
+ "json_declare":"prompt/json_declare.json",
|
|
|
+ "event": "module_output/Chat_event_output.json"
|
|
|
+ },
|
|
|
+ "prompt_input":{
|
|
|
+ "style":"user_input['style']",
|
|
|
+ "story":"user_input['story']",
|
|
|
+ "intro":"intro['故事简介']",
|
|
|
+ "npc":"intro['角色设定']",
|
|
|
+ "value_system":"intro['数值系统']",
|
|
|
+ "target":"intro['游戏通关所需条件']",
|
|
|
+ "output_type":"event_module_prompt['output_type']",
|
|
|
+ "json_declare":"json_declare['json_declare']",
|
|
|
+ "value":"value['value']",
|
|
|
+ "event":"event['class_output_data'][-4:]"
|
|
|
+ },
|
|
|
+ "prompt": "prompt/event_3.json",
|
|
|
+ "output": "{class_output_data_append}",
|
|
|
+ "next_module": {
|
|
|
+ "type": "Judgement",
|
|
|
+ "class": "Boolean",
|
|
|
+ "id": 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "Judgement": [
|
|
|
+ {
|
|
|
+ "class": "Boolean",
|
|
|
+ "id": 1,
|
|
|
+ "input": {
|
|
|
+ "event": "module_output/Chat_event_output.json"
|
|
|
+ },
|
|
|
+ "judgement_input":{
|
|
|
+ "last_event":"event['class_output_data'][-1]"
|
|
|
+ },
|
|
|
+ "value":"last_event['是否需要玩家选择下一步操作']",
|
|
|
+ "if_true_next": {
|
|
|
+ "type": "Interact",
|
|
|
+ "class": "choose",
|
|
|
+ "id": 1
|
|
|
+ },
|
|
|
+ "if_false_next": {
|
|
|
+ "type": "Chat",
|
|
|
+ "class": "event",
|
|
|
+ "id": 3
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "class": "Boolean",
|
|
|
+ "id": 2,
|
|
|
+ "input": {
|
|
|
+ "event": "module_output/Chat_event_output.json"
|
|
|
+ },
|
|
|
+ "judgement_input":{
|
|
|
+ "last_event":"event['class_output_data'][-1]"
|
|
|
+ },
|
|
|
+ "value":"last_event['游戏是否结束']",
|
|
|
+ "if_true_next": {"type":"End"},
|
|
|
+ "if_false_next": {
|
|
|
+ "type": "Chat",
|
|
|
+ "class": "value",
|
|
|
+ "id": 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "Interact": [
|
|
|
+ {
|
|
|
+ "class": "choose",
|
|
|
+ "id": 1,
|
|
|
+ "input": {
|
|
|
+ "event": "module_output/Chat_event_output.json"
|
|
|
+ },
|
|
|
+ "choices": "event['class_output_data'][-1]['玩家可以做出的选择']",
|
|
|
+ "output": "{class_output_data_append}",
|
|
|
+ "next_module": {
|
|
|
+ "type": "Chat",
|
|
|
+ "class": "event",
|
|
|
+ "id": 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+## Example_with_outline
|
|
|
+
|
|
|
+```json
|
|
|
+{
|
|
|
+ "Chat": [
|
|
|
+ {
|
|
|
+ "class": "input",
|
|
|
+ "id": 1,
|
|
|
+ "input": {
|
|
|
+ "user_input": "user_input.json",
|
|
|
+ "input_module_prompt":"prompt/input.json",
|
|
|
+ "json_declare":"prompt/json_declare.json"
|
|
|
+ },
|
|
|
+ "prompt_input":{
|
|
|
+ "style":"user_input['style']",
|
|
|
+ "story":"user_input['story']",
|
|
|
+ "declare":"input_module_prompt['declare']",
|
|
|
+ "json_declare":"json_declare['json_declare']"
|
|
|
+ },
|
|
|
+ "prompt": "prompt/input.json",
|
|
|
+ "output": "{class_output_data}",
|
|
|
+ "next_module": {
|
|
|
+ "type": "Chat",
|
|
|
+ "class": "outline",
|
|
|
+ "id": 1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "class": "outline",
|
|
|
+ "id": 1,
|
|
|
+ "input": {
|
|
|
+ "user_input": "user_input.json",
|
|
|
+ "intro": "module_output/Chat_input_output.json",
|
|
|
+ "outline_module_prompt":"prompt/outline.json"
|
|
|
+ },
|
|
|
+ "prompt_input":{
|
|
|
+ "style":"user_input['style']",
|
|
|
+ "story":"user_input['story']",
|
|
|
+ "intro":"intro['故事简介']",
|
|
|
+ "npc":"intro['角色设定']",
|
|
|
+ "value_system":"intro['数值系统']",
|
|
|
+ "target":"intro['游戏通关所需条件']",
|
|
|
+ "output_type":"outline_module_prompt['output_type']"
|
|
|
+ },
|
|
|
+ "prompt": "prompt/outline.json",
|
|
|
+ "output": "{class_output_data}",
|
|
|
+ "next_module": {
|
|
|
+ "type": "Chat",
|
|
|
+ "class": "value",
|
|
|
+ "id": 1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "class": "value",
|
|
|
+ "id": 1,
|
|
|
+ "input": {
|
|
|
+ "intro": "module_output/Chat_input_output.json",
|
|
|
+ "value_1_module_prompt":"prompt/value_1.json"
|
|
|
+ },
|
|
|
+ "prompt_input":{
|
|
|
+ "intro":"intro['故事简介']",
|
|
|
+ "npc":"intro['角色设定']",
|
|
|
+ "value_system":"intro['数值系统']",
|
|
|
+ "target":"intro['游戏通关所需条件']",
|
|
|
+ "output_type":"value_1_module_prompt['output_type']"
|
|
|
+ },
|
|
|
+ "prompt": "prompt/value_1.json",
|
|
|
+ "output": "{class_output_data}",
|
|
|
+ "next_module": {
|
|
|
+ "type": "Chat",
|
|
|
+ "class": "event",
|
|
|
+ "id": 1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "class": "event",
|
|
|
+ "id": 1,
|
|
|
+ "input": {
|
|
|
+ "user_input": "user_input.json",
|
|
|
+ "event_module_prompt":"prompt/event_1.json",
|
|
|
+ "intro": "module_output/Chat_input_output.json",
|
|
|
+ "value": "module_output/Chat_value_output.json",
|
|
|
+ "outline":"module_output/Chat_outline_output.json",
|
|
|
+ "json_declare":"prompt/json_declare.json"
|
|
|
+ },
|
|
|
+ "prompt_input":{
|
|
|
+ "style":"user_input['style']",
|
|
|
+ "story":"user_input['story']",
|
|
|
+ "intro":"intro['故事简介']",
|
|
|
+ "npc":"intro['角色设定']",
|
|
|
+ "value_system":"intro['数值系统']",
|
|
|
+ "target":"intro['游戏通关所需条件']",
|
|
|
+ "outline":"outline['outline']",
|
|
|
+ "output_type":"event_module_prompt['output_type']",
|
|
|
+ "json_declare":"json_declare['json_declare']",
|
|
|
+ "value":"value['value']"
|
|
|
+ },
|
|
|
+ "prompt": "prompt/event_1.json",
|
|
|
+ "output": "{class_output_data_append}",
|
|
|
+ "next_module": {
|
|
|
+ "type": "Chat",
|
|
|
+ "class": "value",
|
|
|
+ "id": 2
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "class": "value",
|
|
|
+ "id": 2,
|
|
|
+ "input": {
|
|
|
+ "intro": "module_output/Chat_input_output.json",
|
|
|
+ "value_1_module_prompt":"prompt/value_1.json",
|
|
|
+ "value": "module_output/Chat_value_output.json",
|
|
|
+ "event": "module_output/Chat_event_output.json"
|
|
|
+ },
|
|
|
+ "prompt": "prompt/value_2.json",
|
|
|
+ "prompt_input":{
|
|
|
+ "intro":"intro['故事简介']",
|
|
|
+ "npc":"intro['角色设定']",
|
|
|
+ "value_system":"intro['数值系统']",
|
|
|
+ "target":"intro['游戏通关所需条件']",
|
|
|
+ "event":"event['class_output_data'][-4:]",
|
|
|
+ "value":"value['value']",
|
|
|
+ "output_type":"value_1_module_prompt['output_type']"
|
|
|
+ },
|
|
|
+ "output": "{class_output_data}",
|
|
|
+ "next_module": {
|
|
|
+ "type": "Judgement",
|
|
|
+ "class": "Boolean",
|
|
|
+ "id": 1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "class": "event",
|
|
|
+ "id": 2,
|
|
|
+ "input": {
|
|
|
+ "user_input": "user_input.json",
|
|
|
+ "event_module_prompt":"prompt/event_2.json",
|
|
|
+ "intro": "module_output/Chat_input_output.json",
|
|
|
+ "value": "module_output/Chat_value_output.json",
|
|
|
+ "json_declare":"prompt/json_declare.json",
|
|
|
+ "event": "module_output/Chat_event_output.json",
|
|
|
+ "outline":"module_output/Chat_outline_output.json",
|
|
|
+ "interact":"module_output/Interact_choose_output.json"
|
|
|
+ },
|
|
|
+ "prompt_input":{
|
|
|
+ "style":"user_input['style']",
|
|
|
+ "story":"user_input['story']",
|
|
|
+ "intro":"intro['故事简介']",
|
|
|
+ "npc":"intro['角色设定']",
|
|
|
+ "value_system":"intro['数值系统']",
|
|
|
+ "target":"intro['游戏通关所需条件']",
|
|
|
+ "outline":"outline['outline']",
|
|
|
+ "output_type":"event_module_prompt['output_type']",
|
|
|
+ "json_declare":"json_declare['json_declare']",
|
|
|
+ "value":"value['value']",
|
|
|
+ "event":"event['class_output_data'][-4:]",
|
|
|
+ "interact":"interact['class_output_data'][-1]"
|
|
|
+ },
|
|
|
+ "prompt": "prompt/event_2.json",
|
|
|
+ "output": "{class_output_data_append}",
|
|
|
+ "next_module": {
|
|
|
+ "type": "Judgement",
|
|
|
+ "class": "Boolean",
|
|
|
+ "id": 2
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "class": "event",
|
|
|
+ "id": 3,
|
|
|
+ "input": {
|
|
|
+ "user_input": "user_input.json",
|
|
|
+ "event_module_prompt":"prompt/event_3.json",
|
|
|
+ "intro": "module_output/Chat_input_output.json",
|
|
|
+ "value": "module_output/Chat_value_output.json",
|
|
|
+ "json_declare":"prompt/json_declare.json",
|
|
|
+ "event": "module_output/Chat_event_output.json",
|
|
|
+ "outline":"module_output/Chat_outline_output.json"
|
|
|
+ },
|
|
|
+ "prompt_input":{
|
|
|
+ "style":"user_input['style']",
|
|
|
+ "story":"user_input['story']",
|
|
|
+ "intro":"intro['故事简介']",
|
|
|
+ "npc":"intro['角色设定']",
|
|
|
+ "value_system":"intro['数值系统']",
|
|
|
+ "target":"intro['游戏通关所需条件']",
|
|
|
+ "outline":"outline['outline']",
|
|
|
+ "output_type":"event_module_prompt['output_type']",
|
|
|
+ "json_declare":"json_declare['json_declare']",
|
|
|
+ "value":"value['value']",
|
|
|
+ "event":"event['class_output_data'][-4:]"
|
|
|
+ },
|
|
|
+ "prompt": "prompt/event_3.json",
|
|
|
+ "output": "{class_output_data_append}",
|
|
|
+ "next_module": {
|
|
|
+ "type": "Judgement",
|
|
|
+ "class": "Boolean",
|
|
|
+ "id": 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "Judgement": [
|
|
|
+ {
|
|
|
+ "class": "Boolean",
|
|
|
+ "id": 1,
|
|
|
+ "input": {
|
|
|
+ "event": "module_output/Chat_event_output.json"
|
|
|
+ },
|
|
|
+ "judgement_input":{
|
|
|
+ "last_event":"event['class_output_data'][-1]"
|
|
|
+ },
|
|
|
+ "value":"last_event['是否需要玩家选择下一步操作']",
|
|
|
+ "if_true_next": {
|
|
|
+ "type": "Interact",
|
|
|
+ "class": "choose",
|
|
|
+ "id": 1
|
|
|
+ },
|
|
|
+ "if_false_next": {
|
|
|
+ "type": "Chat",
|
|
|
+ "class": "event",
|
|
|
+ "id": 3
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "class": "Boolean",
|
|
|
+ "id": 2,
|
|
|
+ "input": {
|
|
|
+ "event": "module_output/Chat_event_output.json"
|
|
|
+ },
|
|
|
+ "judgement_input":{
|
|
|
+ "last_event":"event['class_output_data'][-1]"
|
|
|
+ },
|
|
|
+ "value":"last_event['游戏是否结束']",
|
|
|
+ "if_true_next": {"type":"End"},
|
|
|
+ "if_false_next": {
|
|
|
+ "type": "Chat",
|
|
|
+ "class": "value",
|
|
|
+ "id": 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "Interact": [
|
|
|
+ {
|
|
|
+ "class": "choose",
|
|
|
+ "id": 1,
|
|
|
+ "input": {
|
|
|
+ "event": "module_output/Chat_event_output.json"
|
|
|
+ },
|
|
|
+ "choices": "event['class_output_data'][-1]['玩家可以做出的选择']",
|
|
|
+ "output": "{class_output_data_append}",
|
|
|
+ "next_module": {
|
|
|
+ "type": "Chat",
|
|
|
+ "class": "event",
|
|
|
+ "id": 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+}
|
|
|
+```
|
|
|
|
|
|
+
|
|
|
|
|
|
## TODO
|
|
|
|
|
@@ -127,3 +633,4 @@ python .\main_module.py
|
|
|
- [ ] 主程序交互优化
|
|
|
- [ ] 数据处理module
|
|
|
- [ ] 更多演示case
|
|
|
+- [ ] Debug/Info logger
|