Kim Adams commited on
Commit
741ce5e
·
1 Parent(s): 462f4e8

trying something else for checkboxes

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
@@ -55,14 +55,11 @@ def FindCommonTheme(people_set):
55
  print('theme_counter', theme_counter)
56
  if theme_counter:
57
  # Find the highest frequency among themes
58
- max_count = theme_counter.most_common(1)[0][1]
59
-
60
  # Gather all themes with that frequency
61
- most_common_themes = [theme for theme, count in theme_counter.items() if count == max_count]
62
-
63
  # Randomly choose among them
64
- most_common_theme = choice(most_common_themes)
65
-
66
  print("case 2: shared by most", most_common_theme)
67
  return most_common_theme
68
 
@@ -104,7 +101,7 @@ def GenerateGameIdeas(common_topic, group):
104
  print("No game idea found.")
105
  return None
106
 
107
- def GetPlayers():
108
  players = []
109
  index = 0
110
  for theme in themes:
@@ -112,6 +109,18 @@ def GetPlayers():
112
  if person not in [t[0] for t in players]:
113
  players.append((person, index))
114
  index += 1
 
 
 
 
 
 
 
 
 
 
 
 
115
  return players
116
 
117
  def GetPeopleByThemesDF():
 
55
  print('theme_counter', theme_counter)
56
  if theme_counter:
57
  # Find the highest frequency among themes
58
+ max_count = theme_counter.most_common(1)[0][1]
 
59
  # Gather all themes with that frequency
60
+ most_common_themes = [theme for theme, count in theme_counter.items() if count == max_count]
 
61
  # Randomly choose among them
62
+ most_common_theme = choice(most_common_themes)
 
63
  print("case 2: shared by most", most_common_theme)
64
  return most_common_theme
65
 
 
101
  print("No game idea found.")
102
  return None
103
 
104
+ def GetPlayersAndIndex():
105
  players = []
106
  index = 0
107
  for theme in themes:
 
109
  if person not in [t[0] for t in players]:
110
  players.append((person, index))
111
  index += 1
112
+ print("\n***players", players)
113
+ return players
114
+
115
+ def GetPlayers():
116
+ players = []
117
+ index = 0
118
+ for theme in themes:
119
+ person = theme['person']
120
+ if person not in players:
121
+ players.append((person))
122
+
123
+ print("\n***players", players)
124
  return players
125
 
126
  def GetPeopleByThemesDF():
create_games/data/game_ideas.json CHANGED
@@ -1,7 +1,7 @@
1
  [
2
  {
3
- "Name": "Lost and Found",
4
- "Description": "Players take turns drawing items that have been lost. The player who draws the item that is found first wins the round. The player with the most rounds won at the end of the game is the winner.",
5
- "Rationale": "This game encourages creativity and allows players to practice their drawing skills while having fun."
6
  }
7
  ]
 
1
  [
2
  {
3
+ "Name": "Family Portraits",
4
+ "Description": "Each player takes turns drawing a portrait of their family. The other players must guess who is in the portrait. The player with the most correct guesses wins.",
5
+ "Rationale": "This game encourages creativity and allows players to learn more about each other's families."
6
  }
7
  ]
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
@@ -4,7 +4,7 @@ from home_view.app_theme import SoftBlue
4
  from utilities import constants
5
  from sketch import sketch as sk
6
  from slack_processing.slack_data_prep import FetchSlack, ProcessSlack, CreateEmbeddings
7
- from create_games.create_games_slack import LoadThemes,GetPlayers,CreateGameForGroup,GetPeopleByThemesDF
8
 
9
  startDF=pd.DataFrame()
10
  slackDF=pd.DataFrame()
@@ -25,12 +25,12 @@ def FetchData():
25
  return startDF, slackDF, embeddingsDF, playersDF, gamesDF
26
 
27
  def Init():
28
- global startDF, slackDF, embeddingsDF, gamesDF,players,playersDF,playersValues
29
  startDF=FetchSlack()
30
  slackDF=ProcessSlack()
31
  embeddingsDF=CreateEmbeddings()
32
  gamesDF=LoadThemes()
33
- playersValues=GetPlayers()
34
  playersDF = GetPeopleByThemesDF()
35
  playersCB.choices = playersValues
36
 
@@ -56,8 +56,9 @@ def Predict(sketch):
56
  return confidences
57
 
58
  def CreateGame():
59
- global players,gameTitle
60
  print("CreateGame():", players)
 
61
  game_ideas = CreateGameForGroup(players)
62
  #print("CreateGame():", game_ideas)
63
  if not game_ideas is None:
@@ -76,7 +77,7 @@ with gr.Blocks() as ui:
76
  logo=gr.Image(value=constants.BUILDPLAY_LOGO, width=200, height=200, show_download_button=False, container=False)
77
  directions= gr.Markdown(constants.DIRECTIONS, container=False)
78
  with gr.Column():
79
- playersCB = gr.CheckboxGroup ([], label=constants.PLAYERS, info=constants.PLAYERS_INFO )
80
  createBtn = gr.Button(value=constants.CREATE_GAME, variant="primary")
81
  gameTitle=gr.Markdown(constants.GAME_TITLE, container=False)
82
  desc=gr.TextArea(info=constants.GAME_DESC, interactive=False, show_label=False,
 
4
  from utilities import constants
5
  from sketch import sketch as sk
6
  from slack_processing.slack_data_prep import FetchSlack, ProcessSlack, CreateEmbeddings
7
+ from create_games.create_games_slack import LoadThemes,GetPlayersAndIndex,CreateGameForGroup,GetPeopleByThemesDF
8
 
9
  startDF=pd.DataFrame()
10
  slackDF=pd.DataFrame()
 
25
  return startDF, slackDF, embeddingsDF, playersDF, gamesDF
26
 
27
  def Init():
28
+ global startDF, slackDF, embeddingsDF, gamesDF,playersDF,playersValues
29
  startDF=FetchSlack()
30
  slackDF=ProcessSlack()
31
  embeddingsDF=CreateEmbeddings()
32
  gamesDF=LoadThemes()
33
+ playersValues=GetPlayersAndIndex()
34
  playersDF = GetPeopleByThemesDF()
35
  playersCB.choices = playersValues
36
 
 
56
  return confidences
57
 
58
  def CreateGame():
59
+ global players, gameTitle
60
  print("CreateGame():", players)
61
+ print("playersCB.choices:", playersCB.choices)
62
  game_ideas = CreateGameForGroup(players)
63
  #print("CreateGame():", game_ideas)
64
  if not game_ideas is None:
 
77
  logo=gr.Image(value=constants.BUILDPLAY_LOGO, width=200, height=200, show_download_button=False, container=False)
78
  directions= gr.Markdown(constants.DIRECTIONS, container=False)
79
  with gr.Column():
80
+ playersCB = gr.CheckboxGroup ([], type="value", label=constants.PLAYERS, info=constants.PLAYERS_INFO )
81
  createBtn = gr.Button(value=constants.CREATE_GAME, variant="primary")
82
  gameTitle=gr.Markdown(constants.GAME_TITLE, container=False)
83
  desc=gr.TextArea(info=constants.GAME_DESC, interactive=False, show_label=False,