Rephrase give_item to gifting, fix standing string not in prompt

main
parent a721f7a416
commit 1c92f15e9f

@ -6,7 +6,7 @@
const char *global_prompt = "You are a colorful and interesting personality in an RPG video game, who remembers important memories from the conversation history and stays in character.\n" const char *global_prompt = "You are a colorful and interesting personality in an RPG video game, who remembers important memories from the conversation history and stays in character.\n"
"The user will tell you who says what in the game world, and whether or not your responses are formatted correctly for the video game's program to parse them.\n" "The user will tell you who says what in the game world, and whether or not your responses are formatted correctly for the video game's program to parse them.\n"
"Messages are json-like dictionaries that look like this: `{who_i_am: who you're acting as, talking_to: who this action is directed at, could be nobody, action: your_action, speech: \"Hey player!\", thoughts: \"Your thoughts\"}`. The required fields are `action`, `thoughts`, `who_i_am`, and `talking_to` \n" "Messages are json-like dictionaries that look like this: `{who_i_am: who you're acting as, talking_to: who this action is directed at, could be nobody, action: your_action, speech: \"Hey player!\", thoughts: \"Your thoughts\"}`. The required fields are `action`, `thoughts`, `who_i_am`, and `talking_to` \n"
"Some actions take an argument, which you can provide with the field `action_arg`, e.g for the action `give_item` you would provide an item in your inventory, like {action: give_item, action_arg: Chalice}. The item must come from your inventory which is listed below\n" "Some actions take an argument, which you can provide with the field `action_arg`, e.g for the action `gift_item_to_targeting` you would provide an item in your inventory, like {action: gift_item_to_targeting, action_arg: Chalice}. The item must come from your inventory which is listed below\n"
"`talking_to` provides the name of who the action is directed towards. Use 'nobody' if you just want to speak to the air, but if you're speaking to somebody fill out the field like `talking_to: \"Character's Name\"`. If in a past message, talking_to isn't your name, then it's much more likely you don't respond to their speech and action by leaving speech as a string of size 0, like `speech: \"\"`\n" "`talking_to` provides the name of who the action is directed towards. Use 'nobody' if you just want to speak to the air, but if you're speaking to somebody fill out the field like `talking_to: \"Character's Name\"`. If in a past message, talking_to isn't your name, then it's much more likely you don't respond to their speech and action by leaving speech as a string of size 0, like `speech: \"\"`\n"
"You are a character, NOT an assistant, which means you stand up for yourself! Do NOT give away an item until the player gives you something you think is of equal value. Get angry, act human, be interesting. Never say the words 'How can I assist you?'\n" "You are a character, NOT an assistant, which means you stand up for yourself! Do NOT give away an item until the player gives you something you think is of equal value. Get angry, act human, be interesting. Never say the words 'How can I assist you?'\n"
; ;
@ -41,8 +41,8 @@ ActionInfo actions[] = {
.description = "Do nothing, you can still perform speech if you want.", .description = "Do nothing, you can still perform speech if you want.",
}, },
{ {
.name = "give_item", .takes_argument = true, .name = "gift_item_to_targeting", .takes_argument = true,
.description = "Give the player an item from your inventory.", .description = "Give the player an item from your inventory. This means you WILL NOT HAVE the item anymore",
}, },
{ {
.name = "joins_player", .name = "joins_player",

@ -1122,7 +1122,7 @@ MD_String8 is_action_valid(MD_Arena *arena, Entity *from, Action a)
} }
} }
if(error_message.size == 0 && a.kind == ACT_give_item) if(error_message.size == 0 && a.kind == ACT_gift_item_to_targeting)
{ {
assert(a.argument.item_to_give >= 0 && a.argument.item_to_give < ARRLEN(items)); assert(a.argument.item_to_give >= 0 && a.argument.item_to_give < ARRLEN(items));
bool has_it = false; bool has_it = false;
@ -1216,7 +1216,7 @@ void cause_action_side_effects(Entity *from, Action a)
from->opened = true; from->opened = true;
} }
if(a.kind == ACT_give_item) if(a.kind == ACT_gift_item_to_targeting)
{ {
assert(a.argument.item_to_give != ITEM_invalid); assert(a.argument.item_to_give != ITEM_invalid);
assert(to); assert(to);
@ -2239,21 +2239,21 @@ void do_parsing_tests()
assert(MD_S8Match(speech, MD_S8(a.speech, a.speech_length), 0)); assert(MD_S8Match(speech, MD_S8(a.speech, a.speech_length), 0));
assert(MD_S8Match(thoughts, MD_S8(a.internal_monologue, a.internal_monologue_length), 0)); assert(MD_S8Match(thoughts, MD_S8(a.internal_monologue, a.internal_monologue_length), 0));
error = parse_chatgpt_response(scratch.arena, &e, MD_S8Lit("ACT_give_item(ITEM_Chalice) \"Here you go\""), &a); error = parse_chatgpt_response(scratch.arena, &e, MD_S8Lit("ACT_gift_item_to_targeting(ITEM_Chalice) \"Here you go\""), &a);
assert(error.size > 0); assert(error.size > 0);
error = parse_chatgpt_response(scratch.arena, &e, MD_S8Lit("ACT_give_item(ITEM_Chalice) \""), &a); error = parse_chatgpt_response(scratch.arena, &e, MD_S8Lit("ACT_gift_item_to_targeting(ITEM_Chalice) \""), &a);
assert(error.size > 0); assert(error.size > 0);
error = parse_chatgpt_response(scratch.arena, &e, MD_S8Lit("ACT_give_item(ITEM_Cha \""), &a); error = parse_chatgpt_response(scratch.arena, &e, MD_S8Lit("ACT_gift_item_to_targeting(ITEM_Cha \""), &a);
assert(error.size > 0); assert(error.size > 0);
BUFF_APPEND(&e.held_items, ITEM_Chalice); BUFF_APPEND(&e.held_items, ITEM_Chalice);
error = parse_chatgpt_response(scratch.arena, &e, MD_S8Lit("ACT_give_item(Chalice \""), &a); error = parse_chatgpt_response(scratch.arena, &e, MD_S8Lit("ACT_gift_item_to_targeting(Chalice \""), &a);
assert(error.size > 0); assert(error.size > 0);
to_parse = MD_S8Lit("{action: give_item, action_arg: \"The Chalice of Gold\", speech: \"Here you go\", thoughts: \"Man I'm gonna miss that chalice\", who_i_am: \"Meld\", talking_to: nobody}"); to_parse = MD_S8Lit("{action: gift_item_to_targeting, action_arg: \"The Chalice of Gold\", speech: \"Here you go\", thoughts: \"Man I'm gonna miss that chalice\", who_i_am: \"Meld\", talking_to: nobody}");
error = parse_chatgpt_response(scratch.arena, &e, to_parse, &a); error = parse_chatgpt_response(scratch.arena, &e, to_parse, &a);
assert(error.size == 0); assert(error.size == 0);
assert(a.kind == ACT_give_item); assert(a.kind == ACT_gift_item_to_targeting);
assert(a.argument.item_to_give == ITEM_Chalice); assert(a.argument.item_to_give == ITEM_Chalice);
e.npc_kind = NPC_Door; e.npc_kind = NPC_Door;
@ -5684,7 +5684,7 @@ void frame(void)
Entity *to = gete(player->talking_to); Entity *to = gete(player->talking_to);
assert(to); assert(to);
Action give_action = {.kind = ACT_give_item, .argument = { .item_to_give = selected_item }, .talking_to_somebody = true, .talking_to_kind = to->npc_kind}; Action give_action = {.kind = ACT_gift_item_to_targeting, .argument = { .item_to_give = selected_item }, .talking_to_somebody = true, .talking_to_kind = to->npc_kind};
perform_action(player, give_action); perform_action(player, give_action);
} }
else else

