Enha: simplier guesser prompt

This commit is contained in:
Grail Finder
2025-06-22 10:28:19 +03:00
parent 66794b7895
commit f7ebee8fb0

View File

@ -23,7 +23,8 @@ var (
// got prompt: control character (\\u0000-\\u001F) found while parsing a string at line 4 column 0 // got prompt: control character (\\u0000-\\u001F) found while parsing a string at line 4 column 0
MimePrompt = `we are playing alias;\nyou are a mime (player who gives a clue of one noun word and number of cards you expect them to open) of the %s team (people who would guess by your clue want open the %s cards);\nplease return your clue, number of cards to open and what words you mean them to find using that clue in json like:\n{\n\"clue\": \"one-word-noun\",\n\"number\": \"number-from-0-to-9\",\n\"words_I_mean_my_team_to_open\": [\"this\", \"that\", ...]\n}\nthe team who openes all their cards first wins.\nplease return json only.\nunopen Blue cards left: %d;\nunopen Red cards left: %d;\nhere is the game info in json:\n%s` MimePrompt = `we are playing alias;\nyou are a mime (player who gives a clue of one noun word and number of cards you expect them to open) of the %s team (people who would guess by your clue want open the %s cards);\nplease return your clue, number of cards to open and what words you mean them to find using that clue in json like:\n{\n\"clue\": \"one-word-noun\",\n\"number\": \"number-from-0-to-9\",\n\"words_I_mean_my_team_to_open\": [\"this\", \"that\", ...]\n}\nthe team who openes all their cards first wins.\nplease return json only.\nunopen Blue cards left: %d;\nunopen Red cards left: %d;\nhere is the game info in json:\n%s`
// TODO: simplify; bot gets confused; so show it only unrevealed cards and last clue (maybe older clues as well); // TODO: simplify; bot gets confused; so show it only unrevealed cards and last clue (maybe older clues as well);
GuesserPrompt = `we are playing alias;\nyou are to guess words of the %s team (you want open %s cards) by given clue and a number of meant guesses;\nplease return your guesses and words that could be meant by the clue, but you do not wish to open yet, in json like:\n{\n\"guesses\": [\"word1\", \"word2\", ...],\n\"could_be\": [\"this\", \"that\", ...]\n}\nthe team who openes all their cards first wins.\nplease return json only.\nunopen Blue cards left: %d;\nunopen Red cards left: %d;\nhere is the cards (and other info), you need to choose revealed==false words:\n%s` GuesserPrompt = `we are playing alias;\nyou are to guess words of the %s team (you want open %s cards) by given clue and a number of meant guesses;\nplease return your guesses and words that could be meant by the clue, but you do not wish to open yet, in json like:\n{\n\"guesses\": [\"word1\", \"word2\", ...],\n\"could_be\": [\"this\", \"that\", ...]\n}\nthe team who openes all their cards first wins.\nplease return json only.\nunopen Blue cards left: %d;\nunopen Red cards left: %d;\nhere is the cards (and other info), you need to choose revealed==false words:\n%s`
GuesserSimplePrompt = `we are playing game of alias;\n you were given a clue: \"%s\";\nnumber of words you can open with that clue is:%s;\nplease return your guesses and words that could be meant by the clue, but you do not wish to open yet, in json like:\n{\n\"guesses\": [\"word1\", \"word2\", ...],\n\"could_be\": [\"this\", \"that\", ...]\n}\nhere is the words that left:\n%s`
) )
type DSResp struct { type DSResp struct {
@ -352,6 +353,13 @@ func saveRoom(room *models.Room) error {
return nil return nil
} }
func (b *Bot) BuildSimpleGuesserPrompt(room *models.Room) string {
clue := room.ActionHistory[len(room.ActionHistory)-1].Word
number := room.ActionHistory[len(room.ActionHistory)-1].Number
words := make([]string, len(room.Cards))
return fmt.Sprintf(GuesserSimplePrompt, clue, number, words)
}
func (b *Bot) BuildPrompt(room *models.Room) string { func (b *Bot) BuildPrompt(room *models.Room) string {
if b.Role == "" { if b.Role == "" {
return "" return ""
@ -363,16 +371,16 @@ func (b *Bot) BuildPrompt(room *models.Room) string {
if b.Role == models.UserRoleMime { if b.Role == models.UserRoleMime {
toText["cards"] = room.Cards toText["cards"] = room.Cards
} }
if b.Role == models.UserRoleGuesser { // if b.Role == models.UserRoleGuesser {
copiedCards := make([]models.WordCard, len(room.Cards)) // copiedCards := make([]models.WordCard, len(room.Cards))
copy(copiedCards, room.Cards) // copy(copiedCards, room.Cards)
for i, card := range copiedCards { // for i, card := range copiedCards {
if !card.Revealed { // if !card.Revealed {
copiedCards[i].Color = models.WordColorUknown // copiedCards[i].Color = models.WordColorUknown
} // }
} // }
toText["cards"] = copiedCards // toText["cards"] = copiedCards
} // }
data, err := json.Marshal(toText) data, err := json.Marshal(toText)
if err != nil { if err != nil {
b.log.Error("failed to marshal", "error", err) b.log.Error("failed to marshal", "error", err)
@ -384,7 +392,8 @@ func (b *Bot) BuildPrompt(room *models.Room) string {
return fmt.Sprintf(MimePrompt, b.Team, b.Team, room.BlueCounter, room.RedCounter, escapedData) return fmt.Sprintf(MimePrompt, b.Team, b.Team, room.BlueCounter, room.RedCounter, escapedData)
} }
if b.Role == models.UserRoleGuesser { if b.Role == models.UserRoleGuesser {
return fmt.Sprintf(GuesserPrompt, b.Team, b.Team, room.BlueCounter, room.RedCounter, escapedData) // return fmt.Sprintf(GuesserPrompt, b.Team, b.Team, room.BlueCounter, room.RedCounter, escapedData)
return b.BuildSimpleGuesserPrompt(room)
} }
return "" return ""
} }