Skip to content

Commit

Permalink
add error handling for when agents don't submit a guess
Browse files Browse the repository at this point in the history
  • Loading branch information
bovard committed Dec 14, 2023
1 parent 29cd76f commit fd4e614
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions kaggle_environments/envs/llm_20_questions/llm_20_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ def interpreter(state, env):
if active1 is not None:
guessed = False
if active1.observation.role == "guesser":
if active1.observation.turnType == "ask":
if not active1.action:
active1.status = "ERROR"
elif active1.observation.turnType == "ask":
active1.observation.questions.append(active1.action)
inactive1.observation.questions.append(active1.action)
elif active1.observation.turnType == "guess":
active1.observation.guesses.append(active1.action)
inactive1.observation.guesses.append(active1.action)
if keyword_guessed(active1.action):
if active1.action and keyword_guessed(active1.action):
guessed = True
score = 20 - int(step / 3)
active1.reward = score
Expand All @@ -120,12 +122,14 @@ def interpreter(state, env):
active1.observation.keyword = keyword
active1.observation.category = category
response = active1.action
if response.lower().__contains__("yes"):
if not response:
active1.status = "ERROR"
elif response and response.lower().__contains__("yes"):
response = "yes"
elif response.lower().__contains__("no"):
elif response and response.lower().__contains__("no"):
response = "no"
else:
response = "maybe"
active1.status = "ERROR"
active1.observation.answers.append(response)
inactive1.observation.answers.append(response)

Expand All @@ -151,13 +155,15 @@ def interpreter(state, env):
if active2 is not None:
guessed = False
if active2.observation.role == "guesser":
if active2.observation.turnType == "ask":
if not active2.action:
active2.status = "ERROR"
elif active2.observation.turnType == "ask":
active2.observation.questions.append(active2.action)
inactive2.observation.questions.append(active2.action)
elif active2.observation.turnType == "guess":
active2.observation.guesses.append(active2.action)
inactive2.observation.guesses.append(active2.action)
if keyword_guessed(active2.action):
if active2.action and keyword_guessed(active2.action):
guessed = True
score = 20 - int(step / 3)
active2.reward = score
Expand All @@ -172,12 +178,14 @@ def interpreter(state, env):
active2.observation.keyword = keyword
active2.observation.category = category
response = active2.action
if response.lower().__contains__("yes"):
if not response:
active2.status = "ERROR"
elif response.lower().__contains__("yes"):
response = "yes"
elif response.lower().__contains__("no"):
response = "no"
else:
response = "maybe"
active2.status = "ERROR"
active2.observation.answers.append(response)
inactive2.observation.answers.append(response)

Expand Down

0 comments on commit fd4e614

Please sign in to comment.