aboutsummaryrefslogtreecommitdiff
Commit message (Expand)AuthorAge
...
* Make global names in default mod use good naming convention and move backward...Perttu Ahola2011-12-03
* Rename cookresult_item to cookresult_itemstringPerttu Ahola2011-12-03
* add EnvRef:get_node_or_nil()Perttu Ahola2011-12-03
* Add ABM required neighbor checkPerttu Ahola2011-12-03
* Fix bucket texture namesPerttu Ahola2011-12-03
* Allow digging unknown nodesPerttu Ahola2011-12-03
* Show infotext for unknown nodesPerttu Ahola2011-12-03
* Show infotext for unknown items placed on groundPerttu Ahola2011-12-03
* Call this 0.4.dev-20111203-3Perttu Ahola2011-12-03
* On SIGINT in main menu, don't connect before shutting downPerttu Ahola2011-12-03
* inventorycube: use all three specified textures; also moved mesh creation / m...Kahrl2011-12-03
* Do not broadcast an empty chat message when someone tries to log in with the ...Kahrl2011-12-03
* Notify player whose password is being changedKahrl2011-12-03
* Call this 0.4.dev-20111203-2Perttu Ahola2011-12-03
* Note about debug.txt in error message dialog when mod fails to loadPerttu Ahola2011-12-03
* Change naming convention to be modname:* instead of modname_* (sorry modders!)Perttu Ahola2011-12-03
* Fix note about run-in-place mod search path in mods/default/init.luaPerttu Ahola2011-12-03
* Set version 0.4.dev-20111203-1Perttu Ahola2011-12-03
* Add usermods/ to mod search paths and print out the paths at server startupPerttu Ahola2011-12-03
* Properly handle mod name conflictsPerttu Ahola2011-12-03
* Better mod loading error handlingPerttu Ahola2011-12-03
* Add world/mods to mod search pathPerttu Ahola2011-12-03
* Remove accidental stupid naming in craftitem examplePerttu Ahola2011-12-03
* Enforced mod global naming convention and better error reportingPerttu Ahola2011-12-03
* Fix script error reporting a bitPerttu Ahola2011-12-02
* Fix ActiveObject creation for fast player respawnsPerttu Ahola2011-12-02
* Fix sending of player hp (was sent all the time)Perttu Ahola2011-12-02
* Remove unnecessary debug output from mods/default/init.luaPerttu Ahola2011-12-02
* Show bare hand when no item is selectedPerttu Ahola2011-12-02
* Set version to 0.4.dev-20111202-1Perttu Ahola2011-12-02
* Fix mod licensing and add a mention about sound licensing in README.txtPerttu Ahola2011-12-02
* Script-defined creative inventoryPerttu Ahola2011-12-02
* Rename "build" privilege to "interact" (backwards-compatibly, of course)Perttu Ahola2011-12-02
* Rename "NodeItem"/"ToolItem"/"CraftItem" to "node"/"tool"/"craft"Perttu Ahola2011-12-02
* Remove obsolete createPickedUpItem()Perttu Ahola2011-12-02
* Add time_from_last_punch to Lua APIPerttu Ahola2011-12-02
* Add a note about mods being under CC BY-SA 3.0 like texturesPerttu Ahola2011-12-02
* + middle-click now empties the inventory slot properlyMark Holmquist2011-12-02
* Add enable_pvp settingPerttu Ahola2011-12-02
* Make unlimited player transfer distance configurablePerttu Ahola2011-12-02
* Fix player double damagePerttu Ahola2011-12-02
* Make hitting players make a visual damage flash to the player texture and the...Perttu Ahola2011-12-02
* Don't hide players in pitch black (like oerkkis)Perttu Ahola2011-12-02
* Move ServerRemotePlayer to a separate filePerttu Ahola2011-12-02
* Fix /give(me) commands a bit in default modPerttu Ahola2011-12-02
* Fix the previous commitPerttu Ahola2011-12-02
* Enforce PLAYER_INVENTORY_SIZE in ObjectRef::l_inventory_set_listPerttu Ahola2011-12-02
* Print out PROTOCOL_VERSIONs if server is incompatible with clientPerttu Ahola2011-12-02
* Higher default map save and unload intervalPerttu Ahola2011-12-02
* Don't send objects or map data before definitions have been sentPerttu Ahola2011-12-02
class="hl opt">(testPcgRandomRange); TEST(testPcgRandomBytes); TEST(testPcgRandomNormalDist); } //////////////////////////////////////////////////////////////////////////////// void TestRandom::testPseudoRandom() { PseudoRandom pr(814538); for (u32 i = 0; i != 256; i++) UASSERTEQ(int, pr.next(), expected_pseudorandom_results[i]); } void TestRandom::testPseudoRandomRange() { PseudoRandom pr((int)time(NULL)); EXCEPTION_CHECK(PrngException, pr.range(2000, 6000)); EXCEPTION_CHECK(PrngException, pr.range(5, 1)); for (u32 i = 0; i != 32768; i++) { int min = (pr.next() % 3000) - 500; int max = (pr.next() % 3000) - 500; if (min > max) SWAP(int, min, max); int randval = pr.range(min, max); UASSERT(randval >= min); UASSERT(randval <= max); } } void TestRandom::testPcgRandom() { PcgRandom pr(814538, 998877); for (u32 i = 0; i != 256; i++) UASSERTEQ(u32, pr.next(), expected_pcgrandom_results[i]); } void TestRandom::testPcgRandomRange() { PcgRandom pr((int)time(NULL)); EXCEPTION_CHECK(PrngException, pr.range(5, 1)); // Regression test for bug 3027 pr.range(pr.RANDOM_MIN, pr.RANDOM_MAX); for (u32 i = 0; i != 32768; i++) { int min = (pr.next() % 3000) - 500; int max = (pr.next() % 3000) - 500; if (min > max) SWAP(int, min, max); int randval = pr.range(min, max); UASSERT(randval >= min); UASSERT(randval <= max); } } void TestRandom::testPcgRandomBytes() { char buf[32]; PcgRandom r(1538, 877); memset(buf, 0, sizeof(buf)); r.bytes(buf + 5, 23); UASSERT(memcmp(buf + 5, expected_pcgrandom_bytes_result, sizeof(expected_pcgrandom_bytes_result)) == 0); memset(buf, 0, sizeof(buf)); r.bytes(buf, 17); UASSERT(memcmp(buf, expected_pcgrandom_bytes_result2, sizeof(expected_pcgrandom_bytes_result2)) == 0); } void TestRandom::testPcgRandomNormalDist() { static const int max = 120; static const int min = -120; static const int num_trials = 20; static const u32 num_samples = 61000; s32 bins[max - min + 1]; memset(bins, 0, sizeof(bins)); PcgRandom r(486179 + (int)time(NULL)); for (u32 i = 0; i != num_samples; i++) { s32 randval = r.randNormalDist(min, max, num_trials); UASSERT(randval <= max); UASSERT(randval >= min); bins[randval - min]++; } // Note that here we divide variance by the number of trials; // this is because variance is a biased estimator. int range = (max - min + 1); float mean = (max + min) / 2; float variance = ((range * range - 1) / 12) / num_trials; float stddev = sqrt(variance); static const float prediction_intervals[] = { 0.68269f, // 1.0 0.86639f, // 1.5 0.95450f, // 2.0 0.98758f, // 2.5 0.99730f, // 3.0 }; //// Simple normality test using the 68-95-99.7% rule for (u32 i = 0; i != ARRLEN(prediction_intervals); i++) { float deviations = i / 2.f + 1.f; int lbound = myround(mean - deviations * stddev); int ubound = myround(mean + deviations * stddev); UASSERT(lbound >= min); UASSERT(ubound <= max); int accum = 0; for (int j = lbound; j != ubound; j++) accum += bins[j - min]; float actual = (float)accum / num_samples; UASSERT(fabs(actual - prediction_intervals[i]) < 0.02); } } const int TestRandom::expected_pseudorandom_results[256] = { 0x02fa, 0x60d5, 0x6c10, 0x606b, 0x098b, 0x5f1e, 0x4f56, 0x3fbd, 0x77af, 0x4fe9, 0x419a, 0x6fe1, 0x177b, 0x6858, 0x36f8, 0x6d83, 0x14fc, 0x2d62, 0x1077, 0x23e2, 0x041b, 0x7a7e, 0x5b52, 0x215d, 0x682b, 0x4716, 0x47e3, 0x08c0, 0x1952, 0x56ae, 0x146d, 0x4b4f, 0x239f, 0x3fd0, 0x6794, 0x7796, 0x7be2, 0x75b7, 0x5691, 0x28ee, 0x2656, 0x40c0, 0x133c, 0x63cd, 0x2aeb, 0x518f, 0x7dbc, 0x6ad8, 0x736e, 0x5b05, 0x160b, 0x589f, 0x6f64, 0x5edc, 0x092c, 0x0a39, 0x199e, 0x1927, 0x562b, 0x2689, 0x3ba3, 0x366f, 0x46da, 0x4e49, 0x0abb, 0x40a1, 0x3846, 0x40db, 0x7adb, 0x6ec1, 0x6efa, 0x01cc, 0x6335, 0x4352, 0x72fb, 0x4b2d, 0x509a, 0x257e, 0x2f7d, 0x5891, 0x2195, 0x6107, 0x5269, 0x56e3, 0x4849, 0x38f7, 0x2791, 0x04f2, 0x4e05, 0x78ff, 0x6bae, 0x50b3, 0x74ad, 0x31af, 0x531e, 0x7d56, 0x11c9, 0x0b5e, 0x405e, 0x1e15, 0x7f6a, 0x5bd3, 0x6649, 0x71b4, 0x3ec2, 0x6ab4, 0x520e, 0x6ad6, 0x287e, 0x10b8, 0x18f2, 0x7107, 0x46ea, 0x1d85, 0x25cc, 0x2689, 0x35c1, 0x3065, 0x6237, 0x3edd, 0x23d9, 0x6fb5, 0x37a1, 0x3211, 0x526a, 0x4b09, 0x23f1, 0x58cc, 0x2e42, 0x341f, 0x5e16, 0x3d1a, 0x5e8c, 0x7a82, 0x4635, 0x2bf8, 0x6577, 0x3603, 0x1daf, 0x539f, 0x2e91, 0x6bd8, 0x42d3, 0x7a93, 0x26e3, 0x5a91, 0x6c67, 0x1b66, 0x3ac7, 0x18bf, 0x20d8, 0x7153, 0x558d, 0x7262, 0x653d, 0x417d, 0x3ed3, 0x3117, 0x600d, 0x6d04, 0x719c, 0x3afd, 0x6ba5, 0x17c5, 0x4935, 0x346c, 0x5479, 0x6ff6, 0x1fcc, 0x1054, 0x3f14,