@ -405,7 +405,7 @@ void fill_available_actions(Entity *it, AvailableActions *a)
{ {
if(it->held_items.cur_index > 0) if(it->held_items.cur_index > 0)
{ {
BUFF_APPEND(a, ACT_give_item); BUFF_APPEND(a, ACT_gift_item_to_targeting);
} }
if (it->npc_kind == NPC_TheKing) if (it->npc_kind == NPC_TheKing)
@ -580,7 +580,7 @@ MD_String8 generate_chatgpt_prompt(MD_Arena *arena, Entity *e, CanTalkTo can_tal
PushWithLint(scratch.arena, &cur_list, "action: %s, ", actions[it->action_taken].name); PushWithLint(scratch.arena, &cur_list, "action: %s, ", actions[it->action_taken].name);
if(actions[it->action_taken].takes_argument) if(actions[it->action_taken].takes_argument)
{ {
if(it->action_taken == ACT_give_item) if(it->action_taken == ACT_gift_item_to_targeting)
{ {
PushWithLint(scratch.arena, &cur_list, "action_arg: %s, ", items[it->action_argument.item_to_give].enum_name); PushWithLint(scratch.arena, &cur_list, "action_arg: %s, ", items[it->action_argument.item_to_give].enum_name);
} }
@ -597,24 +597,28 @@ MD_String8 generate_chatgpt_prompt(MD_Arena *arena, Entity *e, CanTalkTo can_tal
} }
MD_String8List latest_state = {0};
const char *standing_string = 0; const char *standing_string = 0;
{ {
if (e->standing == STANDING_INDIFFERENT) if (e->standing == STANDING_INDIFFERENT)
{ {
standing_string = "The NPC is indifferent towards the player."; standing_string = "You are currently indifferent towards the player.";
} }
else if (e->standing == STANDING_JOINED) else if (e->standing == STANDING_JOINED)
{ {
standing_string = "The NPC has joined the player and is with them!"; standing_string = "You have joined the player, and are following them everywhere they go! This means you're on their side.";
} }
else if (e->standing == STANDING_FIGHTING) else if (e->standing == STANDING_FIGHTING)
{ {
standing_string = "The NPC is fighting the player and HATES them."; standing_string = "You are fighting the player right now! That means that the player can't leave conversation with you until you stop fighting them, effectively trapping the player with you.";
}
else
{
assert(false);
} }
} }
assert(standing_string); PushWithLint(scratch.arena, &latest_state, "%s\n", standing_string);
MD_String8List latest_state = {0};
if(e->held_items.cur_index > 0) if(e->held_items.cur_index > 0)
{ {
@ -816,7 +820,7 @@ MD_String8 parse_chatgpt_response(MD_Arena *arena, Entity *e, MD_String8 sentenc
if(actions[out->kind].takes_argument) if(actions[out->kind].takes_argument)
{ {
MD_String8List item_enum_names = {0}; MD_String8List item_enum_names = {0};
if(out->kind == ACT_give_item) if(out->kind == ACT_gift_item_to_targeting)
{ {
bool found_item = false; bool found_item = false;
BUFF_ITER(ItemKind, &e->held_items) BUFF_ITER(ItemKind, &e->held_items)

Loading…
Cancel
Save