Skip to content

Commit

Permalink
Updated format of JSON games and sampling of the task games, fixed a …
Browse files Browse the repository at this point in the history
…bug in the quiz
  • Loading branch information
guydav committed Dec 7, 2023
1 parent 59fec6c commit db4c21b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 31 deletions.
30 changes: 8 additions & 22 deletions data/games.json
Original file line number Diff line number Diff line change
@@ -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": {}
}
19 changes: 15 additions & 4 deletions src/components/pages/QuizPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 44 additions & 4 deletions src/components/pages/Task1Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 6 additions & 1 deletion src/stores/smiledata.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
Expand All @@ -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: {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit db4c21b

Please sign in to comment.