diff --git a/components/cardword.html b/components/cardword.html index 24df4a3..6fd4612 100644 --- a/components/cardword.html +++ b/components/cardword.html @@ -1,11 +1,21 @@ {{define "cardword"}} {{if .Revealed}} {{if eq .Color "amber"}} -
{{.Word}}
{{else}} -
{{.Word}} +
+ {{end}} +{{else if .Mime}} + {{if eq .Color "amber"}} +
{{.Word}} +
+ {{else}} +
{{.Word}}
{{end}} diff --git a/handlers/game.go b/handlers/game.go index 328e188..d0d5217 100644 --- a/handlers/game.go +++ b/handlers/game.go @@ -84,8 +84,10 @@ func HandleJoinTeam(w http.ResponseWriter, r *http.Request) { return } // reveal all cards - if role == "mime" { - fi.Room.RevealAllCards() + if fi.State.Role == "mime" { + fi.Room.MimeView() // there must be a better way + } else { + fi.Room.GuesserView() } // return html tmpl, err := template.ParseGlob("components/*.html") @@ -163,7 +165,9 @@ func HandleStartGame(w http.ResponseWriter, r *http.Request) { } // reveal all cards if fi.State.Role == "mime" { - fi.Room.RevealAllCards() + fi.Room.MimeView() + } else { + fi.Room.GuesserView() } // return html tmpl, err := template.ParseGlob("components/*.html") diff --git a/handlers/handlers.go b/handlers/handlers.go index b9eefb7..72d0585 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -49,10 +49,11 @@ func HandleHome(w http.ResponseWriter, r *http.Request) { } fi, _ := getFullInfoByCtx(r.Context()) if fi != nil && fi.Room != nil && fi.State != nil { + fi.Room.UpdateCounter() if fi.State.Role == "mime" { - fi.Room.RevealAllCards() + fi.Room.MimeView() // there must be a better way } else { - fi.Room.UpdateCounter() + fi.Room.GuesserView() } } if fi != nil && fi.Room == nil { diff --git a/llmapi/main.go b/llmapi/main.go index b52b5ce..88ef13e 100644 --- a/llmapi/main.go +++ b/llmapi/main.go @@ -26,6 +26,7 @@ var ( // 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` GuesserSimplePrompt = `we are playing game of alias;\n you were given a clue: \"%s\";\nplease return your guess and words that could be meant by the clue, but you do not wish to open yet, in json like:\n{\n\"guess\": \"most_relevant_word_to_the_clue\",\n\"could_be\": [\"this\", \"that\", ...]\n}\nhere is the words that left:\n%v` + MimeSimplePrompt = `we are playing alias;\nyou are to give a clue to your team so they could open these words: %v;\nhere are the words of opposite team you should avoid: %v;\nand here is a black word that is critical not to pick: %s;\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}\nplease return json only.\nunopen Blue cards left: %d;\nunopen Red cards left: %d;` ) func convertToSliceOfStrings(value any) ([]string, error) { @@ -177,7 +178,6 @@ func (b *Bot) BotMove() { // form prompt prompt := b.BuildPrompt(room) b.log.Debug("got prompt", "prompt", prompt) - room.LogJournal = append(room.LogJournal, b.BotName+" got prompt: "+prompt) // call llm llmResp, err := b.CallLLM(prompt) if err != nil { @@ -207,6 +207,8 @@ func (b *Bot) BotMove() { } room.ActionHistory = append(room.ActionHistory, action) room.MimeDone = true + meant := fmt.Sprintf(b.BotName+" meant to open: %v", tempMap["words_I_mean_my_team_to_open"]) + room.LogJournal = append(room.LogJournal, meant) eventPayload = mimeResp.Clue + mimeResp.Number guessLimitU64, err := strconv.ParseUint(mimeResp.Number, 10, 8) if err != nil { diff --git a/models/main.go b/models/main.go index a1cd566..bcbfb89 100644 --- a/models/main.go +++ b/models/main.go @@ -287,6 +287,18 @@ func (r *Room) RevealAllCards() { } } +func (r *Room) MimeView() { + for i := range r.Cards { + r.Cards[i].Mime = true + } +} + +func (r *Room) GuesserView() { + for i := range r.Cards { + r.Cards[i].Mime = false + } +} + func (r *Room) RevealSpecificWord(word string) { for i, card := range r.Cards { if card.Word == word { @@ -299,6 +311,7 @@ type WordCard struct { Word string `json:"word"` Color WordColor `json:"color"` Revealed bool `json:"revealed"` + Mime bool `json:"mime"` // user who sees that card is mime Mark []CardMark `json:"marks"` } diff --git a/todos.md b/todos.md index 26ec84f..792a455 100644 --- a/todos.md +++ b/todos.md @@ -24,7 +24,9 @@ - clear indication that model (llm) is thinking / answered; - different files for each supported lang; - possibly turn markings into parts of names of users (first three letters?); -- sse div to bot thinking +- sse div to bot thinking; +- simplify mime prompt; +- redo card .revealed use: it should mean that card is revealed for everybody, while mime should be able to see cards as is; #### sse points - clue sse update; @@ -57,3 +59,4 @@ - invite link gets cutoff; - when llm guesses the word it is not removed from a pool of words making it keep guessing it; - bot team does not loses their turn after white card (or limit); +- name check does not work;