femo-plugin 1.0.0

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.
Files changed (166) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +627 -0
  3. package/femo2host/__init__.py +4 -0
  4. package/femo2host/femoToolcall/chronica.py +156 -0
  5. package/femo2host/femoToolcall/femo-chat.mjs +69 -0
  6. package/femo2host/femoToolcall/femo_debugger.py +1515 -0
  7. package/femo2host/femo_api.py +437 -0
  8. package/femo2host/femo_gen_api.jsx +77 -0
  9. package/femoBridges/ContextExample.py +555 -0
  10. package/femoBridges/MemoryExample.py +163 -0
  11. package/femoBridges/__init__.py +1 -0
  12. package/femoBridges/getDir/get_dir.py +56 -0
  13. package/femoBridges/getDir//344/275/240/345/217/257/344/273/245/350/256/276/345/256/232/344/273/273/346/204/217/346/226/207/344/273/266/345/244/271/344/270/272/347/224/250/346/210/267/346/225/260/346/215/256/346/226/207/344/273/266/345/244/271.txt +10 -0
  14. package/femoBridges/llmBridge.py +247 -0
  15. package/femoBridges/llmProviders.py +308 -0
  16. package/femoCompiler/FEMO_CLIrenderer.py +198 -0
  17. package/femoCompiler/FEMO_config.py +35 -0
  18. package/femoCompiler/FEMO_errors.py +278 -0
  19. package/femoCompiler/FEMO_interpreter.py +163 -0
  20. package/femoCompiler/FEMO_normalizer.py +396 -0
  21. package/femoCompiler/FEMO_parser.py +2468 -0
  22. package/femoCompiler/FEMO_runtime.py +3630 -0
  23. package/femoCompiler/FEMO_scope_resolver.py +209 -0
  24. package/femoCompiler/__init__.py +1 -0
  25. package/femoCompiler/actor_resolver.py +86 -0
  26. package/femoCompiler/block_collector.py +441 -0
  27. package/femoCompiler/db_utils.py +485 -0
  28. package/femoCompiler/femoAsync.py +401 -0
  29. package/femoCompiler/host_manifest.py +68 -0
  30. package/femoCompiler/job_manager.py +767 -0
  31. package/femoCompiler/protocol.py +126 -0
  32. package/femoCompiler/save_dialog.py +402 -0
  33. package/femoCompiler/task_world.py +544 -0
  34. package/femoCompiler/vars/__init__.py +19 -0
  35. package/femoCompiler/vars/checkpoint.py +113 -0
  36. package/femoCompiler/vars/env.py +686 -0
  37. package/femoCompiler/vars/evaluator.py +567 -0
  38. package/femoCompiler/vars/join.py +303 -0
  39. package/femoCompiler/vars/merge.py +157 -0
  40. package/femoCompiler/vars/model.py +245 -0
  41. package/femoExamples/AI/345/211/252/350/247/206/351/242/221/AI/345/211/252/350/247/206/351/242/221.femo +192 -0
  42. package/femoExamples/AI/350/201/212/345/244/251/345/256/244/group-chat.femo +42 -0
  43. package/femoExamples/AI/350/201/212/345/244/251/345/256/244/random_wait_time.py +10 -0
  44. package/femoExamples/LuxFiat/luxfiat.femo +38 -0
  45. package/femoExamples/LuxFiat/wait.py +29 -0
  46. package/femoExamples/debug/347/245/236/345/231/250/debug/347/245/236/345/231/250.femo +222 -0
  47. package/femoExamples/discussion.femo +70 -0
  48. package/femoExamples/goal-mode.femo +23 -0
  49. package/femoExamples//345/270/270/347/224/250/345/267/245/345/205/267python/wait.py +29 -0
  50. package/femoExamples//347/213/274/344/272/272/346/235/200/werewolf_utils.py +205 -0
  51. package/femoExamples//347/213/274/344/272/272/346/235/200/werewolf_utils2.py +324 -0
  52. package/femoExamples//347/213/274/344/272/272/346/235/200//347/213/274/344/272/272/346/235/200-/350/255/246/351/225/277/347/211/210.femo +544 -0
  53. package/femoExamples//347/213/274/344/272/272/346/235/200//347/213/274/344/272/272/346/235/200.femo +331 -0
  54. package/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225/undercover_utils.py +683 -0
  55. package/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225//350/260/201/346/230/257/345/215/247/345/272/225-/350/217/234/345/270/202/345/234/272/345/261/200.femo +348 -0
  56. package/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225//350/260/201/346/230/257/345/215/247/345/272/225.femo +392 -0
  57. package/femoGen/document_ch.html +2352 -0
  58. package/femoGen/document_en.html +2279 -0
  59. package/femoGen/index.html +19 -0
  60. package/femoGen/intro_ch.html +942 -0
  61. package/femoGen/intro_en.html +932 -0
  62. package/femoGen/package-lock.json +1698 -0
  63. package/femoGen/package.json +19 -0
  64. package/femoGen/public/character_need.ttf +0 -0
  65. package/femoGen/public/favicon.ico +0 -0
  66. package/femoGen/public/femo-logo-slogan.svg +83 -0
  67. package/femoGen/public/femo-logo.svg +55 -0
  68. package/femoGen/public/logo-fullsize.ico +0 -0
  69. package/femoGen/src/FemoWorAuto.jsx +5444 -0
  70. package/femoGen/src/actionModal.jsx +358 -0
  71. package/femoGen/src/bubbleOverlay.jsx +701 -0
  72. package/femoGen/src/canvasNodes.jsx +608 -0
  73. package/femoGen/src/common.jsx +715 -0
  74. package/femoGen/src/debugPanel.jsx +530 -0
  75. package/femoGen/src/faIcons.jsx +84 -0
  76. package/femoGen/src/femoDiagnostics.js +122 -0
  77. package/femoGen/src/femoFileList.jsx +357 -0
  78. package/femoGen/src/femoGenerator.jsx +1198 -0
  79. package/femoGen/src/femoLog.js +107 -0
  80. package/femoGen/src/femoParser.jsx +2255 -0
  81. package/femoGen/src/femoPreview.jsx +297 -0
  82. package/femoGen/src/graphBuilder.jsx +358 -0
  83. package/femoGen/src/libPanel.jsx +519 -0
  84. package/femoGen/src/main.jsx +22 -0
  85. package/femoGen/src/mobileView.jsx +2796 -0
  86. package/femoGen/src/projectPanel.jsx +529 -0
  87. package/femoGen/src/soulModal.jsx +162 -0
  88. package/femoGen/src/styles/font.css +10 -0
  89. package/femoGen/src/themes.js +465 -0
  90. package/femoGen/src/useCanvasInteraction.jsx +319 -0
  91. package/femoGen/vite.config.js +28 -0
  92. package/femoGen//347/222/207/345/255/230/346/247/221.txt +15 -0
  93. package/hostAdapter/dshAdapter/README.md +68 -0
  94. package/hostAdapter/dshAdapter/build.mjs +75 -0
  95. package/hostAdapter/dshAdapter/client/client-ui/chat-node.tsx +339 -0
  96. package/hostAdapter/dshAdapter/client/client-ui/composer.tsx +997 -0
  97. package/hostAdapter/dshAdapter/client/client-ui/editor-page.tsx +726 -0
  98. package/hostAdapter/dshAdapter/client/client-ui/editor-view.tsx +88 -0
  99. package/hostAdapter/dshAdapter/client/client-ui/femo-stream-live.tsx +264 -0
  100. package/hostAdapter/dshAdapter/client/client-ui/proj2/frame-router.ts +282 -0
  101. package/hostAdapter/dshAdapter/client/client-ui/proj2/index.ts +44 -0
  102. package/hostAdapter/dshAdapter/client/client-ui/proj2/ledger.ts +329 -0
  103. package/hostAdapter/dshAdapter/client/client-ui/proj2/turn-view.tsx +211 -0
  104. package/hostAdapter/dshAdapter/client/client-ui/proj2/window-id.ts +28 -0
  105. package/hostAdapter/dshAdapter/client/client-ui/stream-store.ts +550 -0
  106. package/hostAdapter/dshAdapter/client/client-ui/styles.ts +144 -0
  107. package/hostAdapter/dshAdapter/client/client-ui/view-button.tsx +572 -0
  108. package/hostAdapter/dshAdapter/client/client-ui/view-state.ts +61 -0
  109. package/hostAdapter/dshAdapter/client/client.tsx +518 -0
  110. package/hostAdapter/dshAdapter/client/fa-icons.tsx +112 -0
  111. package/hostAdapter/dshAdapter/client/femo-reasoning-row.tsx +103 -0
  112. package/hostAdapter/dshAdapter/client/lineage-fork-native.jsx +624 -0
  113. package/hostAdapter/dshAdapter/client/lineage-fork.jsx +585 -0
  114. package/hostAdapter/dshAdapter/cordis.patch.yml +8 -0
  115. package/hostAdapter/dshAdapter/dshPatch/DSH-0.1.2-fork/344/277/256/346/224/271/351/234/200/346/261/202.md +184 -0
  116. package/hostAdapter/dshAdapter/dshPatch/MEOW_MODIFICATIONS.md +3105 -0
  117. package/hostAdapter/dshAdapter/dshPatch/patch-dsh-0.1.2-alpha.1.py +313 -0
  118. package/hostAdapter/dshAdapter/host/api-retry.ts +141 -0
  119. package/hostAdapter/dshAdapter/host/bridge.ts +224 -0
  120. package/hostAdapter/dshAdapter/host/config.ts +124 -0
  121. package/hostAdapter/dshAdapter/host/debug-log.ts +29 -0
  122. package/hostAdapter/dshAdapter/host/debug-run.ts +793 -0
  123. package/hostAdapter/dshAdapter/host/diag-feed.ts +56 -0
  124. package/hostAdapter/dshAdapter/host/engine-events.ts +891 -0
  125. package/hostAdapter/dshAdapter/host/engine-transcript.ts +122 -0
  126. package/hostAdapter/dshAdapter/host/femo-files.ts +210 -0
  127. package/hostAdapter/dshAdapter/host/god-mirror.ts +234 -0
  128. package/hostAdapter/dshAdapter/host/host-log.ts +101 -0
  129. package/hostAdapter/dshAdapter/host/http.ts +66 -0
  130. package/hostAdapter/dshAdapter/host/index.ts +633 -0
  131. package/hostAdapter/dshAdapter/host/list-cache.ts +183 -0
  132. package/hostAdapter/dshAdapter/host/main-actor.ts +853 -0
  133. package/hostAdapter/dshAdapter/host/main-delivery-queue.ts +115 -0
  134. package/hostAdapter/dshAdapter/host/native-state.ts +21 -0
  135. package/hostAdapter/dshAdapter/host/node-retry.ts +246 -0
  136. package/hostAdapter/dshAdapter/host/persona.ts +146 -0
  137. package/hostAdapter/dshAdapter/host/pre-step-gate.ts +95 -0
  138. package/hostAdapter/dshAdapter/host/proj-trace.ts +49 -0
  139. package/hostAdapter/dshAdapter/host/projection-input.ts +238 -0
  140. package/hostAdapter/dshAdapter/host/projection.ts +742 -0
  141. package/hostAdapter/dshAdapter/host/routes.ts +1196 -0
  142. package/hostAdapter/dshAdapter/host/run-control.ts +641 -0
  143. package/hostAdapter/dshAdapter/host/safe-steer.ts +33 -0
  144. package/hostAdapter/dshAdapter/host/section-gate.ts +108 -0
  145. package/hostAdapter/dshAdapter/host/session-events.ts +45 -0
  146. package/hostAdapter/dshAdapter/host/state-files.ts +301 -0
  147. package/hostAdapter/dshAdapter/host/stream-frames.ts +229 -0
  148. package/hostAdapter/dshAdapter/host/subagent-native.ts +997 -0
  149. package/hostAdapter/dshAdapter/host/subagent.ts +1205 -0
  150. package/hostAdapter/dshAdapter/host/tools.ts +486 -0
  151. package/hostAdapter/dshAdapter/host/windowing-native.ts +294 -0
  152. package/hostAdapter/dshAdapter/host.manifest.json +6 -0
  153. package/hostAdapter/dshAdapter/lib/client.js +19161 -0
  154. package/hostAdapter/dshAdapter/lib/client.js.map +7 -0
  155. package/hostAdapter/dshAdapter/lib/index.js +8173 -0
  156. package/hostAdapter/dshAdapter/lib/index.js.map +7 -0
  157. package/hostAdapter/dshAdapter/package-lock.json +500 -0
  158. package/hostAdapter/dshAdapter/package.json +55 -0
  159. package/hostAdapter/dshAdapter/pnpm-lock.yaml +596 -0
  160. package/hostAdapter/dshAdapter/pnpm-workspace.yaml +2 -0
  161. package/hostAdapter/dshAdapter/python/dev-bridge-test.py +43 -0
  162. package/hostAdapter/dshAdapter/python/femo_bridge.py +533 -0
  163. package/hostAdapter/dshAdapter/tsconfig.host.json +9 -0
  164. package/hostAdapter/dshAdapter/tsconfig.json +21 -0
  165. package/package.json +40 -0
  166. package//350/257/255/346/263/225/346/226/207/346/241/243.md +1136 -0
