@appleduck28, if you want to get an idea of the max value your stats can reach in the game, you can hack the randomtest.js file to help you out. Let’s say you want to compute max values for 3 stats: strength, health, and magic. I’ll show you how to hack the randomtest.js file to give you that info. You can modify what I show you below to work for the exact stats you want to examine. Caveat: The CS interpreter and related JS code is complex enough that I can’t be sure that what I’m about to tell you is 100% precise, but I’m confident it will get you in the ballpark. So here goes…
First, make a copy of the randomtest.js file and store it somewhere so you can return to using it if you mess up the code you’re going to edit.
There are three areas of the code in the randomtest.js file where you’ll enter additional JS code. The first area is near the top of the file. Find this line:
var gameName = "mygame";
Just above that line, copy and paste the following code:
// Start code mod
var stat_names = [
"strength"
,"health"
,"magic"
];
var num_stats = stat_names.length;
var max_stats = [];
var stat_idx;
for (stat_idx = 0; stat_idx < num_stats; ++stat_idx) {
max_stats[stat_idx] = 0;
}
// End code mod
(If you want to determine max values for a different set of stats, you would change the strings in the stat_names array; see example of this at the bottom of this post.)
The second area of the code to modify is towards the bottom of the file. Find this line:
sceneCoverage = coverage[this.name];
Just below that line, copy and paste the following code:
// Start code mod
for (stat_idx = 0; stat_idx < num_stats; ++stat_idx) {
var stat_idx_name = stat_names[stat_idx];
var stat_idx_value = this.stats[stat_idx_name];
if (max_stats[stat_idx] < stat_idx_value) {
max_stats[stat_idx] = stat_idx_value;
}
}
// End code mod
This code is keeping track of the max stat values. Note that this block of code is executed more often than it would actually be executed during a real game, but since you’re looking for a max and not an average, the values should be accurate.
The final area of code to modify is at the very end of the file, where you will enter the code to output the results. Go to the very end of the file and copy and paste the following block of code:
// Start code mod
for (stat_idx = 0; stat_idx < num_stats; ++stat_idx) {
log("Max " + stat_names[stat_idx] + " = " + max_stats[stat_idx]);
}
// End code mod
After you have finished making those mods, save the randomtest.js file and then run the test. I’d recommend using only one iteration at first, just to get some quick feedback. Then you can increase the number of iterations to see how it effects the results.
The output for the max stats will be at the end of the randomtest-output.txt file.
Whatever the set of stats you want to examine, you only have to initialize the stat_names array to hold the names of the stats you are interested in. For instance, if the names of the stats you are interested in are strength, reflexes, wounds, magic, and dollars, then you’d set up your stat_names array like this instead:
var stat_names = [
"strength"
,"reflexes"
,"wounds"
,"magic"
,"dollars"
];
Just make sure that the names of the stats you enter here match exactly to what you put in the stats array in mygame.js, with the same spelling and case. Also make sure to put quotes around the stat names in this array.
There you have it. Because of the random nature of randomtest.js, it’s always possible that some path through your game will produce higher stats than what’s uncovered by this method, but like I said, this method should get you in the ballpark. Hope it helps.