-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.md.j2
323 lines (234 loc) · 7.68 KB
/
README.md.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# :wolf: Werewolf Game with `autogen`






## Requirements
- Get your API key
- OpenAI API Key
- [https://platform.openai.com/api-keys](https://platform.openai.com/api-keys)
- Groq API Key
- [https://console.groq.com/keys](https://console.groq.com/keys)
- Gemini API Key
- [https://aistudio.google.com/app/apikey](https://aistudio.google.com/app/apikey)
- (optional) `docker compose`
- (optional) python >= 3.10
Note that either of `docker compose` or `python` is required.
## How to Use
### Preparation
1. Create `.env` file
2. Set `OPENAI_API_KEY`, `GROQ_API_KEY` or `GOOGLE_API_KEY` in the `.env` file as follows:
```text
OPENAI_API_KEY=HERE_IS_YOUR_API_KEY
GROQ_API_KEY=HERE_IS_YOUR_API_KEY
GOOGLE_API_KEY=HERE_IS_YOUR_API_KEY
```
3. If you don't use `docker` but `python` in your machine, create a virtual environment and install libraries manually:
```bash
python -m venv venv
source venv/bin/activate # or `venv/Scripts/activate` in windows
python -m pip install .
```
### Enjoy a Werewolf Game
The simple use is as follows:
```bash
docker compose run werewolf python -m werewolf
```
In this case, you are an observer.
If you want to join a game, use the flag `-h` or `--include-human`:
```bash
docker compose run werewolf python -m werewolf -h
```
You can see all options with `--help` option as follows:
```bash
$ docker compose run werewolf python -m werewolf --help
{{ help }}
```
If you don't use `docker`, ignore `docker compose run werewolf` in the above commands.
## Examples
{% for example in examples%}
### {{ example.title }}
{{ example.description }}
<details>
<summary> Game Log </summary>
```sh
{{ example.log }}
```
</details>
{% for lang, translated in example.log_translated.items() %}
<details>
<summary>{{ lang }} translation by ChatGPT</summary>
```sh
{{ translated }}
```
</details>
{% endfor %}{% endfor %}
## TODO
- [x] fix a bug that a night actions of a knight and a fortune teller are invalid. See [Case2](#case-2-open-game-1-villager-1-werewolf-1-knight-and-1-fortune-teller-with-2-times-to-speak-per-day);
- solved by [#12](https://github.com/hmasdev/autogen-werewolf/issues/12) and [#14](https://github.com/hmasdev/autogen-werewolf/pull/14)
## Contribution
### Development
1. Fork the repository: [https://github.com/hmasdev/autogen-werewolf](https://github.com/hmasdev/autogen-werewolf)
2. Clone the repository
```bash
git clone https://github.com/{YOURE_NAME}/autogen-werewolf
cd autogen-werewolf
```
3. Create a virtual environment
```bash
python -m venv venv
source venv/bin/activate
```
4. Install the required packages
```bash
pip install -e .[dev]
```
5. Checkout your working branch
```bash
git checkout -b your-working-branch
```
6. Make your changes
7. Test your changes
```bash
pytest
flake8 autogen-werewolf tests
mypy autogen-werewolf tests
```
8. Commit your changes
```bash
git add .
git commit -m "Your commit message"
```
9. Push your changes
```bash
git push origin your-working-branch
```
10. Create a pull request: [https://github.com/hmasdev/autogen-werewolf/compare](https://github.com/hmasdev/autogen-werewolf/compare)
Note that you can use `uv` to develop the project in step 3, 4 and 7.
### Update README
1. Fork the repository: [https://github.com/hmasdev/autogen-werewolf](https://github.com/hmasdev/autogen-werewolf)
2. Clone the repository
```bash
git clone https://github.com/{YOURE_NAME}/autogen-werewolf
cd autogen-werewolf
```
3. Create a virtual environment
```bash
python -m venv venv
source venv/bin/activate
```
4. Install the required packages
```bash
pip install -e .[dev]
```
5. Checkout your working branch
```bash
git checkout -b your-working-branch
```
6. Make your changes
- Update **./README.md.j2**
- **CAUTION**: Do not update **./README.md** directly. It will be generated automatically from ./README.md.j2.
- Update or add an example in [./examples](./examples/)
- Name Rule: `Case{number}.json`
- Schema:
```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "The title of the example case."
},
"description": {
"type": "string",
"description": "A brief description of the example case."
},
"log": {
"type": "string",
"description": "The game log for the example case."
},
"log_translated": {
"type": "object",
"description": "Translations of the game log.",
"additionalProperties": {
"type": "string"
}
}
},
"required": ["title", "description", "log", "log_translated"]
}
```
7. Test your changes
```bash
python update_readme.py
```
8. Commit your changes
```bash
git add .
git commit -m "Your commit message"
```
9. Push your changes
```bash
git push origin your-working-branch
```
10. Create a pull request: [https://github.com/hmasdev/autogen-werewolf/compare](https://github.com/hmasdev/autogen-werewolf/compare)
### Classes
```mermaid
classDiagram
class ConversableAgent {
<<external>>
}
class IWerewolfPlayer {
<<interface>>
}
class BaseWerewolfPlayer {
<<abstract>>
}
class DefaultGameMaster {
<<concrete>>
}
class VillagerRole {
<<concrete>>
}
class WerewolfRole {
<<concrete>>
}
class KnightRole {
<<concrete>>
}
class FortuneTellerRole {
<<concrete>>
}
class GroupChatManager {
<<external>>
}
class IWerewolfGameMaster {
<<interface>>
}
class BaseGameMaster {
<<abstract>>
}
VillagerRole --|> BaseWerewolfPlayer
WerewolfRole --|> BaseWerewolfPlayer
KnightRole --|> BaseWerewolfPlayer
FortuneTellerRole --|> BaseWerewolfPlayer
IWerewolfPlayer <|.. BaseWerewolfPlayer
IWerewolfPlayer --|> ConversableAgent
BaseGameMaster <|-- DefaultGameMaster
IWerewolfGameMaster <|.. BaseGameMaster
IWerewolfGameMaster --|> GroupChatManager
```
NOTE: `IWereWolfPlayer` and `IWerewolfGameMaster` are NOT interfaces strictly, because they inherit from `ConversableAgent` and `GroupChatManager` respectively. They are introduced to avoid circular dependencies.
## LICENSE
[MIT](https://github.com/hmasdev/autogen-werewolf/tree/main/LICENSE)
## Authors
- [hmasdev](https://github.com/hmasdev)
## Reference
- Autogen: [https://github.com/microsoft/autogen](https://github.com/microsoft/autogen)
- Click: [https://github.com/pallets/click](https://github.com/pallets/click)
- LangChain: [https://github.com/langchain-ai/langchain](https://github.com/langchain-ai/langchain)
- python-dotenv: [https://github.com/theskumar/python-dotenv](https://github.com/theskumar/python-dotenv)
- Werewolf Game (in Japanese): [https://ja.wikipedia.org/wiki/%E4%BA%BA%E7%8B%BC%E3%82%B2%E3%83%BC%E3%83%A0](https://ja.wikipedia.org/wiki/%E4%BA%BA%E7%8B%BC%E3%82%B2%E3%83%BC%E3%83%A0)