Eric Botti
commited on
Commit
·
21c7651
1
Parent(s):
587e98a
prompt tweaking, added game rules as system message
Browse files- src/app.py +8 -1
- src/game_chameleon.py +1 -1
- src/message.py +4 -2
- src/prompts.py +17 -7
src/app.py
CHANGED
@@ -6,7 +6,7 @@ from streamlit import session_state
|
|
6 |
from game_chameleon import ChameleonGame
|
7 |
from agent_interfaces import HumanAgentInterface
|
8 |
from message import Message
|
9 |
-
from prompts import fetch_prompt
|
10 |
|
11 |
st.set_page_config(layout="wide", page_title="Chameleon")
|
12 |
|
@@ -16,6 +16,9 @@ def display_message(message: Message):
|
|
16 |
messages_container.markdown(f":green[{message.content}]")
|
17 |
elif message.type == "debug":
|
18 |
messages_container.markdown(f":orange[DEBUG: {message.content}]")
|
|
|
|
|
|
|
19 |
else:
|
20 |
messages_container.markdown(f"{message.content}")
|
21 |
|
@@ -54,6 +57,10 @@ with center:
|
|
54 |
|
55 |
messages_container.write("Welcome to Chameleon! A social deduction game powered by LLMs.")
|
56 |
|
|
|
|
|
|
|
|
|
57 |
messages_container.write("Enter your name to begin...")
|
58 |
|
59 |
user_input = st.chat_input("Your response:")
|
|
|
6 |
from game_chameleon import ChameleonGame
|
7 |
from agent_interfaces import HumanAgentInterface
|
8 |
from message import Message
|
9 |
+
from prompts import fetch_prompt
|
10 |
|
11 |
st.set_page_config(layout="wide", page_title="Chameleon")
|
12 |
|
|
|
16 |
messages_container.markdown(f":green[{message.content}]")
|
17 |
elif message.type == "debug":
|
18 |
messages_container.markdown(f":orange[DEBUG: {message.content}]")
|
19 |
+
elif message.type == "system":
|
20 |
+
# Don't display system message as it is displayed in the "How to Play" expander
|
21 |
+
pass
|
22 |
else:
|
23 |
messages_container.markdown(f"{message.content}")
|
24 |
|
|
|
57 |
|
58 |
messages_container.write("Welcome to Chameleon! A social deduction game powered by LLMs.")
|
59 |
|
60 |
+
rules_expander = messages_container.expander("How to Play", expanded=False)
|
61 |
+
|
62 |
+
rules_expander.markdown(fetch_prompt("game_rules"))
|
63 |
+
|
64 |
messages_container.write("Enter your name to begin...")
|
65 |
|
66 |
user_input = st.chat_input("Your response:")
|
src/game_chameleon.py
CHANGED
@@ -80,7 +80,7 @@ class ChameleonGame(Game):
|
|
80 |
# Check if the game has not been won
|
81 |
if self.game_state != "game_end":
|
82 |
if self.game_state == "game_start":
|
83 |
-
self.game_message(fetch_prompt("game_rules"))
|
84 |
self.game_state = "setup_round"
|
85 |
if self.game_state == "setup_round":
|
86 |
self.setup_round()
|
|
|
80 |
# Check if the game has not been won
|
81 |
if self.game_state != "game_end":
|
82 |
if self.game_state == "game_start":
|
83 |
+
self.game_message(fetch_prompt("game_rules"), message_type="system")
|
84 |
self.game_state = "setup_round"
|
85 |
if self.game_state == "setup_round":
|
86 |
self.setup_round()
|
src/message.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
from typing import Literal, List
|
2 |
from pydantic import BaseModel, computed_field, Field
|
3 |
|
4 |
-
MessageType = Literal["prompt", "info", "agent", "retry", "error", "format", "verbose", "debug"]
|
5 |
|
6 |
message_number = 0
|
7 |
|
@@ -30,7 +30,9 @@ class Message(BaseModel):
|
|
30 |
# This can be counterintuitive since they can be controlled by either human or ai
|
31 |
# Further, The programmatic messages from the game are always "user"
|
32 |
|
33 |
-
if self.type != "
|
|
|
|
|
34 |
return "user"
|
35 |
else:
|
36 |
return "assistant"
|
|
|
1 |
from typing import Literal, List
|
2 |
from pydantic import BaseModel, computed_field, Field
|
3 |
|
4 |
+
MessageType = Literal["prompt", "info", "agent", "retry", "error", "format", "verbose", "debug", "system"]
|
5 |
|
6 |
message_number = 0
|
7 |
|
|
|
30 |
# This can be counterintuitive since they can be controlled by either human or ai
|
31 |
# Further, The programmatic messages from the game are always "user"
|
32 |
|
33 |
+
if self.type != "system":
|
34 |
+
return "system"
|
35 |
+
elif self.type != "agent":
|
36 |
return "user"
|
37 |
else:
|
38 |
return "assistant"
|
src/prompts.py
CHANGED
@@ -10,11 +10,21 @@ def format_prompt(prompt_name, **kwargs):
|
|
10 |
|
11 |
_game_rules = '''\
|
12 |
You are playing a social deduction game where every player pretends the be the same animal.
|
13 |
-
During the round
|
14 |
-
All players know what animal they are pretending to be,
|
15 |
-
The
|
16 |
-
The
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
'''
|
19 |
|
20 |
_assign_herd = """\
|
@@ -22,7 +32,7 @@ You are a **{herd_animal}**, keep this secret at all costs and figure which play
|
|
22 |
"""
|
23 |
|
24 |
_assign_chameleon = """\
|
25 |
-
|
26 |
"""
|
27 |
|
28 |
_player_describe_animal = """It's your turn to describe yourself. Remember:
|
@@ -40,7 +50,7 @@ Your Guess:
|
|
40 |
"""
|
41 |
|
42 |
_vote_prompt = """\
|
43 |
-
|
44 |
Player Responses:
|
45 |
{player_responses}
|
46 |
Your Vote:
|
|
|
10 |
|
11 |
_game_rules = '''\
|
12 |
You are playing a social deduction game where every player pretends the be the same animal.
|
13 |
+
During the round each player gets a turn to describe themselves using an "I"-statement as if they were the animal.
|
14 |
+
All but one of players know what animal they are pretending to be, collectively these players are called the Herd.
|
15 |
+
The remaining player, known as the Chameleon, does not know what animal the others are pretending to be.
|
16 |
+
The Chameleon must blend in by providing details about the animal using context from other players.
|
17 |
+
The Herd must be careful not to give away too much information with their responses so that Chameleon deduce the animal.
|
18 |
+
|
19 |
+
After all players have spoken, two thing will happen:
|
20 |
+
1. The Chameleon will guess what animal the other players are pretending to be
|
21 |
+
2. The Herd will vote on who they think the Chameleon is.
|
22 |
+
|
23 |
+
The game is played in rounds, and the first player to reach 7 points wins. Points are awarded during a round as follows:
|
24 |
+
- If the Chameleon remains undetected, they get +1 point
|
25 |
+
- If the Chameleon guesses the animal correctly, they get +1 point
|
26 |
+
- If a member of the Herd votes for the Chameleon, they get +1 point
|
27 |
+
- If the Chameleon is unable to guess the animal, each member of the Herd gets +1 point
|
28 |
'''
|
29 |
|
30 |
_assign_herd = """\
|
|
|
32 |
"""
|
33 |
|
34 |
_assign_chameleon = """\
|
35 |
+
You are the **Chameleon**, remain undetected and guess what animal the others are pretending to be
|
36 |
"""
|
37 |
|
38 |
_player_describe_animal = """It's your turn to describe yourself. Remember:
|
|
|
50 |
"""
|
51 |
|
52 |
_vote_prompt = """\
|
53 |
+
It's your turn to vote. Choose from the other players who you think the Chameleon is.
|
54 |
Player Responses:
|
55 |
{player_responses}
|
56 |
Your Vote:
|