@@ -0,0 +1,544 @@
1
+ meta:
2
+ name = 狼人杀警长版
3
+ version = 2.0
4
+ owner = 001
5
+ session = new
6
+ output_style = |
7
+ 这是一局狼人杀游戏!你的身份牌决定了你所在的阵营,你要动脑子,努力让自己的阵营获胜。你要努力赢!
8
+ 这是6人局:2狼,2神(预言家、女巫),2村民。其中村民和神是好人阵营,狼人是狼人阵营。
9
+ 第一天白天有警长竞选:上警的玩家竞选警长,警下玩家投票选出警长。警长白天放逐投票计1.5票,并决定每天从他的哪一边开始发言。
10
+ 发言要有逻辑分析,不能瞎猜。第一天夜晚没有信息,不要幻觉。推理要依赖真实的聊天记录。
11
+ 当你们想要指定玩家成为行动时,必须@他,且只能使用场上存活玩家名单中真实存在的玩家名。
12
+ 名单里没有的名字绝不能用——例如名单里有 @Eve,输出变量时就写 @Eve;名单里没有 Kate,就绝不能写 @Kate。
13
+ 发言精炼有逻辑,不要长篇大论;夜晚行动回合的回复要简短。
14
+ 你没有调用任何工具的能力,严禁使用工具,直接根据你看到的聊天记录发言。
15
+
16
+ actors:
17
+ ai @Eve = soul:the1stlittlesoul
18
+ ai @小猫咪 = soul:littlecat
19
+ human @人 = soul:human, source:0
20
+ ai @小机 = soul:debugcoder1
21
+ ai @小灵 = soul:debugcoder2
22
+ ai @Portia = soul:Portia
23
+ ai @AI助手 = source:main
24
+
25
+ code:
26
+ werewolf_utils = file:"werewolf_utils2.py"
27
+
28
+ vars:
29
+ roles = {}
30
+ $alive = [@Eve, @小猫咪, @AI助手, @Portia, @人, @小机]
31
+ all = [@Eve, @小猫咪, @AI助手, @Portia, @人, @小机, @小灵]
32
+ $wolves = []
33
+ $wolf_room = []
34
+ $witch_has_antidote = true
35
+ $witch_has_poison = true
36
+ $dead_tonight = []
37
+ $game_over = false
38
+ $winner = ""
39
+ $sheriff_candidates = []
40
+ $vote_results = {}
41
+ @speaker = ""
42
+ @voter = ""
43
+ @player = ""
44
+ @狼人 = ""
45
+ day = 0
46
+ @上帝 = @小灵
47
+ @预言家 = ""
48
+ @女巫 = ""
49
+ @村民1 = ""
50
+ @村民2 = ""
51
+ $@sherif = ""
52
+ speak_from = ""
53
+ order = []
54
+ speaker_order = []
55
+ voter_order = []
56
+
57
+ action roleCard @func(werewolf_utils.assign_roles):
58
+ out:
59
+ roles, wolves, wolf_room, @预言家, @女巫, @村民1, @村民2
60
+
61
+ module NightPhase:
62
+ vars:
63
+ @KILL = ""
64
+ SAVE = false
65
+ @POISON = ""
66
+ @CHECK = ""
67
+ seer_check_result = ""
68
+ witch_prompt_text = ""
69
+ wolf_fail_count = 0
70
+
71
+ action nextDay @assign:
72
+ out:
73
+ day += 1
74
+
75
+ action wolf_fail @assign:
76
+ out:
77
+ wolf_fail_count += 1
78
+
79
+ action wolf_discuss @mind(@狼人):
80
+ prompt: |
81
+ 这是第{day}天晚上,夜晚降临。目前场上存活玩家:{alive}。
82
+ wolves成员: {wolves}。你是{@狼人}, 你的身份卡是狼人。请选择你的击杀对象。
83
+ 当你决定击杀对象时,需要输出:SET VARIABLE:<<@KILL = @目标名字>>
84
+ scope: wolf_room
85
+ out:
86
+ @KILL(string, "击杀目标")
87
+
88
+ action seer_check @mind(@预言家):
89
+ prompt: |
90
+ 你是{@预言家},你的身份是预言家,请选择你今晚要查验的玩家。目前场上的存活玩家:{alive}
91
+ 你需要通过变量赋值语句:SET VARIABLE:<<@CHECK = @目标名字>> 告诉上帝你的查验对象。
92
+ scope: [@上帝, @预言家]
93
+ out:
94
+ @CHECK(string, "查验目标")
95
+
96
+ action seer_result @func(werewolf_utils.check_role):
97
+ in:
98
+ target_name = @CHECK
99
+ roles_dict = roles
100
+ out:
101
+ seer_check_result
102
+
103
+ action tell_seer @mind(@预言家):
104
+ prompt: |
105
+ 现在是夜晚,你查验了 {@CHECK},结果是:{seer_check_result}。
106
+ scope: [@上帝, @预言家]
107
+
108
+ action witch_prompt @func(werewolf_utils.build_witch_prompt):
109
+ in:
110
+ has_antidote = witch_has_antidote
111
+ has_poison = witch_has_poison
112
+ kill_target = @KILL
113
+ alive_players = alive
114
+ witch_name = @女巫
115
+ out:
116
+ witch_prompt_text
117
+
118
+ action witchTurn @mind(@女巫):
119
+ prompt: |
120
+ {witch_prompt_text}
121
+ scope: [@上帝, @女巫]
122
+ out:
123
+ SAVE(bool, "是否救人"), @POISON(string, "毒杀目标")
124
+
125
+ action resolve_night @func(werewolf_utils.resolve_night):
126
+ in:
127
+ kill_target = @KILL
128
+ save = SAVE
129
+ poison_target = @POISON
130
+ alive_players = alive
131
+ has_antidote = witch_has_antidote
132
+ has_poison = witch_has_poison
133
+ wolves = wolves
134
+ out:
135
+ dead_tonight, alive, wolves, wolf_room, witch_has_antidote, witch_has_poison
136
+
137
+ flow:
138
+ [seer_check]: seer_check
139
+ [seer_result]: seer_result
140
+ [tell_seer]: tell_seer
141
+ [witchTurn]: witchTurn
142
+ [witch_prompt]: witch_prompt
143
+ [resolve_night]: resolve_night
144
+ [nextDay]: nextDay
145
+ [wolf_discuss]: wolf_discuss
146
+ [pos_4]:
147
+ [pos_3]:
148
+ [FAIL]: wolf_fail
149
+ [pos_1]:
150
+ [pos_2]:
151
+ [pos_h]:
152
+
153
+ [IN] -> [nextDay]
154
+ [nextDay] -> [pos_4]
155
+ [pos_4] -> for @狼人 in wolves:
156
+ -> if (@狼人 in alive == true) -> [wolf_discuss] ->
157
+ -> [pos_3]
158
+ [pos_3] -> fork:
159
+ -> if (@KILL == "") -> [FAIL]
160
+ -> if (@KILL != "") -> [pos_1]
161
+ [FAIL] -> fork:
162
+ -> if (wolf_fail_count < 3) -> [pos_4]
163
+ -> if (wolf_fail_count >= 3) -> [pos_1]
164
+ [pos_1] -> fork:
165
+ -> if (@预言家 in alive == false) -> [pos_2]
166
+ -> if (@预言家 in alive == true) -> [seer_check]
167
+ [pos_2] -> fork:
168
+ -> if (@女巫 in alive != true) -> [pos_h]
169
+ -> if (@女巫 in alive == true) -> [witch_prompt]
170
+ [pos_h] -> [resolve_night]
171
+ [resolve_night] -> [OUT]
172
+ [witch_prompt] -> [witchTurn]
173
+ [witchTurn] -> [pos_h]
174
+ [seer_check] -> [seer_result]
175
+ [seer_result] -> [tell_seer]
176
+ [tell_seer] -> [pos_2]
177
+
178
+ # sketch:
179
+ # [FOR] = 200, 200
180
+ # [OUT] = 600, 380
181
+ # [seer_check] = 448, 88
182
+ # [seer_result] = 583, 29
183
+ # [tell_seer] = 629, 110
184
+ # [witchTurn] = 1153, 419
185
+ # [witch_prompt] = 1152, 317
186
+ # [resolve_night] = 458, 746
187
+ # [nextDay] = 139, -7
188
+ # [wolf_discuss] = 172, 420
189
+ # [pos_4] = -6, 300
190
+ # [pos_3] = 114, 357
191
+ # [FAIL] = 183, 265
192
+ # [pos_1] = 590, 186
193
+ # [pos_2] = 992, 326
194
+ # [pos_h] = 1008, 428
195
+
196
+ module DayPhase:
197
+ meta:
198
+ delay = 10
199
+
200
+ vars:
201
+ announcement = ""
202
+ @VOTE = ""
203
+ eliminated_today = ""
204
+
205
+ action announce @func(werewolf_utils.announce_death):
206
+ in:
207
+ dead_tonight = dead_tonight
208
+ out:
209
+ announcement
210
+
211
+ action god_announce @ai(@上帝):
212
+ prompt: |
213
+ 天亮了。{announcement}。这是第{day}天白天,存活玩家:{alive}。
214
+ 你是上帝,你需要将昨晚的结算结果告诉所有玩家。不可以在发言中暴露夜间具体行动,不可以暴露玩家身份。
215
+ scope: all
216
+
217
+ action speak @mind(@speaker):
218
+ prompt: |
219
+ 轮到你发言。你是{@speaker},你的身份是{@speaker.roles}。目前场上存活玩家:{alive}。昨晚 {announcement}。请分享你的想法和怀疑对象。
220
+ scope: all
221
+
222
+ action init @assign:
223
+ out:
224
+ $vote_results = {}
225
+ @VOTE = ""
226
+
227
+ action vote @mind(@voter):
228
+ prompt: |
229
+ 现在是白天,投票时间。你是{@voter},你的身份是{@voter.roles}。请先分析一下,然后决定投谁。
230
+ 最后输出:SET VARIABLE: <<@VOTE = @目标名字>>
231
+ scope: [@上帝, @voter]
232
+ out:
233
+ @VOTE(string, "投票目标")
234
+
235
+ action collect_vote @func(werewolf_utils.collect_vote):
236
+ in:
237
+ votes = $vote_results
238
+ voter_name = @voter
239
+ target = @VOTE
240
+ out:
241
+ $vote_results
242
+
243
+ action process_vote @func(werewolf_utils.process_votes_and_end):
244
+ in:
245
+ votes = $vote_results
246
+ alive_players = alive
247
+ wolves = wolves
248
+ roles_dict = roles
249
+ sheriff = @sherif
250
+ out:
251
+ eliminated_today, alive, wolves, wolf_room, game_over, winner
252
+
253
+ action announce_vote @ai(@上帝):
254
+ prompt: |
255
+ 投票结束。系统计票记录:{vote_results}。{eliminated_today} 被放逐(「无人」代表平票或全员弃票,今日无人出局;警长票按1.5票计)。存活玩家:{alive}。
256
+ 你是上帝,请告诉大家投票结果,谁都投了谁。本环节只宣布投票结果,不许说下一步的行动。不可以在发言中透露玩家身份。
257
+ scope: all
258
+
259
+ action 移交警徽 @mind(@sherif):
260
+ prompt: |
261
+ 你是警长{@sherif},但你已不在存活玩家名单中。请指定警徽去向:
262
+ 若移交给一位存活玩家,请输出:SET VARIABLE: <<@sherif = @你要移交的人>>(只能写存活玩家名单中的名字:{alive})
263
+ 若撕毁警徽,请输出:SET VARIABLE: <<@sherif = "">>
264
+ showprompt: |
265
+ 请警长选择移交警徽
266
+ scope: [@上帝, @sherif]
267
+ out:
268
+ @sherif(string, "警徽去向")
269
+
270
+ action 决定发言顺序 @ai(@sherif):
271
+ prompt: |
272
+ 你是警长{@sherif}。请决定今天白天的发言从你的哪一边开始。只输出一行赋值,二选一:
273
+ 从左边开始:SET VARIABLE: <<speak_from = 左>>
274
+ 从右边开始:SET VARIABLE: <<speak_from = 右>>
275
+ scope: [@上帝, @sherif]
276
+ out:
277
+ speak_from(string, "发言方向")
278
+
279
+ action get_order @func(werewolf_utils.get_order):
280
+ in:
281
+ from_ = speak_from
282
+ sheriff = @sherif
283
+ alive = alive
284
+ out:
285
+ order
286
+
287
+ flow:
288
+ [announce]: announce
289
+ [speak]: speak
290
+ [vote]: vote
291
+ [announce_vote]: announce_vote
292
+ [god]: god_announce
293
+ [init]: init
294
+ [process_vote]: process_vote
295
+ [c]: collect_vote
296
+ [移交警徽]: 移交警徽
297
+ [移交警徽_2]: 移交警徽
298
+ [决定发言顺序]: 决定发言顺序
299
+ [get_order]: get_order
300
+
301
+ [IN] -> [announce]
302
+ [announce] -> [god]
303
+ [god] -> fork:
304
+ -> if ((@sherif != "") and (@sherif in alive == true)) -> [决定发言顺序]
305
+ -> if ((@sherif != "") and (@sherif in alive == false)) -> [移交警徽]
306
+ -> if (@sherif == "") -> [get_order]
307
+ [决定发言顺序] -> [get_order]
308
+ [get_order] -> for @speaker in order:
309
+ -> [speak] ->
310
+ -> [init]
311
+ [init] -> par @voter in alive:
312
+ -> [vote] -> [c] ->
313
+ -> [process_vote]
314
+ [process_vote] -> [announce_vote]
315
+ [announce_vote] -> fork:
316
+ -> if ((@sherif != "") and (@sherif in alive == false)) -> [移交警徽_2]
317
+ -> if ((@sherif == "") or (@sherif in alive == true)) -> [OUT]
318
+ [移交警徽_2] -> [OUT]
319
+ [移交警徽] -> [get_order]
320
+
321
+ # sketch:
322
+ # [FOR] = 138, 167
323
+ # [PAR] = 263, 86
324
+ # [PAR_出] = 272, 336
325
+ # [OUT] = 457, 14
326
+ # [announce] = -159, -10
327
+ # [speak] = 113, 64
328
+ # [vote] = 260, 152
329
+ # [announce_vote] = 449, 225
330
+ # [god] = -160, 89
331
+ # [init] = 254, -17
332
+ # [process_vote] = 449, 331
333
+ # [c] = 259, 238
334
+ # [移交警徽] = -322, 171
335
+ # [移交警徽_2] = 452, 107
336
+ # [决定发言顺序] = -159, 230
337
+ # [get_order] = -10, 160
338
+
339
+ module Election:
340
+ meta:
341
+ delay = 10
342
+
343
+ vars:
344
+ @start = ""
345
+ want_badge = false
346
+ @vote_target = ""
347
+
348
+ action init @assign:
349
+ out:
350
+ $sheriff_candidates = []
351
+ $vote_results = {}
352
+
353
+ action 是否上警 @mind(@player):
354
+ prompt: |
355
+ 警长竞选开始,你是{@player},你的身份是{@player.roles}。是否上警竞选警长?
356
+ 若要上警,请输出:SET VARIABLE: <<want_badge = true>>
357
+ 若不上警,请直接简短说明你放弃上警,不要输出任何赋值。
358
+ scope: [@上帝, @player]
359
+ out:
360
+ want_badge(bool, "是否上警")
361
+
362
+ action collect_candidacy @func(werewolf_utils.collect_candidacy):
363
+ in:
364
+ candidates = $sheriff_candidates
365
+ player_name = @player
366
+ want = want_badge
367
+ out:
368
+ $sheriff_candidates
369
+
370
+ action 上帝指定起始 @ai(@上帝):
371
+ prompt: |
372
+ 上警玩家有:{$sheriff_candidates}。
373
+ 如果有上警玩家,请随机选择其中一人作为第一个发言者,
374
+ 输出:SET VARIABLE: <<@start = @玩家名>>。
375
+ 如果没有人上警,则不要输出赋值。
376
+ 随便选,越没道理越好。
377
+ scope: all
378
+ out:
379
+ @start(string, "起始发言玩家")
380
+
381
+ action 生成发言顺序 @func(werewolf_utils.get_speaker_order_from_start):
382
+ in:
383
+ candidates = $sheriff_candidates
384
+ start = @start
385
+ out:
386
+ speaker_order
387
+
388
+ action 警上发言 @mind(@player):
389
+ prompt: |
390
+ 你是{@player},请发表你的警长竞选发言,说明你的优势,并给出你对场上的初步判断。
391
+ scope: all
392
+
393
+ action 生成投票者列表 @func(werewolf_utils.get_sheriff_voter_order):
394
+ in:
395
+ alive = alive
396
+ candidates = $sheriff_candidates
397
+ out:
398
+ voter_order
399
+
400
+ action 投票 @mind(@voter):
401
+ prompt: |
402
+ 你是{@voter},现在是警长竞选投票。
403
+ 你是警下玩家,只能从警上玩家中选择一人投票。
404
+ 警上玩家:{$sheriff_candidates}。
405
+ 最后必须输出:
406
+ SET VARIABLE: <<@vote_target = @你支持的警上玩家>>
407
+ 只能填写警上玩家名单中的真实名字。
408
+ scope: [@上帝, @voter]
409
+ out:
410
+ @vote_target(string, "投票目标")
411
+
412
+ action 收集投票 @func(werewolf_utils.collect_vote):
413
+ in:
414
+ votes = $vote_results
415
+ voter_name = @voter
416
+ target = @vote_target
417
+ out:
418
+ $vote_results
419
+
420
+ action 处理选举 @func(werewolf_utils.process_election_votes):
421
+ in:
422
+ votes = $vote_results
423
+ candidates = $sheriff_candidates
424
+ alive = alive
425
+ out:
426
+ @sherif(string, "当选警长")
427
+
428
+ action 宣布警长 @ai(@上帝):
429
+ prompt: |
430
+ 计票结果:{$vote_results}。
431
+ 警长竞选结束。当前警长:{@sherif}。
432
+ 如果 {@sherif} 为空,则宣布无人当选警长(平票或无人上警)。
433
+ 请向全体玩家宣布警长归属,并说明警长的特权:白天放逐投票计1.5票,每天决定从警长的哪一边开始发言。
434
+ scope: all
435
+
436
+ flow:
437
+ [init]: init
438
+ [是否上警]: 是否上警
439
+ [collect_candidacy]: collect_candidacy
440
+ [上帝指定起始]: 上帝指定起始
441
+ [生成发言顺序]: 生成发言顺序
442
+ [警上发言]: 警上发言
443
+ [生成投票者列表]: 生成投票者列表
444
+ [投票]: 投票
445
+ [收集投票]: 收集投票
446
+ [处理选举]: 处理选举
447
+ [宣布警长]: 宣布警长
448
+
449
+ [IN] -> [init]
450
+ [init] -> par @player in alive:
451
+ -> [是否上警] -> [collect_candidacy] ->
452
+ -> [上帝指定起始]
453
+ [上帝指定起始] -> [生成发言顺序]
454
+ [生成发言顺序] -> for @player in speaker_order:
455
+ -> [警上发言] ->
456
+ -> [生成投票者列表]
457
+ [生成投票者列表] -> par @voter in voter_order:
458
+ -> [投票] -> [收集投票] ->
459
+ -> [处理选举]
460
+ [处理选举] -> [宣布警长]
461
+ [宣布警长] -> [OUT]
462
+
463
+ # sketch:
464
+ # [PAR] = 0, 172
465
+ # [PAR_出] = 5, 439
466
+ # [FOR] = 139, 255
467
+ # [PAR_2] = 269, 356
468
+ # [PAR_2_出] = 263, 99
469
+ # [OUT] = 130, 91
470
+ # [init] = -5, 72
471
+ # [是否上警] = -4, 256
472
+ # [collect_candidacy] = -2, 346
473
+ # [上帝指定起始] = 133, 430
474
+ # [生成发言顺序] = 133, 329
475
+ # [警上发言] = 132, 168
476
+ # [生成投票者列表] = 261, 429
477
+ # [投票] = 257, 258
478
+ # [收集投票] = 258, 169
479
+ # [处理选举] = 257, -9
480
+ # [宣布警长] = 125, -6
481
+
482
+ module chat:
483
+ action chat @mind(@player):
484
+ prompt: |
485
+ 游戏结束啦,随便聊聊吧~
486
+ scope: all
487
+
488
+ action chat_human @human(@人):
489
+ scope: all
490
+
491
+ flow:
492
+ [chat]: chat
493
+ [hub]:
494
+ [AI_line]:
495
+ [chat_human]: chat_human
496
+ [human_line]:
497
+
498
+ [IN] -> [hub]
499
+ [hub] -> fork:
500
+ -> [AI_line]
501
+ -> [human_line]
502
+ [AI_line] -> for @player in [@Eve, @小猫咪, @小机, @小灵, @Portia, @AI助手]:
503
+ -> [chat] ->
504
+ -> [OUT]
505
+ [human_line] -> [chat_human]
506
+ [chat_human] -> [human_line]
507
+
508
+ # sketch:
509
+ # [FOR] = -224, 187
510
+ # [OUT] = 3, 185
511
+ # [chat] = -119, 261
512
+ # [hub] = 1, 102
513
+ # [AI_line] = -166, 120
514
+ # [chat_human] = 149, 193
515
+ # [human_line] = 154, 116
516
+
517
+ mainflow:
518
+ [roleCard]: roleCard
519
+ [game_loop]: &NightPhase
520
+ [day]: &DayPhase
521
+ [chat]: &chat
522
+ [Election]: &Election
523
+ [pos_1]:
524
+
525
+ [START] -> [roleCard]
526
+ [roleCard] -> [game_loop]
527
+ [game_loop] -> [pos_1]
528
+ [pos_1] -> fork:
529
+ -> if (day == 1) -> [Election]
530
+ -> if (day > 1) -> [day]
531
+ [Election] -> [day]
532
+ [day] -> fork:
533
+ -> if (game_over == false) -> [game_loop]
534
+ -> if (game_over == true) -> [chat]
535
+ [chat] -> [END]
536
+
537
+ #sketch:
538
+ # [END] = 260, 335
539
+ # [roleCard] = 153, -10
540
+ # [game_loop] = 146, 110
541
+ # [day] = 267, 224
542
+ # [chat] = 33, 317
543
+ # [Election] = 13, 223
544
+ # [pos_1] = -19, 128