mnemon->bins = NULL;
mnemon->to_introduce = 3;
- mnemon->to_master = 10;
+ mnemon->to_master = 0;
mnemon->unlearned = 0;
- mnemon->mastered = 0;
+ mnemon->mastered = -1;
}
static void
category = mnemon_get_category (mnemon, name);
+#define READ_LINE do { \
+ bytes_read = getline (&line, &line_size, file); \
+ if (bytes_read == -1) \
+ goto END_OF_FILE; \
+ line_count++; \
+ chomp (line); \
+} while (0)
+
while (1) {
int score;
char *challenge, *response;
- /* Read bin number (ignoring blank separator lines) */
- do {
- bytes_read = getline (&line, &line_size, file);
- if (bytes_read == -1)
- goto END_OF_FILE;
- line_count++;
- chomp (line);
- } while (*line == '\0');
+ /* Ignore blank lines */
+ READ_LINE;
+ if (*line == '\0')
+ continue;
+ /* Read bin number */
score = strtol (line, &end, 10);
if (*end != '\0') {
fprintf (stderr, "Failed to parse bin number from \"%s\" at %s:%d\n",
}
/* Read challenge */
- bytes_read = getline (&line, &line_size, file);
- if (bytes_read == -1)
- break;
- line_count++;
- chomp (line);
+ READ_LINE;
challenge = strdup (line);
/* Read response */
- bytes_read = getline (&line, &line_size, file);
- if (bytes_read == -1)
- break;
- line_count++;
- chomp (line);
+ READ_LINE;
response = line;
category_add_item (category, score, challenge, response);
item->score = 1;
mnemon->unlearned--;
printf ("You got it!");
+ if (mnemon->to_introduce == 0 &&
+ mnemon->unlearned == 0 &&
+ mnemon->to_master == 0)
+ {
+ mnemon->to_master = 10;
+ mnemon->mastered = 0;
+ }
} else if (item->score < 0) {
printf ("Yes---just give me %d more.",
- item->score);
printf ("On your first try, no less!");
} else {
printf ("Masterful (%dx).", item->score);
+ if (mnemon->to_master)
+ mnemon->mastered++;
}
} else {
printf (" %s is the correct answer.",
if (item->score > 0)
printf ( " Oops, you knew that, right?\n ");
mnemon->unlearned++;
- mnemon->mastered = 0;
/* We go to -2 to force a little extra reinforcement
* when re-learning an item, (otherwise, it will often
* get asked again immediately where it is easy to get
}
}
- printf (" (");
+ printf (" ");
if (mnemon->to_introduce)
- printf ("%d to come.", mnemon->to_introduce);
- if (mnemon->to_introduce && mnemon->unlearned)
- printf (" ");
+ printf ("%d to come. ", mnemon->to_introduce);
if (mnemon->unlearned)
- printf ("%d still unlearned.", mnemon->unlearned);
- if (mnemon->to_introduce == 0 && mnemon->unlearned == 0) {
+ printf ("%d still unlearned. ", mnemon->unlearned);
+ if (mnemon->to_master) {
if (mnemon->mastered < mnemon->to_master)
printf ("%d items to master",
mnemon->to_master - mnemon->mastered);
else
printf ("Great job!");
- mnemon->mastered++;
}
- printf (")\n\n");
+ printf ("\n\n");
bin = mnemon_get_bin (mnemon, item->score);
mnemon_handle_response (mnemon, bin, item_index,
item, response);
- } while (mnemon->mastered <= mnemon->to_master);
+ } while (mnemon->mastered < mnemon->to_master);
}
int