Kim Adams commited on
Commit
d77bc0c
·
1 Parent(s): dbf30ea

added topic/players to game to see why games are suggested

Browse files
create_games/__pycache__/create_games_slack.cpython-311.pyc CHANGED
Binary files a/create_games/__pycache__/create_games_slack.cpython-311.pyc and b/create_games/__pycache__/create_games_slack.cpython-311.pyc differ
 
create_games/create_games_slack.py CHANGED
@@ -80,9 +80,9 @@ def GenerateGameIdeas(common_topic, group, gameType):
80
  print("\n\n---GenerateGameIdeas: common_topic", common_topic, "gameType: ",gameType)
81
  prompt=None
82
  if gameType==constants.CHAT:
83
- prompt = f"""Given this game topic '{common_topic}', create a chat-based game that a player can play against YOU via chat interface (Type=Chat). Refer to yourself as BuildBot. Provide 1-2 Tips, example questions to get players started (Tip=Ask about color). Include 1-3 Rules that explain how to play. Keep answers short. Answer must be in JSON, in this format: {{"Name":"Name of game", "Description":"Game rules", "Type":"Draw or Chat", "Rules":"Some rules for the game.", "Tips":"String of 1-2 questions to get players started", "InitialQuestion":"Pose the first question that starts the game."}}"""
84
  elif gameType==constants.DRAW:
85
- prompt = f"""Given this game topic '{common_topic}', create a drawing-based game where a player draws a single thing. Include simple rules for how to play and the first thing for them to draw (InitialQuestion). Keep answers short. Answer must be in JSON, in this format: {{"Name": "Name of game", "Description": "Game rules", "Rules": "Some rules for the game.", "Tips": "String of 1-2 questions to get players started","InitialQuestion": "Tell the player what to draw first."}}"""
86
  messages=[]
87
  messages.append({"role": "system", "content": prompt})
88
 
@@ -148,19 +148,18 @@ def LoadThemes():
148
 
149
  def CreateGameForGroup(group, gameType, retry=False):
150
  global themes,themes_by_person
151
-
152
  if not retry:
153
  common_topic = FindCommonTheme(group)
154
  else:
155
  common_topic = MostCommonTheme()
156
-
157
  game_ideas,df = GenerateGameIdeas(common_topic, group, gameType)
158
  if game_ideas is None:
159
  if not retry:
160
  retry=True
161
  return CreateGameForGroup(players, retry)
 
 
162
  else:
163
  gameDF=pd.DataFrame(game_ideas)
164
- return gameDF
165
- return None
166
-
 
80
  print("\n\n---GenerateGameIdeas: common_topic", common_topic, "gameType: ",gameType)
81
  prompt=None
82
  if gameType==constants.CHAT:
83
+ prompt = f"""Given this game topic '{common_topic}', create a chat-based game that a player can play against YOU via chat interface. Refer to yourself as BuildBot. Provide 1-2 Tips, example questions to get players started (Tip=Ask about color). Include 1-3 Rules that explain how to play. Keep answers short. Answer must be in JSON, in this format: {{"Name":"Name of game", "Description":"Game rules", "Type":"Draw or Chat", "Rules":"Some rules for the game.", "Tips":"String of 1-2 questions to get players started", "InitialQuestion":"Pose the first question that starts the game."}}"""
84
  elif gameType==constants.DRAW:
85
+ prompt = f"""Given this game topic '{common_topic}', create a drawing-based game where a player draws a single thing. Include 1-3 simple rules for how to play and the first thing for them to draw (InitialQuestion). Keep answers short. Answer must be in JSON, in this format: {{"Name": "Name of game", "Description": "Game rules", "Rules": "Some rules for the game.", "Tips": "String of 1-2 questions to get players started","InitialQuestion": "Tell the player what to draw first."}}"""
86
  messages=[]
87
  messages.append({"role": "system", "content": prompt})
88
 
 
148
 
149
  def CreateGameForGroup(group, gameType, retry=False):
150
  global themes,themes_by_person
 
151
  if not retry:
152
  common_topic = FindCommonTheme(group)
153
  else:
154
  common_topic = MostCommonTheme()
 
155
  game_ideas,df = GenerateGameIdeas(common_topic, group, gameType)
156
  if game_ideas is None:
157
  if not retry:
158
  retry=True
159
  return CreateGameForGroup(players, retry)
