Fix: bot opening the same card over and over
This commit is contained in:
@ -86,7 +86,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
|
|||||||
fi.Room.ClearMarks()
|
fi.Room.ClearMarks()
|
||||||
}
|
}
|
||||||
switch string(color) {
|
switch string(color) {
|
||||||
case "black":
|
case string(models.WordColorBlack):
|
||||||
log.Debug("opened black word", "room", fi.Room)
|
log.Debug("opened black word", "room", fi.Room)
|
||||||
// game over
|
// game over
|
||||||
fi.Room.IsRunning = false
|
fi.Room.IsRunning = false
|
||||||
@ -102,7 +102,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
|
|||||||
fi.Room.ThisTurnLimit = 0
|
fi.Room.ThisTurnLimit = 0
|
||||||
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
|
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
|
||||||
fi.Room.ClearMarks()
|
fi.Room.ClearMarks()
|
||||||
case "white", string(oppositeColor):
|
case string(models.WordColorWhite), string(oppositeColor):
|
||||||
log.Debug("opened opposite color word", "room", fi.Room, "opposite-color", oppositeColor)
|
log.Debug("opened opposite color word", "room", fi.Room, "opposite-color", oppositeColor)
|
||||||
// end turn
|
// end turn
|
||||||
fi.Room.TeamTurn = oppositeColor
|
fi.Room.TeamTurn = oppositeColor
|
||||||
|
@ -84,6 +84,7 @@ func (b *Bot) checkGuess(word string, room *models.Room) error {
|
|||||||
room.ActionHistory = append(room.ActionHistory, action)
|
room.ActionHistory = append(room.ActionHistory, action)
|
||||||
// if opened card is of color of opp team, change turn
|
// if opened card is of color of opp team, change turn
|
||||||
oppositeColor := room.GetOppositeTeamColor()
|
oppositeColor := room.GetOppositeTeamColor()
|
||||||
|
room.OpenedThisTurn++
|
||||||
if room.OpenedThisTurn >= room.ThisTurnLimit {
|
if room.OpenedThisTurn >= room.ThisTurnLimit {
|
||||||
// end turn
|
// end turn
|
||||||
room.TeamTurn = oppositeColor
|
room.TeamTurn = oppositeColor
|
||||||
@ -92,7 +93,7 @@ func (b *Bot) checkGuess(word string, room *models.Room) error {
|
|||||||
room.ThisTurnLimit = 0
|
room.ThisTurnLimit = 0
|
||||||
}
|
}
|
||||||
switch string(color) {
|
switch string(color) {
|
||||||
case "black":
|
case string(models.WordColorBlack):
|
||||||
// game over
|
// game over
|
||||||
room.IsRunning = false
|
room.IsRunning = false
|
||||||
room.IsOver = true
|
room.IsOver = true
|
||||||
@ -106,7 +107,7 @@ func (b *Bot) checkGuess(word string, room *models.Room) error {
|
|||||||
Action: models.ActionTypeGameOver,
|
Action: models.ActionTypeGameOver,
|
||||||
}
|
}
|
||||||
room.ActionHistory = append(room.ActionHistory, action)
|
room.ActionHistory = append(room.ActionHistory, action)
|
||||||
case "white", string(oppositeColor):
|
case string(models.WordColorWhite), string(oppositeColor):
|
||||||
// end turn
|
// end turn
|
||||||
room.TeamTurn = oppositeColor
|
room.TeamTurn = oppositeColor
|
||||||
room.MimeDone = false
|
room.MimeDone = false
|
||||||
@ -224,7 +225,7 @@ func (b *Bot) BotMove() {
|
|||||||
}
|
}
|
||||||
if err := b.checkGuess(guess, room); err != nil {
|
if err := b.checkGuess(guess, room); err != nil {
|
||||||
b.log.Warn("failed to check guess", "mimeResp", tempMap, "bot_name", b.BotName, "guess", guess, "error", err)
|
b.log.Warn("failed to check guess", "mimeResp", tempMap, "bot_name", b.BotName, "guess", guess, "error", err)
|
||||||
msg := fmt.Sprintf("failed to check guess", "mimeResp", tempMap, "bot_name", b.BotName, "guess", guess, "error", err)
|
msg := fmt.Sprintf("failed to check guess; mimeResp: %v; bot_name: %s; guess: %s; error: %v", tempMap, b.BotName, guess, err)
|
||||||
room.LogJournal = append(room.LogJournal, msg)
|
room.LogJournal = append(room.LogJournal, msg)
|
||||||
}
|
}
|
||||||
b.log.Info("mime resp log", "guesserResp", tempMap)
|
b.log.Info("mime resp log", "guesserResp", tempMap)
|
||||||
@ -393,6 +394,9 @@ func (b *Bot) BuildSimpleGuesserPrompt(room *models.Room) string {
|
|||||||
// number := room.ActionHistory[len(room.ActionHistory)-1].Number
|
// number := room.ActionHistory[len(room.ActionHistory)-1].Number
|
||||||
words := make([]string, len(room.Cards))
|
words := make([]string, len(room.Cards))
|
||||||
for i, card := range room.Cards {
|
for i, card := range room.Cards {
|
||||||
|
if card.Revealed { // skipped already opened
|
||||||
|
continue
|
||||||
|
}
|
||||||
words[i] = card.Word
|
words[i] = card.Word
|
||||||
}
|
}
|
||||||
return fmt.Sprintf(GuesserSimplePrompt, clueAction.Word, words)
|
return fmt.Sprintf(GuesserSimplePrompt, clueAction.Word, words)
|
||||||
|
1
todos.md
1
todos.md
@ -55,3 +55,4 @@
|
|||||||
- there is a clue window for a mime before game started;
|
- there is a clue window for a mime before game started;
|
||||||
- retry call to llm (if 400|429|4xx);
|
- retry call to llm (if 400|429|4xx);
|
||||||
- when llm guesses the word it is not removed from a pool of words making it keep guessing it;
|
- 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);
|
||||||
|
Reference in New Issue
Block a user