rm old code
Browse files- games/angrybirds/old/config.py +0 -393
- games/angrybirds/old/prompt.py +0 -67
- games/angrybirds/old/query.py +0 -109
- games/angrybirds/old/util.py +0 -34
games/angrybirds/old/config.py
DELETED
|
@@ -1,393 +0,0 @@
|
|
| 1 |
-
|
| 2 |
-
class config:
|
| 3 |
-
|
| 4 |
-
# constant
|
| 5 |
-
x_bird = 'bird'
|
| 6 |
-
x_pig = 'pig'
|
| 7 |
-
x_obstable = 'obstacle'
|
| 8 |
-
x_add = 'add'
|
| 9 |
-
x_list = 'list'
|
| 10 |
-
x_change_position = 'change position'
|
| 11 |
-
|
| 12 |
-
# x_para = 'para'
|
| 13 |
-
x_quantity = 'quantiy'
|
| 14 |
-
x_color = 'color'
|
| 15 |
-
x_type = 'type'
|
| 16 |
-
x_size = 'size'
|
| 17 |
-
x_args = 'args'
|
| 18 |
-
|
| 19 |
-
agent = 'game developer'
|
| 20 |
-
game_desc = """
|
| 21 |
-
Imaging we are developing the game of the Angry Birds,
|
| 22 |
-
and the game is described as the following:
|
| 23 |
-
|
| 24 |
-
In Angry Birds, players take control of a group of birds who are seeking
|
| 25 |
-
revenge on a group of green pigs that have stolen their eggs.
|
| 26 |
-
The gameplay involves using a slingshot to launch the birds at various
|
| 27 |
-
structures where the pigs are hiding. The objective is to
|
| 28 |
-
eliminate all the pigs on each level and score as many points as possible.
|
| 29 |
-
|
| 30 |
-
A game developer is building the game,
|
| 31 |
-
and I need you to help me figure out what is going on.
|
| 32 |
-
"""
|
| 33 |
-
|
| 34 |
-
game_examples = {
|
| 35 |
-
"Add a bird.": {
|
| 36 |
-
'train': '',
|
| 37 |
-
'prompt': [
|
| 38 |
-
f"The {agent} is talking about birds.",
|
| 39 |
-
f"The {agent} wants to add a bird.",
|
| 40 |
-
],
|
| 41 |
-
'result': [
|
| 42 |
-
x_bird,
|
| 43 |
-
x_add,
|
| 44 |
-
{},
|
| 45 |
-
],
|
| 46 |
-
},
|
| 47 |
-
"Delete a bird.": {
|
| 48 |
-
'train': '',
|
| 49 |
-
'prompt': [
|
| 50 |
-
f"The {agent} is talking about birds.",
|
| 51 |
-
f"The {agent} wants to remove a bird.",
|
| 52 |
-
],
|
| 53 |
-
'result': [
|
| 54 |
-
x_bird,
|
| 55 |
-
x_add,
|
| 56 |
-
{x_quantity: -1},
|
| 57 |
-
],
|
| 58 |
-
},
|
| 59 |
-
"Add more birds.": {
|
| 60 |
-
'train': '',
|
| 61 |
-
'prompt': [
|
| 62 |
-
f"The {agent} is talking about birds.",
|
| 63 |
-
f"The {agent} wants to add some birds.",
|
| 64 |
-
],
|
| 65 |
-
'result': [
|
| 66 |
-
x_bird,
|
| 67 |
-
x_add,
|
| 68 |
-
{x_quantity: 'some'},
|
| 69 |
-
],
|
| 70 |
-
},
|
| 71 |
-
"Add a big bird.": {
|
| 72 |
-
'train': '',
|
| 73 |
-
'focus': '',
|
| 74 |
-
'prompt': [
|
| 75 |
-
f"The {agent} is talking about birds.",
|
| 76 |
-
f"The {agent} wants to add a bird.",
|
| 77 |
-
f"The type of the bird the {agent} wants to add is a big bird.",
|
| 78 |
-
],
|
| 79 |
-
'result': [
|
| 80 |
-
x_bird,
|
| 81 |
-
x_add,
|
| 82 |
-
{x_type: 'big'},
|
| 83 |
-
],
|
| 84 |
-
},
|
| 85 |
-
"Add a magnet bird.": {
|
| 86 |
-
'train': '',
|
| 87 |
-
'focus': '',
|
| 88 |
-
'prompt': [
|
| 89 |
-
f"The {agent} is talking about birds.",
|
| 90 |
-
f"The {agent} wants to add a bird.",
|
| 91 |
-
f"The type of the bird the {agent} wants to add is a big bird.",
|
| 92 |
-
],
|
| 93 |
-
'result': [
|
| 94 |
-
x_bird,
|
| 95 |
-
x_add,
|
| 96 |
-
{x_type: 'magnet'},
|
| 97 |
-
],
|
| 98 |
-
},
|
| 99 |
-
"Add a superheavy bird.": {
|
| 100 |
-
'train': '',
|
| 101 |
-
'focus': '',
|
| 102 |
-
'prompt': [
|
| 103 |
-
f"The {agent} is talking about birds.",
|
| 104 |
-
f"The {agent} wants to add a bird.",
|
| 105 |
-
f"The type of the bird the {agent} wants to add is a big bird.",
|
| 106 |
-
],
|
| 107 |
-
'result': [
|
| 108 |
-
x_bird,
|
| 109 |
-
x_add,
|
| 110 |
-
{x_type: 'superheavy'},
|
| 111 |
-
],
|
| 112 |
-
},
|
| 113 |
-
"Add a catapult bird.": {
|
| 114 |
-
'train': '',
|
| 115 |
-
'focus': '',
|
| 116 |
-
'prompt': [
|
| 117 |
-
f"The {agent} is talking about birds.",
|
| 118 |
-
f"The {agent} wants to add a bird.",
|
| 119 |
-
f"The type of the bird the {agent} wants to add is a big bird.",
|
| 120 |
-
],
|
| 121 |
-
'result': [
|
| 122 |
-
x_bird,
|
| 123 |
-
x_add,
|
| 124 |
-
{x_type: 'catapult'},
|
| 125 |
-
],
|
| 126 |
-
},
|
| 127 |
-
"Add a flash bird.": {
|
| 128 |
-
'train': '',
|
| 129 |
-
'focus': '',
|
| 130 |
-
'prompt': [
|
| 131 |
-
f"The {agent} is talking about birds.",
|
| 132 |
-
f"The {agent} wants to add a bird.",
|
| 133 |
-
f"The type of the bird the {agent} wants to add is a big bird.",
|
| 134 |
-
],
|
| 135 |
-
'result': [
|
| 136 |
-
x_bird,
|
| 137 |
-
x_add,
|
| 138 |
-
{x_type: 'flash'},
|
| 139 |
-
],
|
| 140 |
-
},
|
| 141 |
-
"Add an antigravity bird.": {
|
| 142 |
-
'train': '',
|
| 143 |
-
'focus': '',
|
| 144 |
-
'prompt': [
|
| 145 |
-
f"The {agent} is talking about birds.",
|
| 146 |
-
f"The {agent} wants to add a bird.",
|
| 147 |
-
f"The type of the bird the {agent} wants to add is a big bird.",
|
| 148 |
-
],
|
| 149 |
-
'result': [
|
| 150 |
-
x_bird,
|
| 151 |
-
x_add,
|
| 152 |
-
{x_type: 'antigravity'},
|
| 153 |
-
],
|
| 154 |
-
},
|
| 155 |
-
"The game is too difficult. Please add more birds.": {
|
| 156 |
-
'train': '',
|
| 157 |
-
'prompt': [
|
| 158 |
-
f"The {agent} is talking about birds.",
|
| 159 |
-
f"The {agent} wants to add some birds.",
|
| 160 |
-
],
|
| 161 |
-
'result': [
|
| 162 |
-
x_bird,
|
| 163 |
-
x_add,
|
| 164 |
-
{x_quantity: 'some'},
|
| 165 |
-
],
|
| 166 |
-
},
|
| 167 |
-
"Make the bird bigger.": {
|
| 168 |
-
'train': '',
|
| 169 |
-
'prompt': [
|
| 170 |
-
f"The {agent} is talking about birds.",
|
| 171 |
-
f"The {agent} wants to change the size of a bird.",
|
| 172 |
-
f"The {agent} did not specify how much bigger",
|
| 173 |
-
],
|
| 174 |
-
'result': [
|
| 175 |
-
x_bird,
|
| 176 |
-
x_size,
|
| 177 |
-
{},
|
| 178 |
-
],
|
| 179 |
-
},
|
| 180 |
-
"Make the bird bigger, so it can run over the enemies.": {
|
| 181 |
-
'test': '',
|
| 182 |
-
'focus': '',
|
| 183 |
-
'prompt': [
|
| 184 |
-
f"The {agent} is talking about birds.",
|
| 185 |
-
f"The {agent} wants to change the size of a bird.",
|
| 186 |
-
f"The {agent} did not specify how much bigger",
|
| 187 |
-
],
|
| 188 |
-
'result': [
|
| 189 |
-
x_bird,
|
| 190 |
-
x_size,
|
| 191 |
-
{},
|
| 192 |
-
],
|
| 193 |
-
},
|
| 194 |
-
"List birds.": {
|
| 195 |
-
'train': '',
|
| 196 |
-
'prompt': [
|
| 197 |
-
f"The {agent} is talking about birds.",
|
| 198 |
-
f"The {agent} wants to list the kinds of the birds",
|
| 199 |
-
],
|
| 200 |
-
'result': [
|
| 201 |
-
x_bird,
|
| 202 |
-
x_list,
|
| 203 |
-
{},
|
| 204 |
-
],
|
| 205 |
-
},
|
| 206 |
-
"Show bird list.": {
|
| 207 |
-
'train': '',
|
| 208 |
-
'prompt': [
|
| 209 |
-
f"The {agent} is talking about birds.",
|
| 210 |
-
f"The {agent} wants to list the kinds of the birds",
|
| 211 |
-
],
|
| 212 |
-
'result': [
|
| 213 |
-
x_bird,
|
| 214 |
-
x_list,
|
| 215 |
-
{},
|
| 216 |
-
],
|
| 217 |
-
},
|
| 218 |
-
"What kind of birds do you have?": {
|
| 219 |
-
'train': '',
|
| 220 |
-
'prompt': [
|
| 221 |
-
f"The {agent} is talking about birds.",
|
| 222 |
-
f"The {agent} wants to list the kinds of the birds",
|
| 223 |
-
],
|
| 224 |
-
'result': [
|
| 225 |
-
x_bird,
|
| 226 |
-
x_list,
|
| 227 |
-
{},
|
| 228 |
-
],
|
| 229 |
-
},
|
| 230 |
-
"Are there new kinds of birds?": {
|
| 231 |
-
'train': '',
|
| 232 |
-
'prompt': [
|
| 233 |
-
f"The {agent} is talking about birds.",
|
| 234 |
-
f"The {agent} wants to list the kinds of the birds",
|
| 235 |
-
],
|
| 236 |
-
'result': [
|
| 237 |
-
x_bird,
|
| 238 |
-
x_list,
|
| 239 |
-
{x_type: 'new'},
|
| 240 |
-
],
|
| 241 |
-
},
|
| 242 |
-
'I want to change the positon of birds': {
|
| 243 |
-
'train': '',
|
| 244 |
-
'prompt': [
|
| 245 |
-
],
|
| 246 |
-
'result': [
|
| 247 |
-
x_change_position,
|
| 248 |
-
{x_args: 'bird'},
|
| 249 |
-
],
|
| 250 |
-
},
|
| 251 |
-
'I want to change the positon of pigs': {
|
| 252 |
-
'train': '',
|
| 253 |
-
'prompt': [
|
| 254 |
-
],
|
| 255 |
-
'result': [
|
| 256 |
-
x_change_position,
|
| 257 |
-
{x_args: 'pig'},
|
| 258 |
-
],
|
| 259 |
-
},
|
| 260 |
-
'I want to change the positon of houses': {
|
| 261 |
-
'train': '',
|
| 262 |
-
'prompt': [
|
| 263 |
-
],
|
| 264 |
-
'result': [
|
| 265 |
-
x_change_position,
|
| 266 |
-
{x_args: 'house'},
|
| 267 |
-
],
|
| 268 |
-
},
|
| 269 |
-
'I want to change the positon of obstacles': {
|
| 270 |
-
'train': '',
|
| 271 |
-
'prompt': [
|
| 272 |
-
],
|
| 273 |
-
'result': [
|
| 274 |
-
x_change_position,
|
| 275 |
-
{x_args: 'obstacle'},
|
| 276 |
-
],
|
| 277 |
-
},
|
| 278 |
-
"Add a pig.": {
|
| 279 |
-
'train': '',
|
| 280 |
-
'prompt': [
|
| 281 |
-
f"The {agent} is talking about pigs.",
|
| 282 |
-
f"The {agent} wants to add a pig.",
|
| 283 |
-
],
|
| 284 |
-
'result': [
|
| 285 |
-
x_pig,
|
| 286 |
-
x_add,
|
| 287 |
-
{},
|
| 288 |
-
],
|
| 289 |
-
},
|
| 290 |
-
"Our pigs are losing. Add more pigs.": {
|
| 291 |
-
'prompt': [
|
| 292 |
-
f"The {agent} is talking about pigs.",
|
| 293 |
-
f"The {agent} wants to add some pig.",
|
| 294 |
-
],
|
| 295 |
-
'result': [
|
| 296 |
-
x_pig,
|
| 297 |
-
x_add,
|
| 298 |
-
{x_quantity: 'some'},
|
| 299 |
-
],
|
| 300 |
-
},
|
| 301 |
-
"The pigs are too week. Increase the health points for them.": {
|
| 302 |
-
|
| 303 |
-
},
|
| 304 |
-
"The pigs are too week. Increase the HP for them.": {
|
| 305 |
-
|
| 306 |
-
},
|
| 307 |
-
"The pigs are too week. Increase the hit points for them.": {
|
| 308 |
-
|
| 309 |
-
},
|
| 310 |
-
"The pigs are too week. Increase the blood level for them.": {
|
| 311 |
-
|
| 312 |
-
},
|
| 313 |
-
"The pigs are too week. Increase the blood levels for them.": {
|
| 314 |
-
|
| 315 |
-
},
|
| 316 |
-
"I want to protect the pigs by build houses for them.": {
|
| 317 |
-
|
| 318 |
-
},
|
| 319 |
-
"I want to build houses.": {
|
| 320 |
-
|
| 321 |
-
},
|
| 322 |
-
"I want to build houses, so I can protect my pigs.": {
|
| 323 |
-
|
| 324 |
-
},
|
| 325 |
-
"The obstacles are too weak. Let's build some solid houses.": {
|
| 326 |
-
|
| 327 |
-
},
|
| 328 |
-
}
|
| 329 |
-
game_commands = [
|
| 330 |
-
"add a bird.",
|
| 331 |
-
"add more birds",
|
| 332 |
-
"The game is too difficult. Please add more birds.",
|
| 333 |
-
"Make the bird bigger, so it can run over the enemies.",
|
| 334 |
-
# "Are there new kinds of birds?",
|
| 335 |
-
# "Our pigs are loosing. Add more pigs",
|
| 336 |
-
# "The pigs are too week. Increase the health points for them.",
|
| 337 |
-
# "The pigs are too week. Increase the HP for them.",
|
| 338 |
-
# "The pigs are too week. Increase the hit points for them.",
|
| 339 |
-
"The pigs are too week. Increase the blood level for them.",
|
| 340 |
-
"The pigs are too week. Increase the blood levels for them.",
|
| 341 |
-
"I want to protect the pigs by build houses for them.",
|
| 342 |
-
# "I want to build houses",
|
| 343 |
-
"I want to build houses, so I can protect my pigs",
|
| 344 |
-
# "The obstacles are too weak. Let's build some solid houses"
|
| 345 |
-
]
|
| 346 |
-
|
| 347 |
-
cache = {
|
| 348 |
-
"add a bird": ["birds", "quantity", "increase"],
|
| 349 |
-
"please add a bird": ["birds", "quantity", "increase"],
|
| 350 |
-
}
|
| 351 |
-
|
| 352 |
-
NOTA = "none of the above"
|
| 353 |
-
# ONEPLUS = "more than one choices"
|
| 354 |
-
game_spec = {
|
| 355 |
-
"birds": {
|
| 356 |
-
"color": ["change", NOTA],
|
| 357 |
-
"variaty": ["list", NOTA],
|
| 358 |
-
"quantity": {
|
| 359 |
-
"increase": {
|
| 360 |
-
'big bird',
|
| 361 |
-
'magnet bird',
|
| 362 |
-
'superheavy bird',
|
| 363 |
-
'catapult bird',
|
| 364 |
-
'flash bird',
|
| 365 |
-
'antigravity bird',
|
| 366 |
-
'unspecified bird',
|
| 367 |
-
},
|
| 368 |
-
"decrease":{},
|
| 369 |
-
NOTA: {},
|
| 370 |
-
},
|
| 371 |
-
"size": ["increase", "decrease", NOTA],
|
| 372 |
-
NOTA: [],
|
| 373 |
-
},
|
| 374 |
-
"houses": {
|
| 375 |
-
"quantity": ["create", "increase", "decrease", NOTA],
|
| 376 |
-
"strength": ["increase", "decrease", NOTA],
|
| 377 |
-
NOTA: [],
|
| 378 |
-
},
|
| 379 |
-
"pigs": {
|
| 380 |
-
"quantity": ["increase", "decrease", NOTA],
|
| 381 |
-
"health points": ["increase", "decrease", NOTA],
|
| 382 |
-
NOTA: [],
|
| 383 |
-
},
|
| 384 |
-
# "eggs": {
|
| 385 |
-
# "quantity": ["increase", "decrease", NOTA],
|
| 386 |
-
# "size": ["increase", "decrease", NOTA],
|
| 387 |
-
# NOTA: [],
|
| 388 |
-
# },
|
| 389 |
-
"building houses for pigs": {},
|
| 390 |
-
# "protecting pigs": {},
|
| 391 |
-
# "structures": {},
|
| 392 |
-
NOTA: {},
|
| 393 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
games/angrybirds/old/prompt.py
DELETED
|
@@ -1,67 +0,0 @@
|
|
| 1 |
-
class prompt:
|
| 2 |
-
|
| 3 |
-
assistant = {
|
| 4 |
-
"role": "system",
|
| 5 |
-
"content": "You are a helpful assistant.",
|
| 6 |
-
}
|
| 7 |
-
|
| 8 |
-
def prompt_which_object(self, game_desc, query, obj_list):
|
| 9 |
-
prompt = f"""
|
| 10 |
-
{game_desc}
|
| 11 |
-
|
| 12 |
-
The game developer says: \"{query}\".
|
| 13 |
-
|
| 14 |
-
The game developer is talking about ___
|
| 15 |
-
{obj_list}
|
| 16 |
-
|
| 17 |
-
Do not explain.
|
| 18 |
-
"""
|
| 19 |
-
|
| 20 |
-
tmp = """
|
| 21 |
-
Please answer it in the following format:
|
| 22 |
-
Answer: (<choice>)
|
| 23 |
-
"""
|
| 24 |
-
return prompt
|
| 25 |
-
|
| 26 |
-
def prompt_change_attribute(self, game_desc, query, obj, attr_list):
|
| 27 |
-
prompt = f"""
|
| 28 |
-
{game_desc}
|
| 29 |
-
|
| 30 |
-
The game developer says: \"{query}\".
|
| 31 |
-
|
| 32 |
-
The game developer wants to make changes to the __ of the {obj}
|
| 33 |
-
{attr_list}
|
| 34 |
-
|
| 35 |
-
Do not explain.
|
| 36 |
-
"""
|
| 37 |
-
return prompt
|
| 38 |
-
|
| 39 |
-
def prompt_how_to_change_attribute(self, game_desc, query, obj, attr, verb_list):
|
| 40 |
-
prompt = f"""
|
| 41 |
-
{game_desc}
|
| 42 |
-
|
| 43 |
-
The game developer says: \"{query}\".
|
| 44 |
-
|
| 45 |
-
The game developer wants to __ the {attr} of the {obj}
|
| 46 |
-
{verb_list}
|
| 47 |
-
|
| 48 |
-
Do not explain.
|
| 49 |
-
"""
|
| 50 |
-
return prompt
|
| 51 |
-
|
| 52 |
-
def get_full_prompt(self, prompt):
|
| 53 |
-
full_prompt = [
|
| 54 |
-
self.assistant,
|
| 55 |
-
{'role': 'user', 'content': prompt}
|
| 56 |
-
]
|
| 57 |
-
return full_prompt
|
| 58 |
-
|
| 59 |
-
make_sense = """
|
| 60 |
-
In the prompt, does the user's request make sense?
|
| 61 |
-
Please just answer "Yes" if it makes sense, or "No" if it does not.
|
| 62 |
-
Please do not explain.
|
| 63 |
-
"""
|
| 64 |
-
|
| 65 |
-
why_make_no_sense = """
|
| 66 |
-
Please explain why you think the user's request did not make sense.
|
| 67 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
games/angrybirds/old/query.py
DELETED
|
@@ -1,109 +0,0 @@
|
|
| 1 |
-
import json
|
| 2 |
-
|
| 3 |
-
from games.angrybirds.util import util
|
| 4 |
-
from games.angrybirds.prompt import prompt
|
| 5 |
-
from games.angrybirds.config import config
|
| 6 |
-
from games.angrybirds.angrybirds import angrybird
|
| 7 |
-
|
| 8 |
-
debug = 2
|
| 9 |
-
|
| 10 |
-
def yes_no_query(bird:angrybird, command:str, prmpt:str):
|
| 11 |
-
s = f"""
|
| 12 |
-
{config.game_desc}
|
| 13 |
-
|
| 14 |
-
The game developer says: \'{command}'
|
| 15 |
-
|
| 16 |
-
Answer yes or no to the following statement:
|
| 17 |
-
{prmpt}
|
| 18 |
-
|
| 19 |
-
Please do not explain.
|
| 20 |
-
|
| 21 |
-
"""
|
| 22 |
-
|
| 23 |
-
tmp = """
|
| 24 |
-
Please do not explain.
|
| 25 |
-
"""
|
| 26 |
-
|
| 27 |
-
p = prompt()
|
| 28 |
-
|
| 29 |
-
full_prompt = p.get_full_prompt(s)
|
| 30 |
-
# print(full_prompt)
|
| 31 |
-
return bird.query_chatgpt(full_prompt, yes_no=True)
|
| 32 |
-
|
| 33 |
-
def query2(bird: angrybird, command:str):
|
| 34 |
-
pass
|
| 35 |
-
|
| 36 |
-
def query(bird: angrybird, command:str):
|
| 37 |
-
modify_request = 'Please modify your request.'
|
| 38 |
-
p = prompt()
|
| 39 |
-
|
| 40 |
-
print('-'*20)
|
| 41 |
-
obj_lst = list(config.game_spec.keys())
|
| 42 |
-
obj_list = [f"{i} {o}" for i, o in zip(util.order, obj_lst)]
|
| 43 |
-
s = p.prompt_which_object(
|
| 44 |
-
config.game_desc,
|
| 45 |
-
command,
|
| 46 |
-
" ".join(obj_list))
|
| 47 |
-
full_prompt = p.get_full_prompt(s)
|
| 48 |
-
if debug >= 2:
|
| 49 |
-
print(f'prompt:{s}')
|
| 50 |
-
|
| 51 |
-
res = bird.query_openai(full_prompt)
|
| 52 |
-
if debug >= 1:
|
| 53 |
-
print(res)
|
| 54 |
-
obj = util.extract_result(res, obj_lst)
|
| 55 |
-
if debug >= 1:
|
| 56 |
-
print(f"obj: {obj}")
|
| 57 |
-
if (obj is None) or (obj == config.NOTA):
|
| 58 |
-
return [modify_request]
|
| 59 |
-
|
| 60 |
-
# hack
|
| 61 |
-
if obj == 'building houses for pigs':
|
| 62 |
-
obj = 'houses'
|
| 63 |
-
# return [modify_request]
|
| 64 |
-
|
| 65 |
-
print('-'*20)
|
| 66 |
-
attr_lst = list(config.game_spec[obj].keys())
|
| 67 |
-
attr_list = [f"{i} {o}" for i, o in zip(util.order, attr_lst)]
|
| 68 |
-
s = p.prompt_change_attribute(
|
| 69 |
-
config.game_desc,
|
| 70 |
-
command,
|
| 71 |
-
obj,
|
| 72 |
-
" ".join(attr_list))
|
| 73 |
-
full_prompt = p.get_full_prompt(s)
|
| 74 |
-
if debug >= 2:
|
| 75 |
-
print(f'prompt:{s}')
|
| 76 |
-
|
| 77 |
-
res = bird.query(full_prompt)
|
| 78 |
-
if debug >= 1:
|
| 79 |
-
print(res)
|
| 80 |
-
if debug >= 1:
|
| 81 |
-
print(res, attr_lst)
|
| 82 |
-
attr = util.extract_result(res, attr_lst)
|
| 83 |
-
if debug:
|
| 84 |
-
print(f"attr: {attr}")
|
| 85 |
-
if (attr is None) or (attr == config.NOTA):
|
| 86 |
-
return [modify_request, (obj,)]
|
| 87 |
-
|
| 88 |
-
print('-'*20)
|
| 89 |
-
verb_lst = list(config.game_spec[obj][attr])
|
| 90 |
-
verb_list = [f"{i} {o}" for i, o in zip(util.order, verb_lst)]
|
| 91 |
-
s = p.prompt_how_to_change_attribute(
|
| 92 |
-
config.game_desc,
|
| 93 |
-
command,
|
| 94 |
-
obj,
|
| 95 |
-
attr,
|
| 96 |
-
" ".join(verb_list))
|
| 97 |
-
full_prompt = p.get_full_prompt(s)
|
| 98 |
-
if debug >= 2:
|
| 99 |
-
print(f'prompt:{s}')
|
| 100 |
-
|
| 101 |
-
res = bird.query(full_prompt)
|
| 102 |
-
# print(verb_lst)
|
| 103 |
-
verb = util.extract_result(res, verb_lst)
|
| 104 |
-
if debug >= 1:
|
| 105 |
-
print(f"verb: {verb}")
|
| 106 |
-
if (verb is None) or (verb == config.NOTA):
|
| 107 |
-
return [modify_request, (obj, attr)]
|
| 108 |
-
|
| 109 |
-
return [obj, attr, verb]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
games/angrybirds/old/util.py
DELETED
|
@@ -1,34 +0,0 @@
|
|
| 1 |
-
# util classes and functions
|
| 2 |
-
|
| 3 |
-
class util:
|
| 4 |
-
api_key = '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'
|
| 5 |
-
order = [
|
| 6 |
-
"(A)",
|
| 7 |
-
"(B)",
|
| 8 |
-
"(C)",
|
| 9 |
-
"(D)",
|
| 10 |
-
"(E)",
|
| 11 |
-
"(F)",
|
| 12 |
-
"(G)",
|
| 13 |
-
"(H)",
|
| 14 |
-
"(I)",
|
| 15 |
-
"(J)",
|
| 16 |
-
"(K)",
|
| 17 |
-
"(L)",
|
| 18 |
-
"(M)",
|
| 19 |
-
]
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
@staticmethod
|
| 23 |
-
def extract_result(res, alist):
|
| 24 |
-
# search for "(A)"
|
| 25 |
-
for ix in util.order:
|
| 26 |
-
if res.find(ix) != -1:
|
| 27 |
-
idx = util.order.index(ix)
|
| 28 |
-
return alist[idx]
|
| 29 |
-
|
| 30 |
-
# searc for "bird"
|
| 31 |
-
for e in alist:
|
| 32 |
-
if res.find(e) != -1:
|
| 33 |
-
return e
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|