160
+ else:
161
+ return None, None
162
  else:
163
  gameDF=pd.DataFrame(game_ideas)
164
+ return gameDF,common_topic
165
+ return None, None
 
create_games/data/game_ideas.json CHANGED
@@ -1,10 +1,9 @@
1
  [
2
  {
3
- "Name": "Shopping Challenge",
4
- "Description": "Shop for items based on given criteria.",
5
- "Type": "Chat",
6
- "Rules": "1. You have to find items that match the given criteria. \n2. You have 10 seconds to find each item. \n3. The game ends when you either find all the items or run out of time.",
7
- "Tips": "Can you find a red dress? \nCan you find a pair of blue sneakers?",
8
- "InitialQuestion": "Ready to start shopping? Find a yellow hat!"
9
  }
10
  ]
 
1
  [
2
  {
3
+ "Name": "Anniversary Art Challenge",
4
+ "Description": "A drawing-based game to celebrate anniversaries.",
5
+ "Rules": "1. Each player takes turns drawing something related to the concept of anniversaries.\n2. Players have a limited amount of time to complete their drawing, such as 1 minute or 3 minutes.\n3. Each player must include the number of years being celebrated in their drawing, like '2' for a 2-year anniversary.\n4. Players can use any art supplies they have available, such as paper, pencils, markers, or digital drawing tools.\n5. After each player completes their drawing, they share it with the other players and explain the meaning behind their artwork.\n6. Players can vote for their favorite drawing based on creativity, interpretation of the theme, and overall aesthetics. The drawing with the most votes wins the round.\n7. The game can continue for multiple rounds, with different players taking turns to draw each time.",
6
+ "Tips": "1. What symbols or images come to mind when you think of anniversaries?\n2. How can you incorporate the number of years being celebrated into your drawing?",
7
+ "InitialQuestion": "Draw a picture that represents a 5-year anniversary."
 
8
  }
9
  ]
home_view/__pycache__/ui_home.cpython-311.pyc CHANGED
Binary files a/home_view/__pycache__/ui_home.cpython-311.pyc and b/home_view/__pycache__/ui_home.cpython-311.pyc differ
 
home_view/ui_home.py CHANGED
@@ -19,7 +19,6 @@ gameDescription=None
19
  gameTips=None
20
  gameRules=None
21
  gameContext=None
22
-
23
  playersValues=[]
24
  selected= []
25
  players=[]
@@ -59,31 +58,6 @@ def SetSelected(playersCB):
59
  print("player_name", player_name)
60
  break
61
 
62
- '''def CreateGame(gamePlay,chat_history):
63
- global players, gameTitle, gamesDF, gameType, gameDescription, gameName, gameTips,initQuestion
64
- print("\n***CreateGame(): gamePlay ", gamePlay)
65
- game_ideas = CreateGameForGroup(players)
66
- gamesDF=game_ideas
67
- if not game_ideas is None:
68
- game_ideas_dict = game_ideas.to_dict('records')
69
- gameType=game_ideas_dict[0]['Type']
70
- gameDescription=game_ideas_dict[0]['Description']
71
- gameName=game_ideas_dict[0]['Name']
72
- gameTips=game_ideas_dict[0]['Tips']
73
- gameRules=game_ideas_dict[0]['Rules']
74
- initQuestion= game_ideas_dict[0]['InitialQuestion']
75
- print("ChatHistory: ", chat_history)
76
- print("gameInit: ", initQuestion)
77
- chat_history.append(("",initQuestion))
78
- if(gamePlay=="Draw"):
79
- print("CreateGame(): gamePlay is Draw")
80
- return gr.update(visible=True), gr.update(visible=True),gr.update(visible=True), gr.update(visible=False), "## You'll be playing "+gameName, gameDescription, gamesDF, gameRules, gameTips,chat_history, gr.update(visible=False)
81
- elif gamePlay=="Chat":
82
- print("CreateGame(): gamePlay is Chat")
83
- return gr.update(visible=True), gr.update(visible=True),gr.update(visible=False), gr.update(visible=True), "## You'll be playing "+gameName, gameDescription, gamesDF, gameRules, gameTips,chat_history, gr.update(visible=False)
84
- print("in NONE case")
85
- return gr.update(visible=False), gr.update(visible=False),gr.update(visible=False),gr.update(visible=False), constants.NO_GAME_TITLE, constants.NO_GAME, None, "", "",chat_history,gr.update(visible=True)
86
- '''
87
  def CreateGame(gamePlay,chat_history,draw):
