Get building on web, save more issues with interacting with far away players, ensure judgement is harsher. On server warn clearer when no cors

main
parent 5bb20c8e6e
commit 0194c3e812

@ -165,7 +165,10 @@ CharacterGen characters[] = {
}, },
}; };
char *judgement_system_prompt = "You are to judge if, in given conversation and action history from a video game, the player has successfully caused a great transformation in Daniel. You must ONLY respond with either 'yes' or 'no', and no explanation."; char *judgement_system_prompt =
"You are to judge if, in given conversation and action history from a video game, the player has successfully caused a great transformation in Daniel. You must ONLY respond with either 'yes' or 'no', and no explanation.\n"
"Be cautious with saying yes. This causes the player to win and save Daniel's life. Only say yes if you think, based on the history, Daniel has truly changed his ways and evolved as a person.\n"
;
char *judgement_yes_example = char *judgement_yes_example =
"The Player said \"Hey\" to Daniel\n" "The Player said \"Hey\" to Daniel\n"
"Daniel said \"What do you want?\" to The Player\n" "Daniel said \"What do you want?\" to The Player\n"
@ -182,4 +185,5 @@ char *judgement_no_example = "The Player said \"fjdskfjskj\" to Daniel\n"
char *judgement_no2_example = "The Player said \"hey\" to Daniel\n" char *judgement_no2_example = "The Player said \"hey\" to Daniel\n"
"Daniel said \"What could you possibly want from me?\" to The Player\n" "Daniel said \"What could you possibly want from me?\" to The Player\n"
"The Player said \"I want to change you\" to Daniel\n" "The Player said \"I want to change you\" to Daniel\n"
"Daniel said \"HA! You couldn't possibly change me\" to The Player\n"
; ;

@ -668,7 +668,7 @@ ISANERROR("Only know how to do desktop http requests on windows")
#endif // DESKTOP #endif // DESKTOP
#ifdef WEB #ifdef WEB
int make_generation_request(String8 prompt) int make_generation_request(String8 prompt_str)
{ {
ArenaTemp scratch = GetScratch(0, 0); ArenaTemp scratch = GetScratch(0, 0);
String8 terminated_completion_url = nullterm(scratch.arena, FmtWithLint(scratch.arena, "%s://%s:%d/completion", IS_SERVER_SECURE ? "https" : "http", SERVER_DOMAIN, SERVER_PORT)); String8 terminated_completion_url = nullterm(scratch.arena, FmtWithLint(scratch.arena, "%s://%s:%d/completion", IS_SERVER_SECURE ? "https" : "http", SERVER_DOMAIN, SERVER_PORT));
@ -1774,10 +1774,12 @@ CanTalkTo get_can_talk_to(Entity *e)
Entity *get_targeted(Entity *from, NpcKind targeted) Entity *get_targeted(Entity *from, NpcKind targeted)
{ {
bool ignore_radius = from->npc_kind == NPC_Player || targeted == NPC_Player; // player conversations can go across the map to make sure the player always sees them
ENTITIES_ITER(gs.entities) ENTITIES_ITER(gs.entities)
{ {
if(it != from && (it->is_npc) && LenV2(SubV2(it->pos, from->pos)) < PROPAGATE_ACTIONS_RADIUS && it->npc_kind == targeted) if(it != from && (it->is_npc) && it->npc_kind == targeted)
{ {
if(ignore_radius || LenV2(SubV2(it->pos, from->pos)) < PROPAGATE_ACTIONS_RADIUS)
return it; return it;
} }
} }
@ -3566,7 +3568,7 @@ void init(void)
shifted_farmer_armature = load_armature(persistent_arena, binary_file, S8Lit("Farmer.bin")); shifted_farmer_armature = load_armature(persistent_arena, binary_file, S8Lit("Farmer.bin"));
shifted_farmer_armature.image = image_shifted_farmer; shifted_farmer_armature.image = image_shifted_farmer;
Log("Done. Used %f of the frame arena, %llu kB\n", (double) frame_arena->pos / (double)frame_arena->cap, (frame_arena->pos/1024)); Log("Done. Used %f of the frame arena, %d kB\n", (double) frame_arena->pos / (double)frame_arena->cap, (int)(frame_arena->pos/1024));
ArenaClear(frame_arena); ArenaClear(frame_arena);
@ -6257,6 +6259,7 @@ void frame(void)
case GEN_NotDoneYet: case GEN_NotDoneYet:
break; break;
case GEN_Success: case GEN_Success:
{
TextChunk generated = gen_request_content(gs.judgement_gen_request); TextChunk generated = gen_request_content(gs.judgement_gen_request);
if (generated.text_length > 0 && S8FindSubstring(TextChunkString8(generated), S8Lit("yes"), 0, StringMatchFlag_CaseInsensitive) == 0) if (generated.text_length > 0 && S8FindSubstring(TextChunkString8(generated), S8Lit("yes"), 0, StringMatchFlag_CaseInsensitive) == 0)
{ {
@ -6267,6 +6270,7 @@ void frame(void)
{ {
Log("WARNING: generated judgement string '%.*s', doesn't match yes or no, and so is nonsensical! AI acting up!\n", TextChunkVArg(generated)); Log("WARNING: generated judgement string '%.*s', doesn't match yes or no, and so is nonsensical! AI acting up!\n", TextChunkVArg(generated));
} }
}
break; break;
case GEN_Failed: case GEN_Failed:
having_errors = true; having_errors = true;

@ -262,9 +262,7 @@ typedef struct Entity
float dialog_fade; float dialog_fade;
RememberedError *errorlist_first; RememberedError *errorlist_first;
RememberedError *errorlist_last; RememberedError *errorlist_last;
#ifdef DESKTOP
int times_talked_to; // for better mocked response string int times_talked_to; // for better mocked response string
#endif
float loading_anim_in; float loading_anim_in;
Memory *memories_first; Memory *memories_first;
Memory *memories_last; Memory *memories_last;

@ -508,7 +508,11 @@ func main() {
logResponses = os.Getenv("LOG_RESPONSES") != "" logResponses = os.Getenv("LOG_RESPONSES") != ""
doCors = os.Getenv("CORS") != "" doCors = os.Getenv("CORS") != ""
if doCors { log.Println("Doing cors"); } if doCors {
log.Println("Doing cors");
} else {
log.Println("Warning: Not adding cors header to responses, you should probably be running this through a proxy like nginx that does that! To activate cors set the `CORS` environment variable to anything");
}
c = openai.NewClient(api_key) c = openai.NewClient(api_key)
http.HandleFunc("/completion", completion) http.HandleFunc("/completion", completion)

@ -28,6 +28,7 @@ Long distance:
- nocodegen instead of codegen argument - nocodegen instead of codegen argument
- Blur game on bitmap modal input mode - Blur game on bitmap modal input mode
- Detect when an arena accidentally has more than one ArenaTemp requested of it - Detect when an arena accidentally has more than one ArenaTemp requested of it
- In case of AI failure redact the memories that prompted the character to make a generation request
- Polygon and circle collision with cutec2 probably for the player being unable to collide with the camera bounds, and non axis aligned collision rects - Polygon and circle collision with cutec2 probably for the player being unable to collide with the camera bounds, and non axis aligned collision rects
- set the game in oregon (suggestion by phillip) - set the game in oregon (suggestion by phillip)
- Room system where characters can go to rooms. camera constrained to room bounds, and know which rooms are near them to go to - Room system where characters can go to rooms. camera constrained to room bounds, and know which rooms are near them to go to

Loading…
Cancel
Save