diff --git a/character_info.h b/character_info.h index 654aab2..377c1b5 100644 --- a/character_info.h +++ b/character_info.h @@ -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 = "The Player said \"Hey\" to Daniel\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" "Daniel said \"What could you possibly want from me?\" to The Player\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" ; \ No newline at end of file diff --git a/main.c b/main.c index a562a97..2500c63 100644 --- a/main.c +++ b/main.c @@ -668,7 +668,7 @@ ISANERROR("Only know how to do desktop http requests on windows") #endif // DESKTOP #ifdef WEB -int make_generation_request(String8 prompt) +int make_generation_request(String8 prompt_str) { 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)); @@ -1774,10 +1774,12 @@ CanTalkTo get_can_talk_to(Entity *e) 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) { - 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; } } @@ -3566,7 +3568,7 @@ void init(void) shifted_farmer_armature = load_armature(persistent_arena, binary_file, S8Lit("Farmer.bin")); 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); @@ -6257,16 +6259,18 @@ void frame(void) case GEN_NotDoneYet: break; case GEN_Success: + { 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) { Log("Starts with yes, success!\n"); gs.won = true; } - else if(S8FindSubstring(TextChunkString8(generated), S8Lit("no"), 0, StringMatchFlag_CaseInsensitive) == generated.text_length) + else if (S8FindSubstring(TextChunkString8(generated), S8Lit("no"), 0, StringMatchFlag_CaseInsensitive) == generated.text_length) { Log("WARNING: generated judgement string '%.*s', doesn't match yes or no, and so is nonsensical! AI acting up!\n", TextChunkVArg(generated)); } + } break; case GEN_Failed: having_errors = true; diff --git a/makeprompt.h b/makeprompt.h index 49ef936..6adb4fa 100644 --- a/makeprompt.h +++ b/makeprompt.h @@ -262,9 +262,7 @@ typedef struct Entity float dialog_fade; RememberedError *errorlist_first; RememberedError *errorlist_last; -#ifdef DESKTOP int times_talked_to; // for better mocked response string -#endif float loading_anim_in; Memory *memories_first; Memory *memories_last; diff --git a/server/main.go b/server/main.go index 2d6d7b3..3f5ff0a 100644 --- a/server/main.go +++ b/server/main.go @@ -508,7 +508,11 @@ func main() { logResponses = os.Getenv("LOG_RESPONSES") != "" 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) http.HandleFunc("/completion", completion) diff --git a/todo.txt b/todo.txt index db08124..38554ad 100644 --- a/todo.txt +++ b/todo.txt @@ -28,6 +28,7 @@ Long distance: - nocodegen instead of codegen argument - Blur game on bitmap modal input mode - 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 - 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