[Tux4kids-commits] r29 - in tuxmath/trunk: . data/missions docs src
dbruce at alioth.debian.org
dbruce at alioth.debian.org
Thu Mar 8 21:08:07 CET 2007
Author: dbruce
Date: 2006-09-22 21:29:50 +0000 (Fri, 22 Sep 2006)
New Revision: 29
Modified:
tuxmath/trunk/Makefile
tuxmath/trunk/data/missions/options
tuxmath/trunk/docs/README.txt
tuxmath/trunk/docs/changelog
tuxmath/trunk/src/fileops.c
tuxmath/trunk/src/fileops.h
tuxmath/trunk/src/game.c
tuxmath/trunk/src/mathcards.c
tuxmath/trunk/src/mathcards.h
tuxmath/trunk/src/setup.c
tuxmath/trunk/src/tuxmath.h
Log:
now saves game summary files.
Modified: tuxmath/trunk/Makefile
===================================================================
--- tuxmath/trunk/Makefile 2006-09-20 11:48:50 UTC (rev 28)
+++ tuxmath/trunk/Makefile 2006-09-22 21:29:50 UTC (rev 29)
@@ -32,7 +32,7 @@
OWNER=$(shell if `groups root | grep root > /dev/null` ; then echo root:root ; else echo root:wheel ; fi)
-VERSION=tuxmath-0.95
+VERSION=tuxmath-0.96
all: tuxmath
Modified: tuxmath/trunk/data/missions/options
===================================================================
--- tuxmath/trunk/data/missions/options 2006-09-20 11:48:50 UTC (rev 28)
+++ tuxmath/trunk/data/missions/options 2006-09-22 21:29:50 UTC (rev 29)
@@ -177,6 +177,8 @@
# Default: 0 #
# Parameter: use_keypad (boolean) #
# Default: 0 #
+# Parameter: save_game_summary (boolean) #
+# Default: 1 #
# #
# These parameters control various aspects of Tuxmath's #
# not directly related to the math question to be asked. #
@@ -200,7 +202,13 @@
# gameplay or use with touchscreens:
use_keypad = 0
+# By default, Tuxmath saves summaries of the last
+# ten games in the user's .tuxmath directory. Set
+# this parameter to '0' to turn off.
+save_summary = 1
+
+
############################################################
# #
# Advanced Options #
@@ -209,6 +217,7 @@
# behavior. Most users will probably not change them. #
############################################################
+
############################################################
# #
# Advanced Math Question List Options #
@@ -364,20 +373,20 @@
max_comets = 10
# Starting comet speed. Default is 1.
-speed = 1.000000
+speed = 1.00
# Maximum speed. Default is 10.
-max_speed = 10.000000
+max_speed = 10.00
# 'speedup_factor': If feedback is not used but
-# 'allow_speedup' isenabled, the comet speed will be
+# 'allow_speedup' is enabled, the comet speed will be
# multiplied by this factor with each new wave.
# Default is 1.2 (i.e. 20 percent increase per wave)
-speedup_factor = 1.200000
+speedup_factor = 1.20
# 'slow_after_wrong' tells Tuxmath to go back to
-# starting speedand number of comets if the player misses
+# starting speed and number of comets if the player misses
# a question. Useful for smaller kids. Default is 0.
slow_after_wrong = 0
@@ -389,17 +398,17 @@
# a guideline, early elementary kids might prefer
# 0.2-0.3, older kids at around 0.4-0.6. Default 0.35.
-danger_level = 0.350000
+danger_level = 0.35
# (Feedback) Set danger level speedup.
# The margin of safety will decrease by this factor each
# wave. Default 1.1. Note 1 = no increase in danger level.
-danger_level_speedup = 1.100000
+danger_level_speedup = 1.10
# (Feedback) Set the maximum danger level.
# Default 0.9.
-danger_level_max = 0.900000
+danger_level_max = 0.90
# (Feedback) Set the handicap for hitting cities.
# When bigger than 0, this causes the game to slow down
@@ -408,7 +417,7 @@
# 'slow_after_wrong', but allows for more gradual
# changes. Default 0 (no extra handicap).
-city_explode_handicap = 0.000000
+city_explode_handicap = 0.00
############################################################
Modified: tuxmath/trunk/docs/README.txt
===================================================================
--- tuxmath/trunk/docs/README.txt 2006-09-20 11:48:50 UTC (rev 28)
+++ tuxmath/trunk/docs/README.txt 2006-09-22 21:29:50 UTC (rev 29)
@@ -2,9 +2,9 @@
An educational math tutorial game starring Tux, the Linux Penguin
-----------------------------------------------------------------
-Sept 20, 2006
+Sept 22, 2006
-For tuxmath-0.95
+For tuxmath-0.96
Objective
---------
@@ -302,6 +302,14 @@
settings. (This is somewhat under construction).
+Game Summary Files
+------------------
+ "Tux, of Math Command" saves summaries of the last ten games in the player's
+ .tuxmath directory. The files are named "summary1" through "summary10",
+ with "summary1" the most recent. The files includes lists of questions asked
+ and questions missed, along with the numbers of correct and incorrect
+ answers and the percent correct.
+
[ UNDER CONSTRUCTION ]
Modified: tuxmath/trunk/docs/changelog
===================================================================
--- tuxmath/trunk/docs/changelog 2006-09-20 11:48:50 UTC (rev 28)
+++ tuxmath/trunk/docs/changelog 2006-09-22 21:29:50 UTC (rev 29)
@@ -1,6 +1,18 @@
changelog for "tuxmath"
-2006.Sep.03 (https://svn.tux4kids.net/tuxmath/ - revision 26)
+2006.Sep.22 (https://svn.tux4kids.net/tuxmath/ - revision 27)
+ Version 0.96
+
+ Game:
+ * Tuxmath now saves summaries of the last ten games in
+ the player's .tuxmath directory. They are rotated out,
+ with the oldest discarded each time. The summaries
+ include the starting question list, a list of all
+ missed questions, and the numbers of correct and
+ incorrect answers with percent correct.
+ David Bruce <dbruce at tampabay.rr.com>
+
+2006.Sep.18 (https://svn.tux4kids.net/tuxmath/ - revision 26)
Version 0.95
Setup:
Modified: tuxmath/trunk/src/fileops.c
===================================================================
--- tuxmath/trunk/src/fileops.c 2006-09-20 11:48:50 UTC (rev 28)
+++ tuxmath/trunk/src/fileops.c 2006-09-22 21:29:50 UTC (rev 29)
@@ -53,9 +53,25 @@
#include "setup.h"
#include "mathcards.h"
+/* Used by both write_pregame_summary() and */
+/* write_postgame_summary() so defined with */
+/* file scope: */
+static char* summary_filenames[NUM_SUMMARIES] = {
+ "summary1",
+ "summary2",
+ "summary3",
+ "summary4",
+ "summary5",
+ "summary6",
+ "summary7",
+ "summary8",
+ "summary9",
+ "summary10"
+};
/* local function prototypes: */
+static int find_tuxmath_dir(void);
static int str_to_bool(char* val);
@@ -461,6 +477,13 @@
game_options->use_keypad = v;
}
+ else if(0 == strcasecmp(parameter, "save_summary"))
+ {
+ int v = str_to_bool(value);
+ if (v != -1)
+ game_options->save_summary = v;
+ }
+
else if(0 == strcasecmp(parameter, "speed"))
{
game_options->speed = atof(value);
@@ -875,71 +898,17 @@
{
char opt_path[PATH_MAX];
FILE* fp;
- DIR* dir_ptr;
- /* find $HOME */
- strcpy(opt_path, getenv("HOME"));
-
- #ifdef TUXMATH_DEBUG
- printf("\nIn write_user_config_file() home directory is: = %s\n", opt_path);
- #endif
-
- /* add rest of path to user's tuxmath dir: */
- strcat(opt_path, "/.tuxmath");
-
- #ifdef TUXMATH_DEBUG
- printf("\nIn write_user_config_file() tuxmath dir is: = %s\n", opt_path);
- #endif
-
- /* find out if directory exists - if not, create it: */
- dir_ptr = opendir(opt_path);
- if (dir_ptr) /* don't leave DIR* open if it was already there */
+ if (!find_tuxmath_dir())
{
- #ifdef TUXMATH_DEBUG
- printf("\nIn write_user_config_file() tuxmath dir opened OK\n");
- #endif
-
- closedir(dir_ptr);
+ fprintf(stderr, "\nCould not find or create tuxmath dir\n");
+ return 0;
}
- else /* need to create tuxmath config directory: */
- {
- int status;
- /* if user's home has a _file_ named .tuxmath (as from previous version */
- /* of program), need to get rid of it or directory creation will fail: */
- fp = fopen(opt_path, "r");
- if (fp)
- {
- #ifdef TUXMATH_DEBUG
- printf("\nIn write_user_config_file() - removing old .tuxmath file\n");
- #endif
+ /* find $HOME and add rest of path to config file: */
+ strcpy(opt_path, getenv("HOME"));
+ strcat(opt_path, "/.tuxmath/options");
- fclose(fp);
- remove(opt_path);
- }
-
- #ifdef TUXMATH_DEBUG
- printf("\nIn write_user_config_file() - trying to create .tuxmath dir\n");
- #endif
-
- status = mkdir(opt_path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
-
- #ifdef TUXMATH_DEBUG
- printf("\nIn write_user_config_file() - mkdir returned: %d\n", status);
- #endif
-
- /* mkdir () returns 0 if successful */
- if (0 != status)
- {
- fprintf(stderr, "\nwrite_user_config_file() - mkdir failed\n");
- return 0;
- }
-
- }
-
- /* Add filename: */
- strcat(opt_path, "/options");
-
#ifdef TUXMATH_DEBUG
printf("\nIn write_user_config_file() full path to config file is: = %s\n", opt_path);
#endif
@@ -1194,6 +1163,8 @@
"# Default: 0 #\n"
"# Parameter: use_keypad (boolean) #\n"
"# Default: 0 #\n"
+ "# Parameter: save_game_summary (boolean) #\n"
+ "# Default: 1 #\n"
"# #\n"
"# These parameters control various aspects of Tuxmath's #\n"
"# not directly related to the math question to be asked. #\n"
@@ -1233,6 +1204,13 @@
}
fprintf(fp, "use_keypad = %d\n", game_options->use_keypad);
+ if (verbose)
+ {
+ fprintf (fp, "\n# By default, Tuxmath saves summaries of the last\n"
+ "# ten games in the user's .tuxmath directory. Set\n"
+ "# this parameter to '0' to turn off.\n");
+ }
+ fprintf(fp, "save_summary = %d\n", game_options->save_summary);
if (verbose)
{
@@ -1430,13 +1408,13 @@
{
fprintf (fp, "\n# Starting comet speed. Default is 1.\n");
}
- fprintf(fp, "speed = %f\n", game_options->speed);
+ fprintf(fp, "speed = %.2f\n", game_options->speed);
if(verbose)
{
fprintf (fp, "\n# Maximum speed. Default is 10.\n");
}
- fprintf(fp, "max_speed = %f\n", game_options->max_speed);
+ fprintf(fp, "max_speed = %.2f\n", game_options->max_speed);
if(verbose)
{
@@ -1445,7 +1423,7 @@
"# multiplied by this factor with each new wave.\n"
"# Default is 1.2 (i.e. 20 percent increase per wave)\n\n");
}
- fprintf(fp, "speedup_factor = %f\n", game_options->speedup_factor);
+ fprintf(fp, "speedup_factor = %.2f\n", game_options->speedup_factor);
if(verbose)
{
@@ -1466,7 +1444,7 @@
"# a guideline, early elementary kids might prefer\n"
"# 0.2-0.3, older kids at around 0.4-0.6. Default 0.35.\n\n");
}
- fprintf(fp, "danger_level = %f\n", game_options->danger_level);
+ fprintf(fp, "danger_level = %.2f\n", game_options->danger_level);
if(verbose)
{
@@ -1474,14 +1452,14 @@
"# The margin of safety will decrease by this factor each\n"
"# wave. Default 1.1. Note 1 = no increase in danger level.\n\n");
}
- fprintf(fp, "danger_level_speedup = %f\n", game_options->danger_level_speedup);
+ fprintf(fp, "danger_level_speedup = %.2f\n", game_options->danger_level_speedup);
if(verbose)
{
fprintf (fp, "\n# (Feedback) Set the maximum danger level.\n"
"# Default 0.9.\n");
}
- fprintf(fp, "danger_level_max = %f\n", game_options->danger_level_max);
+ fprintf(fp, "danger_level_max = %.2f\n", game_options->danger_level_max);
if (verbose)
{
@@ -1492,7 +1470,7 @@
"# 'slow_after_wrong', but allows for more gradual\n"
"# changes. Default 0 (no extra handicap).\n\n");
}
- fprintf(fp, "city_explode_handicap = %f\n", game_options->city_expl_handicap);
+ fprintf(fp, "city_explode_handicap = %.2f\n", game_options->city_expl_handicap);
if(verbose)
{
@@ -1532,6 +1510,148 @@
}
+/* write_pregame_summary() and write_postgame_summary() are used to */
+/* record data about the player's game to file for review (perhaps by */
+/* teacher). write_pregame_summary() is called at the start of each */
+/* game and records the question list along with identifying data. It */
+/* also rotates old game summaries to successive filenames, keeping */
+/* the last ten summaries for review. write_postgame_summary() */
+/* the list of questions that were not answered correctly and */
+/* calculates the percent correct. */
+int write_pregame_summary(void)
+{
+ int i;
+ FILE* fp;
+ char filepath1[PATH_MAX];
+ char filepath2[PATH_MAX];
+
+ /* Make sure tuxmath dir exists or can be created: */
+ if (!find_tuxmath_dir())
+ {
+ fprintf(stderr, "\nCould not find or create tuxmath dir\n");
+ return 0;
+ }
+
+
+
+ /* Rotate filenames of old summaries, oldest summary if present */
+ /* and leaving summary1 available for current game: */
+
+ /* find $HOME and tack on file name: */
+ strcpy(filepath1, getenv("HOME"));
+ strcat(filepath1, "/.tuxmath/");
+ strcat(filepath1, summary_filenames[NUM_SUMMARIES - 1]);
+
+ fp = fopen(filepath1, "r");
+ if (fp)
+ {
+ #ifdef TUXMATH_DEBUG
+ printf("\nIn write_pregame_summary() - removing oldest summary file\n");
+ #endif
+
+ fclose(fp);
+ remove(filepath1);
+ }
+
+ /* Now shift each old file back by one: */
+ /* 'filepath1' is the old name for each file, */
+ /* 'filepath2' is the new name (i.e. we go from i - 1 to i). */
+ for (i = NUM_SUMMARIES - 1; i > 0; i--)
+ {
+ /* old filename: */
+ strcpy(filepath1, getenv("HOME"));
+ strcat(filepath1, "/.tuxmath/");
+ strcat(filepath1, summary_filenames[i - 1]);
+ /* new filename: */
+ strcpy(filepath2, getenv("HOME"));
+ strcat(filepath2, "/.tuxmath/");
+ strcat(filepath2, summary_filenames[i]);
+ /* now change the name: */
+ rename(filepath1, filepath2);
+ }
+
+ /* summary_filenames[0] (i.e. 'summary1') should now be vacant: */
+ strcpy(filepath1, getenv("HOME"));
+ strcat(filepath1, "/.tuxmath/");
+ strcat(filepath1, summary_filenames[0]);
+
+ fp = fopen(filepath1, "w"); /* "w" means start writing with empty file */
+ if (fp)
+ {
+ /* Write header and identifying data for summary file: */
+ fprintf(fp, "************************\n"
+ "* Tuxmath Game Summary *\n"
+ "************************\n");
+ fprintf(fp, "\nPlayer: %s\n", getenv("USER"));
+
+ /* Write question list: */
+ fprintf(fp, "\nStarting Question List:");
+ MC_PrintQuestionList(fp);
+ fprintf(fp, "\n\nNumber of Questions: %d", MC_StartingListLength());
+
+ fclose(fp);
+ return 1;
+ }
+ else /* Couldn't write file for some reason: */
+ {
+ return 0;
+ }
+}
+
+int write_postgame_summary(void)
+{
+ FILE* fp;
+ char filepath1[PATH_MAX];
+ int total_answered;
+
+ strcpy(filepath1, getenv("HOME"));
+ strcat(filepath1, "/.tuxmath/");
+ strcat(filepath1, summary_filenames[0]);
+
+ fp = fopen(filepath1, "a"); /* "a" means append to end of file */
+ if (fp)
+ {
+ /* Write list of questions missed: */
+ fprintf(fp, "\n\n\nList Of Questions Not Answered Correctly:");
+ MC_PrintWrongList(fp);
+ fprintf(fp, "\n\nNumber Of Distinct Questions Not Answered Correctly: %d",
+ MC_WrongListLength());
+
+ /* Write post-game statistics: */
+ total_answered = MC_NumAnsweredCorrectly() + MC_NumNotAnsweredCorrectly();
+
+ fprintf(fp, "\n\nSummary:\n");
+ fprintf(fp, "Questions Answered:\t%d\n", total_answered);
+ fprintf(fp, "Questions Correct:\t%d\n",
+ MC_NumAnsweredCorrectly());
+ fprintf(fp, "Questions Missed:\t%d\n",
+ MC_NumNotAnsweredCorrectly());
+ /* Avoid divide-by-zero errror: */
+ if (total_answered)
+ {
+ fprintf(fp, "Percent Correct:\t%d %%\n",
+ ((MC_NumAnsweredCorrectly() * 100)/ total_answered) );
+ }
+ else
+ fprintf(fp, "Percent Correct: (not applicable)\n");
+
+ fprintf(fp, "Mission Accomplished:\t");
+ if (MC_MissionAccomplished())
+ {
+ fprintf(fp, "Yes!\n\n8^)\n");
+ }
+ else
+ {
+ fprintf(fp, "No.\n\n:^(\n");
+ }
+ return 1;
+ }
+ else /* Couldn't write file for some reason: */
+ {
+ return 0;
+ }
+}
+
/* prints struct to stream: */
void print_game_options(FILE* fp, int verbose)
{
@@ -1739,7 +1859,81 @@
}
+/* Checks to see if user's .tuxmath directory exists and, if not, tries */
+/* to create it. Returns 1 if .tuxmath dir found or successfully created */
+static int find_tuxmath_dir(void)
+{
+ char opt_path[PATH_MAX];
+ DIR* dir_ptr;
+ /* find $HOME */
+ strcpy(opt_path, getenv("HOME"));
+
+ #ifdef TUXMATH_DEBUG
+ printf("\nIn find_tuxmath_dir() home directory is: = %s\n", opt_path);
+ #endif
+
+ /* add rest of path to user's tuxmath dir: */
+ strcat(opt_path, "/.tuxmath");
+
+ #ifdef TUXMATH_DEBUG
+ printf("\nIn find_tuxmath_dir() tuxmath dir is: = %s\n", opt_path);
+ #endif
+
+ /* find out if directory exists - if not, create it: */
+ dir_ptr = opendir(opt_path);
+ if (dir_ptr) /* don't leave DIR* open if it was already there */
+ {
+ #ifdef TUXMATH_DEBUG
+ printf("\nIn find_tuxmath_dir() tuxmath dir opened OK\n");
+ #endif
+
+ closedir(dir_ptr);
+ return 1;
+ }
+ else /* need to create tuxmath config directory: */
+ {
+ FILE* fp;
+ int status;
+
+ /* if user's home has a _file_ named .tuxmath (as from previous version */
+ /* of program), need to get rid of it or directory creation will fail: */
+ fp = fopen(opt_path, "r");
+ if (fp)
+ {
+ #ifdef TUXMATH_DEBUG
+ printf("\nIn find_tuxmath_dir() - removing old .tuxmath file\n");
+ #endif
+
+ fclose(fp);
+ remove(opt_path);
+ }
+
+ #ifdef TUXMATH_DEBUG
+ printf("\nIn find_tuxmath_dir() - trying to create .tuxmath dir\n");
+ #endif
+
+ status = mkdir(opt_path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+
+ #ifdef TUXMATH_DEBUG
+ printf("\nIn find_tuxmath_dir() - mkdir returned: %d\n", status);
+ #endif
+
+ /* mkdir () returns 0 if successful */
+ if (0 == status)
+ {
+ fprintf(stderr, "\nfind_tuxmath_dir() - $HOME/.tuxmath created\n");
+ return 1;
+ }
+ else
+ {
+ fprintf(stderr, "\nfind_tuxmath_dir() - mkdir failed\n");
+ return 0;
+ }
+ }
+}
+
+
/* Allows use of "true", "YES", T, etc. in text file for boolean values. */
/* Return value of -1 means value string is not recognized. */
static int str_to_bool(char* val)
Modified: tuxmath/trunk/src/fileops.h
===================================================================
--- tuxmath/trunk/src/fileops.h 2006-09-20 11:48:50 UTC (rev 28)
+++ tuxmath/trunk/src/fileops.h 2006-09-22 21:29:50 UTC (rev 29)
@@ -159,14 +159,31 @@
NUM_MUSICS
};
+/* Names for game summary files: */
+enum {
+ SUMMARY1,
+ SUMMARY2,
+ SUMMARY3,
+ SUMMARY4,
+ SUMMARY5,
+ SUMMARY6,
+ SUMMARY7,
+ SUMMARY8,
+ SUMMARY9,
+ SUMMARY10,
+ NUM_SUMMARIES
+};
-
/* These functions used by setup() to read in settings: */
int read_global_config_file(void);
int read_user_config_file(void);
int read_named_config_file(char* filename);
int write_user_config_file(void);
+/* These functions used by game() to record game summary: */
+int write_pregame_summary(void);
+int write_postgame_summary(void);
+
/* FIXME these will probably become "local" functions: */
int read_config_file(FILE* fp, int file_type);
int write_config_file(FILE* fp, int verbose);
Modified: tuxmath/trunk/src/game.c
===================================================================
--- tuxmath/trunk/src/game.c 2006-09-20 11:48:50 UTC (rev 28)
+++ tuxmath/trunk/src/game.c 2006-09-22 21:29:50 UTC (rev 29)
@@ -155,8 +155,7 @@
/* most code moved into smaller functions (game_*()): */
if (!game_initialize())
{
- printf("\ngame_initialize() failed!");
- fprintf(stderr, "\ngame_initialze() failed!");
+ fprintf(stderr, "\ngame_initialize() failed!");
/* return 1 so program exits: */
return 1;
}
@@ -379,7 +378,15 @@
}
}
#endif
-
+
+
+ /* Write post-game info to game summary file: */
+ if (game_options->save_summary)
+ {
+ write_postgame_summary();
+ }
+
+
/* Return the chosen command: */
if (GAME_OVER_WINDOW_CLOSE == game_status)
{
@@ -419,8 +426,13 @@
return 0;
}
+ /* Write pre-game info to game summary file: */
+ if (game_options->save_summary)
+ {
+ write_pregame_summary();
+ }
+
/* Prepare to start the game: */
-
city_expl_height = screen->h - images[IMG_CITY_BLUE]->h;
/* Initialize feedback parameters */
@@ -1442,7 +1454,7 @@
comets[found].y = 0;
#ifdef TUXMATH_DEBUG
- printf ("add_comet(): formula string is: ", comets[found].flashcard.formula_string);
+ printf ("\nadd_comet(): formula string is: %s", comets[found].flashcard.formula_string);
#endif
/* comet slot found and question found so return successfully: */
Modified: tuxmath/trunk/src/mathcards.c
===================================================================
--- tuxmath/trunk/src/mathcards.c 2006-09-20 11:48:50 UTC (rev 28)
+++ tuxmath/trunk/src/mathcards.c 2006-09-22 21:29:50 UTC (rev 29)
@@ -1631,10 +1631,253 @@
+/* prints struct to file */
+void MC_PrintMathOptions(FILE* fp, int verbose)
+{
+ #ifdef MC_DEBUG
+ printf("\nEntering MC_PrintMathOptions()\n");
+ #endif
+
+ /* bail out if no struct */
+ if (!math_opts)
+ {
+ fprintf(stderr, "\nMath Options struct does not exist!\n");
+ return;
+ }
+
+ if (verbose)
+ {
+ fprintf (fp, "\n############################################################\n"
+ "# #\n"
+ "# General Math Options #\n"
+ "# #\n"
+ "# If 'play_through_list' is true, Tuxmath will ask each #\n"
+ "# question in an internally-generated list. The list is #\n"
+ "# generated based on the question ranges selected below. #\n"
+ "# The game ends when no questions remain. #\n"
+ "# If 'play_through_list' is false, the game continues #\n"
+ "# until all cities are destroyed. #\n"
+ "# Default is 1 (i.e. 'true' or 'yes'). #\n"
+ "# #\n"
+ "# 'question_copies' is the number of times each question #\n"
+ "# will be asked. It can be 1 to 10 - Default is 1. #\n"
+ "# #\n"
+ "# 'repeat_wrongs' tells Tuxmath whether to reinsert #\n"
+ "# incorrectly answered questions into the list to be #\n"
+ "# asked again. Default is 1 (yes). #\n"
+ "# #\n"
+ "# 'copies_repeated_wrongs' gives the number of times an #\n"
+ "# incorrectly answered question will reappear. Default #\n"
+ "# is 1. #\n"
+ "# #\n"
+ "# The defaults for these values result in a 'mission' #\n"
+ "# for Tux that is accomplished by answering all #\n"
+ "# questions correctly with at least one surviving city. #\n"
+ "############################################################\n\n");
+ }
+ fprintf (fp, "play_through_list = %d\n", math_opts->play_through_list);
+ fprintf (fp, "question_copies = %d\n", math_opts->question_copies);
+ fprintf (fp, "repeat_wrongs = %d\n", math_opts->repeat_wrongs);
+ fprintf (fp, "copies_repeated_wrongs = %d\n", math_opts->copies_repeated_wrongs);
+
+ if (verbose)
+ {
+ fprintf (fp, "\n############################################################\n"
+ "# The 'format_<op>_answer_<place> options control #\n"
+ "# generation of questions with the answer in different #\n"
+ "# places in the equation. i.e.: #\n"
+ "# #\n"
+ "# format_add_answer_last: 2 + 2 = ? #\n"
+ "# format_add_answer_first: ? + 2 = 4 #\n"
+ "# format_add_answer_middle: 2 + ? = 4 #\n"
+ "# #\n"
+ "# By default, 'format_answer_first' is enabled and the #\n"
+ "# other two formats are disabled. Note that the options #\n"
+ "# are not mutually exclusive - the question list may #\n"
+ "# contain questions with different formats. #\n"
+ "# #\n"
+ "# The formats are set independently for each of the four #\n"
+ "# math operations. #\n"
+ "############################################################\n\n");
+ }
+ fprintf (fp, "format_add_answer_last = %d\n", math_opts->format_add_answer_last);
+ fprintf (fp, "format_add_answer_first = %d\n", math_opts->format_add_answer_first);
+ fprintf (fp, "format_add_answer_middle = %d\n", math_opts->format_add_answer_middle);
+ fprintf (fp, "format_sub_answer_last = %d\n", math_opts->format_sub_answer_last);
+ fprintf (fp, "format_sub_answer_first = %d\n", math_opts->format_sub_answer_first);
+ fprintf (fp, "format_sub_answer_middle = %d\n", math_opts->format_sub_answer_middle);
+ fprintf (fp, "format_mult_answer_last = %d\n", math_opts->format_mult_answer_last);
+ fprintf (fp, "format_mult_answer_first = %d\n", math_opts->format_mult_answer_first);
+ fprintf (fp, "format_mult_answer_middle = %d\n", math_opts->format_mult_answer_middle);
+ fprintf (fp, "format_div_answer_last = %d\n", math_opts->format_div_answer_last);
+ fprintf (fp, "format_div_answer_first = %d\n", math_opts->format_div_answer_first);
+ fprintf (fp, "format_div_answer_middle = %d\n", math_opts->format_div_answer_middle);
+
+ if (verbose)
+ {
+ fprintf (fp, "\n############################################################\n"
+ "# 'allow_negatives' allows or disallows use of negative #\n"
+ "# numbers as both operands and answers. Default is 0 #\n"
+ "# (no), which disallows questions like: #\n"
+ "# 2 - 4 = ? #\n"
+ "# Note: this option must be enabled in order to set the #\n"
+ "# operand ranges to include negatives (see below). If it #\n"
+ "# is changed from 1 (yes) to 0 (no), any negative #\n"
+ "# operand limits will be reset to 0. #\n"
+ "############################################################\n\n");
+ }
+ fprintf (fp, "allow_negatives = %d\n", math_opts->allow_negatives);
+
+ if (verbose)
+ {
+ fprintf (fp, "\n############################################################\n"
+ "# 'max_answer' is the largest absolute value allowed in #\n"
+ "# any value in a question (not only the answer). Default #\n"
+ "# is 144. It can be set as high as 999. #\n"
+ "############################################################\n\n");
+ }
+ fprintf (fp, "max_answer = %d\n", math_opts->max_answer);
+
+ if (verbose)
+ {
+ fprintf (fp, "\n############################################################\n"
+ "# 'max_questions' is limit of the length of the question #\n"
+ "# list. Default is 5000 - only severe taskmasters will #\n"
+ "# need to raise it. #\n"
+ "############################################################\n\n");
+ }
+ fprintf (fp, "max_questions = %d\n", math_opts->max_questions);
+
+ if (verbose)
+ {
+ fprintf (fp, "\n############################################################\n"
+ "# If 'randomize' selected, the list will be shuffled #\n"
+ "# at the start of the game. Default is 1 (yes). #\n"
+ "############################################################\n\n");
+ }
+ fprintf (fp, "randomize = %d\n", math_opts->randomize);
+
+ if (verbose)
+ {
+ fprintf (fp, "\n############################################################\n"
+ "# #\n"
+ "# Math Operations Allowed #\n"
+ "# #\n"
+ "# These options enable questions for each of the four math #\n"
+ "# operations. All are 1 (yes) by default. #\n"
+ "############################################################\n\n");
+ }
+ fprintf(fp, "addition_allowed = %d\n", math_opts->addition_allowed);
+ fprintf(fp, "subtraction_allowed = %d\n", math_opts->subtraction_allowed);
+ fprintf(fp, "multiplication_allowed = %d\n", math_opts->multiplication_allowed);
+ fprintf(fp, "division_allowed = %d\n", math_opts->division_allowed);
+
+
+ if (verbose)
+ {
+ fprintf (fp, "\n############################################################\n"
+ "# #\n"
+ "# Minimum and Maximum Values for Operand Ranges #\n"
+ "# #\n"
+ "# Operand limits can be set to any integer up to the #\n"
+ "# value of 'max_answer'. If 'allow_negatives' is set to 1 #\n"
+ "# (yes), either negative or positive values can be used. #\n"
+ "# Tuxmath will generate questions for every value in the #\n"
+ "# specified range. The maximum must be greater than or #\n"
+ "# equal to the corresponding minimum for any questions to #\n"
+ "# be generated for that operation. #\n"
+ "############################################################\n\n");
+ }
+ fprintf(fp, "\n# Addition operands: augend + addend = sum\n");
+ fprintf(fp, "min_augend = %d\n", math_opts->min_augend);
+ fprintf(fp, "max_augend = %d\n", math_opts->max_augend);
+ fprintf(fp, "min_addend = %d\n", math_opts->min_addend);
+ fprintf(fp, "max_addend = %d\n", math_opts->max_addend);
+
+ fprintf(fp, "\n# Subtraction operands: minuend - subtrahend = difference\n");
+ fprintf(fp, "min_minuend = %d\n", math_opts->min_minuend);
+ fprintf(fp, "max_minuend = %d\n", math_opts->max_minuend);
+ fprintf(fp, "min_subtrahend = %d\n", math_opts->min_subtrahend);
+ fprintf(fp, "max_subtrahend = %d\n", math_opts->max_subtrahend);
+
+ fprintf(fp, "\n# Multiplication operands: multiplier * multiplicand = product\n");
+ fprintf(fp, "min_multiplier = %d\n", math_opts->min_multiplier);
+ fprintf(fp, "max_multiplier = %d\n", math_opts->max_multiplier);
+ fprintf(fp, "min_multiplicand = %d\n", math_opts->min_multiplicand);
+ fprintf(fp, "max_multiplicand = %d\n", math_opts->max_multiplicand);
+
+ fprintf(fp, "\n# Division operands: dividend/divisor = quotient\n");
+ fprintf(fp, "min_divisor = %d\n",math_opts->min_divisor);
+ fprintf(fp, "max_divisor = %d\n", math_opts->max_divisor);
+ fprintf(fp, "min_quotient = %d\n", math_opts->min_quotient);
+ fprintf(fp, "max_quotient = %d\n", math_opts->max_quotient);
+}
+
+
+
+int MC_PrintQuestionList(FILE* fp)
+{
+ if (fp && question_list)
+ {
+ print_list(fp, question_list);
+ return 1;
+ }
+ else
+ {
+ fprintf(stderr, "\nFile pointer and/or question list invalid\n");
+ return 0;
+ }
+}
+
+int MC_PrintWrongList(FILE* fp)
+{
+ if (!fp)
+ {
+ fprintf(stderr, "File pointer invalid\n");
+ return 0;
+ }
+
+ if (wrong_quests)
+ {
+ print_list(fp, wrong_quests);
+ }
+ else
+ {
+ fprintf(fp, "\nNo wrong questions!\n");
+ }
+
+ return 1;
+}
+
+
+int MC_StartingListLength(void)
+{
+ return starting_length;
+}
+
+
+int MC_WrongListLength(void)
+{
+ return list_length(wrong_quests);
+}
+
+int MC_NumAnsweredCorrectly(void)
+{
+ return answered_correctly;
+}
+
+
+int MC_NumNotAnsweredCorrectly(void)
+{
+ return answered_wrong;
+}
+
+
/* Implementation of "private methods" - (cannot be called from outside
of this file) */
+
/* Resets negative values to zero - used when allow_negatives deselected. */
void clear_negatives(void)
{
@@ -2229,190 +2472,6 @@
-/* FIXME generalize this so it can be used to write config file */
-/* prints struct to file */
-void MC_PrintMathOptions(FILE* fp, int verbose)
-{
- #ifdef MC_DEBUG
- printf("\nEntering MC_PrintMathOptions()\n");
- #endif
-
- /* bail out if no struct */
- if (!math_opts)
- {
- fprintf(stderr, "\nMath Options struct does not exist!\n");
- return;
- }
-
- if (verbose)
- {
- fprintf (fp, "\n############################################################\n"
- "# #\n"
- "# General Math Options #\n"
- "# #\n"
- "# If 'play_through_list' is true, Tuxmath will ask each #\n"
- "# question in an internally-generated list. The list is #\n"
- "# generated based on the question ranges selected below. #\n"
- "# The game ends when no questions remain. #\n"
- "# If 'play_through_list' is false, the game continues #\n"
- "# until all cities are destroyed. #\n"
- "# Default is 1 (i.e. 'true' or 'yes'). #\n"
- "# #\n"
- "# 'question_copies' is the number of times each question #\n"
- "# will be asked. It can be 1 to 10 - Default is 1. #\n"
- "# #\n"
- "# 'repeat_wrongs' tells Tuxmath whether to reinsert #\n"
- "# incorrectly answered questions into the list to be #\n"
- "# asked again. Default is 1 (yes). #\n"
- "# #\n"
- "# 'copies_repeated_wrongs' gives the number of times an #\n"
- "# incorrectly answered question will reappear. Default #\n"
- "# is 1. #\n"
- "# #\n"
- "# The defaults for these values result in a 'mission' #\n"
- "# for Tux that is accomplished by answering all #\n"
- "# questions correctly with at least one surviving city. #\n"
- "############################################################\n\n");
- }
- fprintf (fp, "play_through_list = %d\n", math_opts->play_through_list);
- fprintf (fp, "question_copies = %d\n", math_opts->question_copies);
- fprintf (fp, "repeat_wrongs = %d\n", math_opts->repeat_wrongs);
- fprintf (fp, "copies_repeated_wrongs = %d\n", math_opts->copies_repeated_wrongs);
-
- if (verbose)
- {
- fprintf (fp, "\n############################################################\n"
- "# The 'format_<op>_answer_<place> options control #\n"
- "# generation of questions with the answer in different #\n"
- "# places in the equation. i.e.: #\n"
- "# #\n"
- "# format_add_answer_last: 2 + 2 = ? #\n"
- "# format_add_answer_first: ? + 2 = 4 #\n"
- "# format_add_answer_middle: 2 + ? = 4 #\n"
- "# #\n"
- "# By default, 'format_answer_first' is enabled and the #\n"
- "# other two formats are disabled. Note that the options #\n"
- "# are not mutually exclusive - the question list may #\n"
- "# contain questions with different formats. #\n"
- "# #\n"
- "# The formats are set independently for each of the four #\n"
- "# math operations. #\n"
- "############################################################\n\n");
- }
- fprintf (fp, "format_add_answer_last = %d\n", math_opts->format_add_answer_last);
- fprintf (fp, "format_add_answer_first = %d\n", math_opts->format_add_answer_first);
- fprintf (fp, "format_add_answer_middle = %d\n", math_opts->format_add_answer_middle);
- fprintf (fp, "format_sub_answer_last = %d\n", math_opts->format_sub_answer_last);
- fprintf (fp, "format_sub_answer_first = %d\n", math_opts->format_sub_answer_first);
- fprintf (fp, "format_sub_answer_middle = %d\n", math_opts->format_sub_answer_middle);
- fprintf (fp, "format_mult_answer_last = %d\n", math_opts->format_mult_answer_last);
- fprintf (fp, "format_mult_answer_first = %d\n", math_opts->format_mult_answer_first);
- fprintf (fp, "format_mult_answer_middle = %d\n", math_opts->format_mult_answer_middle);
- fprintf (fp, "format_div_answer_last = %d\n", math_opts->format_div_answer_last);
- fprintf (fp, "format_div_answer_first = %d\n", math_opts->format_div_answer_first);
- fprintf (fp, "format_div_answer_middle = %d\n", math_opts->format_div_answer_middle);
-
- if (verbose)
- {
- fprintf (fp, "\n############################################################\n"
- "# 'allow_negatives' allows or disallows use of negative #\n"
- "# numbers as both operands and answers. Default is 0 #\n"
- "# (no), which disallows questions like: #\n"
- "# 2 - 4 = ? #\n"
- "# Note: this option must be enabled in order to set the #\n"
- "# operand ranges to include negatives (see below). If it #\n"
- "# is changed from 1 (yes) to 0 (no), any negative #\n"
- "# operand limits will be reset to 0. #\n"
- "############################################################\n\n");
- }
- fprintf (fp, "allow_negatives = %d\n", math_opts->allow_negatives);
-
- if (verbose)
- {
- fprintf (fp, "\n############################################################\n"
- "# 'max_answer' is the largest absolute value allowed in #\n"
- "# any value in a question (not only the answer). Default #\n"
- "# is 144. It can be set as high as 999. #\n"
- "############################################################\n\n");
- }
- fprintf (fp, "max_answer = %d\n", math_opts->max_answer);
-
- if (verbose)
- {
- fprintf (fp, "\n############################################################\n"
- "# 'max_questions' is limit of the length of the question #\n"
- "# list. Default is 5000 - only severe taskmasters will #\n"
- "# need to raise it. #\n"
- "############################################################\n\n");
- }
- fprintf (fp, "max_questions = %d\n", math_opts->max_questions);
-
- if (verbose)
- {
- fprintf (fp, "\n############################################################\n"
- "# If 'randomize' selected, the list will be shuffled #\n"
- "# at the start of the game. Default is 1 (yes). #\n"
- "############################################################\n\n");
- }
- fprintf (fp, "randomize = %d\n", math_opts->randomize);
-
- if (verbose)
- {
- fprintf (fp, "\n############################################################\n"
- "# #\n"
- "# Math Operations Allowed #\n"
- "# #\n"
- "# These options enable questions for each of the four math #\n"
- "# operations. All are 1 (yes) by default. #\n"
- "############################################################\n\n");
- }
- fprintf(fp, "addition_allowed = %d\n", math_opts->addition_allowed);
- fprintf(fp, "subtraction_allowed = %d\n", math_opts->subtraction_allowed);
- fprintf(fp, "multiplication_allowed = %d\n", math_opts->multiplication_allowed);
- fprintf(fp, "division_allowed = %d\n", math_opts->division_allowed);
-
-
- if (verbose)
- {
- fprintf (fp, "\n############################################################\n"
- "# #\n"
- "# Minimum and Maximum Values for Operand Ranges #\n"
- "# #\n"
- "# Operand limits can be set to any integer up to the #\n"
- "# value of 'max_answer'. If 'allow_negatives' is set to 1 #\n"
- "# (yes), either negative or positive values can be used. #\n"
- "# Tuxmath will generate questions for every value in the #\n"
- "# specified range. The maximum must be greater than or #\n"
- "# equal to the corresponding minimum for any questions to #\n"
- "# be generated for that operation. #\n"
- "############################################################\n\n");
- }
- fprintf(fp, "\n# Addition operands: augend + addend = sum\n");
- fprintf(fp, "min_augend = %d\n", math_opts->min_augend);
- fprintf(fp, "max_augend = %d\n", math_opts->max_augend);
- fprintf(fp, "min_addend = %d\n", math_opts->min_addend);
- fprintf(fp, "max_addend = %d\n", math_opts->max_addend);
-
- fprintf(fp, "\n# Subtraction operands: minuend - subtrahend = difference\n");
- fprintf(fp, "min_minuend = %d\n", math_opts->min_minuend);
- fprintf(fp, "max_minuend = %d\n", math_opts->max_minuend);
- fprintf(fp, "min_subtrahend = %d\n", math_opts->min_subtrahend);
- fprintf(fp, "max_subtrahend = %d\n", math_opts->max_subtrahend);
-
- fprintf(fp, "\n# Multiplication operands: multiplier * multiplicand = product\n");
- fprintf(fp, "min_multiplier = %d\n", math_opts->min_multiplier);
- fprintf(fp, "max_multiplier = %d\n", math_opts->max_multiplier);
- fprintf(fp, "min_multiplicand = %d\n", math_opts->min_multiplicand);
- fprintf(fp, "max_multiplicand = %d\n", math_opts->max_multiplicand);
-
- fprintf(fp, "\n# Division operands: dividend/divisor = quotient\n");
- fprintf(fp, "min_divisor = %d\n",math_opts->min_divisor);
- fprintf(fp, "max_divisor = %d\n", math_opts->max_divisor);
- fprintf(fp, "min_quotient = %d\n", math_opts->min_quotient);
- fprintf(fp, "max_quotient = %d\n", math_opts->max_quotient);
-}
-
-
void print_list(FILE* fp, MC_MathQuestion* list)
{
if (!list)
@@ -2420,8 +2479,8 @@
fprintf(fp, "\nprint_list(): list empty or pointer invalid\n");
return;
}
+
MC_MathQuestion* ptr = list;
- fprintf(fp, "\nList Length:\t%d", list_length(list));
while (ptr)
{
print_node(fp, ptr);
Modified: tuxmath/trunk/src/mathcards.h
===================================================================
--- tuxmath/trunk/src/mathcards.h 2006-09-20 11:48:50 UTC (rev 28)
+++ tuxmath/trunk/src/mathcards.h 2006-09-22 21:29:50 UTC (rev 29)
@@ -245,6 +245,14 @@
/* option (intended to make config files self-documenting).*/
void MC_PrintMathOptions(FILE* fp, int verbose);
+/* Additional functions used to generate game summary files: */
+int MC_PrintQuestionList(FILE* fp);
+int MC_PrintWrongList(FILE* fp);
+int MC_StartingListLength(void);
+int MC_WrongListLength(void);
+int MC_NumAnsweredCorrectly(void);
+int MC_NumNotAnsweredCorrectly(void);
+
/* Simple "Set/Get" type functions for option parameters: */
/* Simple functions to set option parameters: */
Modified: tuxmath/trunk/src/setup.c
===================================================================
--- tuxmath/trunk/src/setup.c 2006-09-20 11:48:50 UTC (rev 28)
+++ tuxmath/trunk/src/setup.c 2006-09-22 21:29:50 UTC (rev 29)
@@ -540,6 +540,7 @@
game_options->starting_comets = DEFAULT_STARTING_COMETS;
game_options->extra_comets_per_wave = DEFAULT_EXTRA_COMETS_PER_WAVE;
game_options->max_comets = DEFAULT_MAX_COMETS;
+ game_options->save_summary = DEFAULT_SAVE_SUMMARY;
game_options->sound_available = DEFAULT_SOUND_AVAILABLE;
game_options->use_feedback = DEFAULT_USE_FEEDBACK;
game_options->danger_level = DEFAULT_DANGER_LEVEL;
Modified: tuxmath/trunk/src/tuxmath.h
===================================================================
--- tuxmath/trunk/src/tuxmath.h 2006-09-20 11:48:50 UTC (rev 28)
+++ tuxmath/trunk/src/tuxmath.h 2006-09-22 21:29:50 UTC (rev 29)
@@ -32,7 +32,7 @@
//#define TUXMATH_DEBUG /* for conditional compilation of debugging output */
//#define FEEDBACK_DEBUG /* for Tim's feedback speed control code */
-#define TUXMATH_VERSION 0.95
+#define TUXMATH_VERSION 0.96
#define PATH_MAX 4096
@@ -51,7 +51,8 @@
#define DEFAULT_SLOW_AFTER_WRONG 0
#define DEFAULT_STARTING_COMETS 2
#define DEFAULT_EXTRA_COMETS_PER_WAVE 2
-#define DEFAULT_MAX_COMETS 10
+#define DEFAULT_MAX_COMETS 10
+#define DEFAULT_SAVE_SUMMARY 1
#define DEFAULT_SOUND_AVAILABLE 1
#define DEFAULT_NUM_CITIES 4 /* MUST BE AN EVEN NUMBER! */
#define DEFAULT_NUM_BKGDS 5
@@ -84,6 +85,7 @@
int extra_comets_per_wave;
int max_comets;
char next_mission[PATH_MAX];
+ int save_summary;
int use_feedback;
float danger_level;
float danger_level_speedup;
More information about the Tux4kids-commits
mailing list