From 72770fbf1daa0858a8b3cab090ff7d55117610e6 Mon Sep 17 00:00:00 2001 From: Mark Langsdorf Date: Fri, 17 Apr 2020 16:03:39 -0500 Subject: [PATCH] now we're just messing around --- tests/effective_dps_test.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/effective_dps_test.cpp b/tests/effective_dps_test.cpp index 81a4e2a711101..97e806af33269 100644 --- a/tests/effective_dps_test.cpp +++ b/tests/effective_dps_test.cpp @@ -88,7 +88,15 @@ static void check_accuracy_dps( avatar &attacker, monster &defender, item &wpn1, double wpn2_hit_rate = static_cast( wpn2_stats.hit_count ) / wpn2_stats.attack_count; double wpn3_hit_rate = static_cast( wpn3_stats.hit_count ) / wpn3_stats.attack_count; CHECK( wpn2_hit_rate > wpn1_hit_rate ); + if( wpn2_hit_rate <= wpn1_hit_rate ) { + std::cout << "wpn 2 hits " << wpn2_stats.hit_count << " / " << wpn2_stats.attack_count << std::endl; + std::cout << "wpn 1 hits " << wpn1_stats.hit_count << " / " << wpn1_stats.attack_count << std::endl; + } CHECK( wpn3_hit_rate > wpn2_hit_rate ); + if( wpn3_hit_rate <= wpn2_hit_rate ) { + std::cout << "wpn 3 hits " << wpn3_stats.hit_count << " / " << wpn3_stats.attack_count << std::endl; + std::cout << "wpn 2 hits " << wpn2_stats.hit_count << " / " << wpn2_stats.attack_count << std::endl; + } CHECK( dps_wpn2 > dps_wpn1 ); CHECK( dps_wpn3 > dps_wpn2 ); } @@ -212,3 +220,30 @@ TEST_CASE( "accuracy increases success", "[accuracy][dps]" ) check_accuracy_dps( dummy, survivor, clumsy_sword, normal_sword, balanced_sword ); } } + +TEST_CASE( "rngjoke" ) +{ + constexpr int trials = 5000; + for( int j = -50; j <= 45; j += 5 ) { + std::vector results1; + std::vector results2; + results1.reserve( trials ); + results2.reserve( trials ); + for( int i = 0; i < trials; i++ ) { + results1.emplace_back( normal_roll( j + 5, 25 ) > 0 ); + results2.emplace_back( normal_roll( j, 25 ) > 0 ); + } + + int successes = std::count_if( results1.begin(), results1.end(), []( bool b ) { + return b == true; + } ); + int failures = std::count_if( results2.begin(), results2.end(), []( bool b ) { + return b == true; + } ); + + std::cout << successes << " > " << failures << "\t// " << j + 5 << " vs " << j << std::endl; + REQUIRE( successes > failures ); + results1.clear(); + results2.clear(); + } +}