Enha: difference between cards for mime and revealed for all

This commit is contained in:
Grail Finder
2025-06-30 10:27:54 +03:00
parent 643a9a035a
commit 42c1f461b0
6 changed files with 42 additions and 9 deletions

View File

@ -1,11 +1,21 @@
{{define "cardword"}}
{{if .Revealed}}
{{if eq .Color "amber"}}
<div id="card-{{.Word}}" class="bg-{{.Color}}-100 border border-gray-500 p-4 rounded-lg min-w-[100px] text-center text-white cursor-pointer"
<div id="card-{{.Word}}" class="bg-{{.Color}}-100 border-8 border-stine-400 p-4 min-w-[100px] text-center text-white cursor-pointer"
style="text-shadow: 0 2px 4px rgba(0,0,0,0.9);"> {{.Word}}
</div>
{{else}}
<div id="card-{{.Word}}" class="bg-{{.Color}}-400 border border-gray-500 p-4 rounded-lg min-w-[100px] text-center text-white cursor-pointer"
<div id="card-{{.Word}}" class="bg-{{.Color}}-400 border-8 border-stone-400 p-4 min-w-[100px] text-center text-white cursor-pointer"
style="text-shadow: 0 2px 4px rgba(0,0,0,0.9);"> {{.Word}}
</div>
{{end}}
{{else if .Mime}}
{{if eq .Color "amber"}}
<div id="card-{{.Word}}" class="bg-{{.Color}}-100 border border-stone-400 p-4 rounded-lg min-w-[100px] text-center text-white cursor-pointer"
style="text-shadow: 0 2px 4px rgba(0,0,0,0.9);"> {{.Word}}
</div>
{{else}}
<div id="card-{{.Word}}" class="bg-{{.Color}}-400 border border-stone-400 p-4 rounded-lg min-w-[100px] text-center text-white cursor-pointer"
style="text-shadow: 0 2px 4px rgba(0,0,0,0.9);"> {{.Word}}
</div>
{{end}}

View File

@ -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")

View File

@ -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 {

View File

@ -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 {

View File

@ -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"`
}

View File

@ -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;