From db4c21b13333bb3f94ba0b1910bb4a5cc0513df1 Mon Sep 17 00:00:00 2001 From: Guy Davidson Date: Thu, 7 Dec 2023 16:49:27 -0500 Subject: [PATCH] Updated format of JSON games and sampling of the task games, fixed a bug in the quiz --- data/games.json | 30 +++++-------------- src/components/pages/QuizPage.vue | 19 +++++++++--- src/components/pages/Task1Page.vue | 48 +++++++++++++++++++++++++++--- src/stores/smiledata.js | 7 ++++- 4 files changed, 73 insertions(+), 31 deletions(-) diff --git a/data/games.json b/data/games.json index c5924a9..75570cd 100644 --- a/data/games.json +++ b/data/games.json @@ -1,32 +1,18 @@ { - "games": [ - { - "id": 0, - "originalGameId": 1, - "real": true, - "quantile": 0, + "realGames": { + "(1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0)": { "text": "To play this game, pick up a dodgeball and throw it into a hexagonal bin. The game ends when you decide to stop, and your score is equal to the number of successful throws you made into the bin." }, - { - "id": 1, - "originalGameId": 1, - "real": false, - "quantile": 1, + "(1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1)": { "text": "To set up the game, place a hexagonal bin in the center of the room. The objective of the game is to pick up and move different objects into the bin. Your score at the end of the game is determined by the number of different objects you successfully moved into the bin." }, - { - "id": 2, - "originalGameId": 1, - "real": false, - "quantile": 1, + "(1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0)": { "text": "To play this game, stand on a rug and throw cube blocks onto a desk without hitting or breaking any lamps, desktops, or laptops. Your score at the end of the game is equal to the number of different cube blocks you successfully threw onto the desk." }, - { - "id": 3, - "originalGameId": 1, - "real": false, - "quantile": 1, + "(1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 1)": { "text": "To play this game, arrange objects of the same color so that one is either on top of, adjacent to, or inside the other. Make sure the main light switch or a lamp is turned off and avoid breaking any objects in the room. At the end of the game, your score is calculated as follows: you get 5 points for every different object used to satisfy the color arrangement condition, an additional 5 points for every different green object used in this way, and another 5 points for every different brown object used in this way. You also get 15 points for every different object used to satisfy the light switch or lamp condition. However, you lose 10 points for every different object that is broken." } - ] + }, + "matchedArchiveGames": {}, + "novelArchiveGames": {} } \ No newline at end of file diff --git a/src/components/pages/QuizPage.vue b/src/components/pages/QuizPage.vue index b590f12..958aa48 100644 --- a/src/components/pages/QuizPage.vue +++ b/src/components/pages/QuizPage.vue @@ -50,24 +50,35 @@ const QUIZ_QUESTIONS = [ }, { 'id': 'textResponses', - 'question': 'What will you be asked to write in your short responses for each trial?', + 'question': 'What will you be asked to write in your short response for each trial?', 'multiSelect': false, 'answers': [ 'Highlights and lowlights of the described game', - 'Explanations of particularly low and high multiple choice answers about the game', + 'A short overall impression of the described game', 'Suggestions for other settings in which the game might be played', 'Your best guess for who created the game', ], 'correctAnswer': 1, // zero-based }, + { + 'id': 'assumeObjectsExist', + 'question': 'Can you assume all objects referenced in a game description exist?', + 'multiSelect': false, + 'answers': [ + 'Yes, you can safely assume all objects mentioned exist in the room', + 'No, you should check that the objects exist in the room pictures', + 'No, but if it seems reasonable for the objects to exist, you can assume they do', + ], + 'correctAnswer': 0, // zero-based + }, { 'id': 'submittables', - 'question': 'What will you be asked to respond with in each trial?', + 'question': 'What will you be asked to respond with to each game?', 'multiSelect': true, 'answers': [ 'Answers of a few multiple choice questions with judgements of the game description', 'Your edits for how the described game might be improved', - 'Short explanations for your question answers', + 'A short overall response to the game description', 'A list of which objects are missing from the room to play the game' ], 'correctAnswer': [0, 2], // zero-based diff --git a/src/components/pages/Task1Page.vue b/src/components/pages/Task1Page.vue index f2a2e51..3f8ee11 100644 --- a/src/components/pages/Task1Page.vue +++ b/src/components/pages/Task1Page.vue @@ -24,11 +24,51 @@ smilestore.loadGamesData(); const gamesData = smilestore.getGamesData; function sampleGames() { - const { games } = gamesData; - // TODO: subsample games, balanced by conditions - // TODO: # of real/model created, MAP-Elites bins, etc.? + const games = []; + if ('realGames' in gamesData && smilestore.getNRealGames > 0) { + const realGameKeys = Object.keys(gamesData.realGames); + const selectedKeys = realGameKeys.length <= smilestore.getNRealGames ? realGameKeys : random.shuffle(realGameKeys).slice(0, smilestore.getNRealGames); + const realGames = selectedKeys.map((key) => ({ + ...gamesData.realGames[key], + id: key, + real: true, + matched: true, + })); + + games.push(...realGames); + + if ('matchedArchiveGames' in gamesData) { + const matchedGames = []; + realGames.forEach((realGameEntry) => { + if (realGameEntry.id in gamesData.matchedArchiveGames) { + matchedGames.push({ + ...gamesData.matchedArchiveGames[realGameEntry.id], + id: realGameEntry.id, + real: false, + matched: true, + }); + } else { + console.log(`No matched game found for ${realGameEntry.id}`); + } + }); + + games.push(...matchedGames); + } + } + + if ('novelArchiveGames' in gamesData && smilestore.getNNovelGames > 0) { + const novelGameKeys = Object.keys(gamesData.novelArchiveGames); + const selectedNovelKeys = novelGameKeys.length <= smilestore.getNNovelGames ? novelGameKeys : random.shuffle(novelGameKeys).slice(0, smilestore.getNNovelGames); + const novelGames = selectedNovelKeys.map((key) => ({ + ...gamesData.novelArchiveGames[key], + id: key, + real: false, + matched: false, + })); + games.push(...novelGames); + } + return random.shuffle(games); - } const participantGames = sampleGames(); diff --git a/src/stores/smiledata.js b/src/stores/smiledata.js index e933dad..7736ed6 100644 --- a/src/stores/smiledata.js +++ b/src/stores/smiledata.js @@ -69,6 +69,8 @@ const useSmileStore = defineStore('smilestore', { paired_game_results: [], quiz_form: [], // array of quiz attempts quiz_attempts: 0, + n_real_games: 10, + n_novel_games: 20, }, config: appconfig, }), @@ -92,6 +94,8 @@ const useSmileStore = defineStore('smilestore', { getGamesData: (state) => state.local.gamesData, getQuizAttempts: (state) => state.data.quiz_attempts, getQuizForm: (state) => state.data.quiz_form, + getNRealGames: (state) => state.data.n_real_games, + getNNovelGames: (state) => state.data.n_novel_games, }, actions: { @@ -282,7 +286,8 @@ const useSmileStore = defineStore('smilestore', { loadGamesData() { if (this.local.gamesData === null) { this.local.gamesData = gamesDataJson; - console.log(`gamesData loaded from json with length ${this.local.gamesData.length}`); + const lengths = Object.keys(this.local.gamesData).map((key) => `${key} (${Object.keys(this.local.gamesData[key]).length})`).join(', '); // => `a (1), b (2), c (3 + console.log(`gamesData loaded from json with keys (and lengths): ${lengths}`); } return this.local.gamesData;