88
  if gamePlay==constants.DRAW:
89
  return PlayDrawGame(draw)
@@ -92,40 +66,52 @@ def CreateGame(gamePlay,chat_history,draw):
92
 
93
  def PlayDrawGame(draw):
94
  global players
95
- game_ideas = CreateGameForGroup(players, constants.DRAW)
96
  gamesDF=game_ideas
 
97
  if not game_ideas is None:
98
  game_ideas_dict = game_ideas.to_dict('records')
99
  gameDescription=game_ideas_dict[0]['Description']
100
  gameName=game_ideas_dict[0]['Name']
101
- gameTips=game_ideas_dict[0]['Tips']
102
- gameRules=game_ideas_dict[0]['Rules']
 
 
 
 
 
 
103
  initQuestion= "### "+game_ideas_dict[0]['InitialQuestion']
104
- return gr.update(visible=True), gr.update(visible=True),gr.update(visible=True), gr.update(visible=False), ("## You'll be playing "+ gameName), gameDescription, gamesDF, gameRules, gameTips, None, gr.update(visible=False), initQuestion
105
- return gr.update(visible=False), gr.update(visible=False),gr.update(visible=False),gr.update(visible=False), constants.NO_GAME_TITLE, constants.NO_GAME, None, "", "",None,gr.update(visible=True), initQuestion
106
 
107
  def PlayChatGame(chat_history):
108
  global players, gamesDF, gameDescription, gameName, gameTips,initQuestion
109
- print("\n***PlayChatGame()")
110
- game_ideas = CreateGameForGroup(players, constants.CHAT)
111
  gamesDF=game_ideas
 
112
  if not game_ideas is None:
113
  game_ideas_dict = game_ideas.to_dict('records')
114
  gameDescription=game_ideas_dict[0]['Description']
115
  gameName=game_ideas_dict[0]['Name']
116
- gameTips=game_ideas_dict[0]['Tips']
117
- gameRules=game_ideas_dict[0]['Rules']
 
 
 
 
 
 
118
  initQuestion= game_ideas_dict[0]['InitialQuestion']
119
  chat_history.append(("",initQuestion))
120
- return gr.update(visible=True), gr.update(visible=True),gr.update(visible=False), gr.update(visible=True), "## You'll be playing "+gameName, gameDescription, gamesDF, gameRules, gameTips,chat_history, gr.update(visible=False),""
121
- return gr.update(visible=False), gr.update(visible=False),gr.update(visible=False),gr.update(visible=False), constants.NO_GAME_TITLE, constants.NO_GAME, None, "", "",chat_history,gr.update(visible=True),""
122
 
123
  def Reset():
124
  return gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False)
125
 
126
  def Predict(sketch):
127
  confidences = sk.Predict(sketch)
128
- print("Predict():", confidences)
129
  return confidences
130
 
131
  def BuildContext():
@@ -139,8 +125,6 @@ def BuildContext():
139
  def Respond(message, chat_history):
140
  global gameContext
141
  BuildContext()
142
- for item in chat_history:
143
- print("chat_history: ", item)
144
  bot_message,df=simple_chat.ManageChatGame(message, gameContext)
145
  chat_history.append((message, bot_message))
146
  return "", chat_history
@@ -170,9 +154,14 @@ with gr.Blocks() as ui:
170
  with gr.Column():
171
  chatTitle= gr.Markdown ()
172
  chatDesc= gr.Markdown ()
 
 
 
 
 
 
173
  tipTitle=gr.Markdown(constants.QUESTIONS_LABEL)
174
  tips=gr.Markdown(constants.GAME_TIPS)
175
- with gr.Column():
176
  rules=gr.Markdown(constants.RULES_LABEL)
177
  chatRules=gr.Markdown(constants.GAME_DESC)
178
 
@@ -182,7 +171,7 @@ with gr.Blocks() as ui:
182
  with gr.Row(visible=False) as drawGame:
183
  sketch=gr.Image(image_mode="L", source="canvas", width=600, height =600, invert_colors=True, interactive=True,
184
  brush_radius=.5, type="numpy", label="Sketch", show_label=True, show_download_button=False)
185
- label=gr.Label(label="Guesses", show_label=True, show_download_button=False)
186
  with gr.Column(visible=False) as chatGame:
