More training, only do dialog stuff on npcs

main
Cameron Murphy Reikes 2 years ago
parent 7476d25edd
commit 381480873f

@ -2312,59 +2312,61 @@ void frame(void)
{
assert(!(it->exists && it->generation == 0));
#ifdef WEB
if(it->gen_request_id != 0)
if(it->is_npc)
{
assert(it->gen_request_id > 0);
int status = EM_ASM_INT({
return get_generation_request_status($0);
}, it->gen_request_id);
if(status == 0)
if(it->gen_request_id != 0)
{
// simply not done yet
}
else
{
if(status == 1)
assert(it->gen_request_id > 0);
int status = EM_ASM_INT({
return get_generation_request_status($0);
}, it->gen_request_id);
if(status == 0)
{
// simply not done yet
}
else
{
// done! we can get the string
char sentence_str[MAX_SENTENCE_LENGTH] = {0};
EM_ASM({
let generation = get_generation_request_content($0);
stringToUTF8(generation, $1, $2);
}, it->gen_request_id, sentence_str, ARRLEN(sentence_str));
if(status == 1)
{
// done! we can get the string
char sentence_str[MAX_SENTENCE_LENGTH] = {0};
EM_ASM({
let generation = get_generation_request_content($0);
stringToUTF8(generation, $1, $2);
}, it->gen_request_id, sentence_str, ARRLEN(sentence_str));
// parse out from the sentence NPC action and dialog
Perception out = {0};
bool text_was_well_formatted = parse_ai_response(it, sentence_str, &out);
// parse out from the sentence NPC action and dialog
Perception out = {0};
bool text_was_well_formatted = parse_ai_response(it, sentence_str, &out);
if(text_was_well_formatted)
{
process_perception(it, out);
if(text_was_well_formatted)
{
process_perception(it, out);
}
else
{
it->perceptions_dirty = true; // on poorly formatted AI, just retry request.
}
EM_ASM({
done_with_generation_request($0);
}, it->gen_request_id);
}
else
else if(status == 2)
{
it->perceptions_dirty = true; // on poorly formatted AI, just retry request.
Log("Failed to generate dialog! Fuck!");
// need somethin better here. Maybe each sentence has to know if it's player or NPC, that way I can remove the player's dialog
process_perception(it, (Perception){.type = NPCDialog, .npc_action_type = ACT_none, .npc_dialog = SENTENCE_CONST("I'm not sure...")});
}
EM_ASM({
done_with_generation_request($0);
}, it->gen_request_id);
it->gen_request_id = 0;
}
else if(status == 2)
{
Log("Failed to generate dialog! Fuck!");
// need somethin better here. Maybe each sentence has to know if it's player or NPC, that way I can remove the player's dialog
process_perception(it, (Perception){.type = NPCDialog, .npc_action_type = ACT_none, .npc_dialog = SENTENCE_CONST("I'm not sure...")});
}
it->gen_request_id = 0;
}
}
#endif
if(fabsf(it->vel.x) > 0.01f)
it->facing_left = it->vel.x < 0.0f;
if(it->dead)
{
it->dead_time += dt;

@ -188,6 +188,7 @@ void fill_available_actions(Entity *it, AvailableActions *a)
void process_perception(Entity *it, Perception p)
{
assert(it->is_npc);
if(p.type != NPCDialog) it->perceptions_dirty = true;
if(!BUFF_HAS_SPACE(&it->remembered_perceptions)) BUFF_REMOVE_FRONT(&it->remembered_perceptions);
BUFF_APPEND(&it->remembered_perceptions, p);

@ -151,6 +151,24 @@ TrainingSample samples[] = {
NPCDoSay(ACT_leaves_player, "As you wish."),
},
},
{
.npc_kind = NPC_OldMan,
.perceptions = {
PlayerAct(ACT_hits_npc),
NPCDoSay(ACT_none, "Young man! You must stop death, do not harm me further I'm warning you!"),
PlayerAct(ACT_hits_npc),
NPCDoSay(ACT_fights_player, "That's it! No holds barred, to the death!"),
},
},
{
.npc_kind = NPC_Blocky,
.perceptions = {
PlayerAct(ACT_hits_npc),
NPCSay("I'm warning you, one more hit and it's curtains for you"),
PlayerAct(ACT_hits_npc),
NPCDoSay(ACT_fights_player, "Although I stood here before, today I move and FIGHT!"),
},
},
};

@ -308,7 +308,7 @@ func index(w http.ResponseWriter, req *http.Request) {
ctx := context.Background()
req := gogpt.CompletionRequest {
Model: "curie:ft-alnar-games-2023-03-31-03-25-44",
Model: "curie:ft-alnar-games-2023-03-31-04-24-33",
MaxTokens: 80,
Prompt: promptString,
Temperature: 0.9,

Loading…
Cancel
Save