187
  chatbot = gr.Chatbot(label=constants.CHAT_BOT, height=constants.CHAT_BOT_HEIGHT)
188
  msg = gr.Textbox(label=constants.CHAT_BOT_INPUT)
@@ -192,7 +181,7 @@ with gr.Blocks() as ui:
192
  submitBtn=gr.Button(value=constants.SUBMIT, variant="primary")
193
  sketch.change(Predict, inputs=[sketch], outputs=[label])
194
  playersCB.change(SetSelected, inputs=[playersCB], outputs=[])
195
- createBtn.click(CreateGame, inputs=[gamePlay,chatbot], outputs=[pGame, holder, drawGame, chatGame, chatTitle, chatDesc, df4, chatRules, tips, chatbot, gameMaker, drawMD])
196
  msg.submit(Respond, [msg, chatbot], [msg, chatbot])
197
  submitBtn.click(Respond, [msg, chatbot], [msg, chatbot])
198
  resetBtn.click(Reset, [], [pGame, holder,gameMaker,drawGame,chatGame])
 
19
  gameTips=None
20
  gameRules=None
21
  gameContext=None
 
22
  playersValues=[]
23
  selected= []
24
  players=[]
 
58
  print("player_name", player_name)
59
  break
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  def CreateGame(gamePlay,chat_history,draw):
62
  if gamePlay==constants.DRAW:
63
  return PlayDrawGame(draw)
 
66
 
67
  def PlayDrawGame(draw):
68
  global players
69
+ game_ideas,common_topic = CreateGameForGroup(players, constants.DRAW)
70
  gamesDF=game_ideas
71
+ playerNames = ', '.join(players)
72
  if not game_ideas is None:
73
  game_ideas_dict = game_ideas.to_dict('records')
74
  gameDescription=game_ideas_dict[0]['Description']
75
  gameName=game_ideas_dict[0]['Name']
76
+ if isinstance(game_ideas_dict[0]['Tips'], list):
77
+ gameTips = ', '.join(game_ideas_dict[0]['Tips'])
78
+ else:
79
+ gameTips = game_ideas_dict[0]['Tips']
80
+ if isinstance(game_ideas_dict[0]['Rules'], list):
81
+ gameRules = ', '.join(game_ideas_dict[0]['Rules'])
82
+ else:
83
+ gameRules = game_ideas_dict[0]['Rules']
84
  initQuestion= "### "+game_ideas_dict[0]['InitialQuestion']
85
+ return gr.update(visible=True), gr.update(visible=True),gr.update(visible=True), gr.update(visible=False), ("## You'll be playing "+ gameName), gameDescription, gamesDF, gameRules, gameTips, None, gr.update(visible=False), initQuestion, ("### "+common_topic.title()), ("### "+playerNames.title())
86
+ return gr.update(visible=False), gr.update(visible=False),gr.update(visible=False),gr.update(visible=False), constants.NO_GAME_TITLE, constants.NO_GAME, None, "", "",None,gr.update(visible=True), initQuestion, ("### "+common_topic.title()), ("### "+playerNames.title())
87
 
88
  def PlayChatGame(chat_history):
89
  global players, gamesDF, gameDescription, gameName, gameTips,initQuestion
90
+ game_ideas,common_topic = CreateGameForGroup(players, constants.CHAT)
 
91
  gamesDF=game_ideas
92
+ playerNames = ', '.join(players)
93
  if not game_ideas is None:
94
  game_ideas_dict = game_ideas.to_dict('records')
95
  gameDescription=game_ideas_dict[0]['Description']
96
  gameName=game_ideas_dict[0]['Name']
97
+ if isinstance(game_ideas_dict[0]['Tips'], list):
98
+ gameTips = ', '.join(game_ideas_dict[0]['Tips'])
99
+ else:
100
+ gameTips = game_ideas_dict[0]['Tips']
101
+ if isinstance(game_ideas_dict[0]['Rules'], list):
102
+ gameRules = ', '.join(game_ideas_dict[0]['Rules'])
103
+ else:
104
+ gameRules = game_ideas_dict[0]['Rules']
105
  initQuestion= game_ideas_dict[0]['InitialQuestion']
106
  chat_history.append(("",initQuestion))
107
+ return gr.update(visible=True), gr.update(visible=True),gr.update(visible=False), gr.update(visible=True), "## You'll be playing "+gameName, gameDescription, gamesDF, gameRules, gameTips,chat_history, gr.update(visible=False),"", ("### "+common_topic.title()), ("### "+playerNames.title())
108
+ return gr.update(visible=False), gr.update(visible=False),gr.update(visible=False),gr.update(visible=False), constants.NO_GAME_TITLE, constants.NO_GAME, None, "", "",chat_history,gr.update(visible=True),"", ("### "+common_topic.title()), ("### "+playerNames.title())
109
 
110
  def Reset():
111
  return gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False)
112
 
113
  def Predict(sketch):
114
  confidences = sk.Predict(sketch)
 
115
  return confidences
116
 
117
  def BuildContext():
 
125
  def Respond(message, chat_history):
126
  global gameContext
127
  BuildContext()
 
 
128
  bot_message,df=simple_chat.ManageChatGame(message, gameContext)
129
  chat_history.append((message, bot_message))
130
  return "", chat_history
 
154
  with gr.Column():
155
  chatTitle= gr.Markdown ()
156
  chatDesc= gr.Markdown ()
157
+ topic=gr.Markdown(constants.TOPIC)
158
+ gameTopic=gr.Markdown()
159
+ playerNames=gr.Markdown(constants.PLAYER_NAMES)
160
+ players=gr.Markdown()
161
+
162
+ with gr.Column():
163
  tipTitle=gr.Markdown(constants.QUESTIONS_LABEL)
164
  tips=gr.Markdown(constants.GAME_TIPS)
 
165
  rules=gr.Markdown(constants.RULES_LABEL)
166
  chatRules=gr.Markdown(constants.GAME_DESC)
167
 
 
171
  with gr.Row(visible=False) as drawGame:
172
  sketch=gr.Image(image_mode="L", source="canvas", width=600, height =600, invert_colors=True, interactive=True,
173
  brush_radius=.5, type="numpy", label="Sketch", show_label=True, show_download_button=False)
174
+ label=gr.Label(label="Guesses", show_label=True)
175
  with gr.Column(visible=False) as chatGame:
176
  chatbot = gr.Chatbot(label=constants.CHAT_BOT, height=constants.CHAT_BOT_HEIGHT)
177
  msg = gr.Textbox(label=constants.CHAT_BOT_INPUT)
 
181
  submitBtn=gr.Button(value=constants.SUBMIT, variant="primary")
182
  sketch.change(Predict, inputs=[sketch], outputs=[label])
183
  playersCB.change(SetSelected, inputs=[playersCB], outputs=[])
184
+ createBtn.click(CreateGame, inputs=[gamePlay,chatbot,drawMD], outputs=[pGame, holder, drawGame, chatGame, chatTitle, chatDesc, df4, chatRules, tips, chatbot, gameMaker, drawMD, gameTopic, players])
185
  msg.submit(Respond, [msg, chatbot], [msg, chatbot])
186
  submitBtn.click(Respond, [msg, chatbot], [msg, chatbot])
187
  resetBtn.click(Reset, [], [pGame, holder,gameMaker,drawGame,chatGame])
utilities/__pycache__/constants.cpython-311.pyc CHANGED
Binary files a/utilities/__pycache__/constants.cpython-311.pyc and b/utilities/__pycache__/constants.cpython-311.pyc differ
 
utilities/constants.py CHANGED
@@ -12,7 +12,10 @@ NO_GAME="No game created"
12
  NO_GAME_TITLE="Game Title: No game created"
13
  PLAY_GAME="Let's Play!"
14
  BUILDPLAY_LOGO="home_view/art/buildPlay.png"
15
- QUESTIONS_LABEL="### Things to Consider"
 
 
 
16
 
17
  GAME_TYPE="What kind of game would you like to play?"
18
  RULES_LABEL="### Rules"
 
12
  NO_GAME_TITLE="Game Title: No game created"
13
  PLAY_GAME="Let's Play!"
14
  BUILDPLAY_LOGO="home_view/art/buildPlay.png"
15
+ QUESTIONS_LABEL="### Considerations"
16
+ WHYTHISGAME_LABEL="## Why this game?"
17
+ TOPIC="## Common Topic"
18
+ PLAYER_NAMES="## Players"
19
 
20
  GAME_TYPE="What kind of game would you like to play?"
21
  RULES_LABEL="### Rules"