1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
//-----------------------------------------------------------------------------
/** @file libboardgame_base/tests/RatingTest.cpp
@author Markus Enzenberger
@copyright GNU General Public License version 3 or later */
//-----------------------------------------------------------------------------
#include "libboardgame_base/Rating.h"
#include "libboardgame_test/Test.h"
using namespace libboardgame_base;
//-----------------------------------------------------------------------------
LIBBOARDGAME_TEST_CASE(boardgame_rating_get_expected_result)
{
Rating a(2806);
Rating b(2577);
LIBBOARDGAME_CHECK_CLOSE_EPS(a.get_expected_result(b), 0.789, 0.001)
}
LIBBOARDGAME_TEST_CASE(boardgame_rating_get_expected_result_multiplayer)
{
// Player and 3 opponents, all with rating 1000, should have 25%
// winning probability
Rating a(1000);
Rating b(1000);
LIBBOARDGAME_CHECK_CLOSE_EPS(a.get_expected_result(b, 3), 0.25, 0.001)
}
LIBBOARDGAME_TEST_CASE(boardgame_rating_update_1)
{
Rating a(2806);
Rating b(2577);
Rating new_a = a;
Rating new_b = b;
new_a.update(0, b, 10);
new_b.update(1, a, 10);
LIBBOARDGAME_CHECK_CLOSE_EPS(new_a.get(), 2798, 1)
LIBBOARDGAME_CHECK_CLOSE_EPS(new_b.get(), 2585, 1)
}
LIBBOARDGAME_TEST_CASE(boardgame_rating_update_2)
{
Rating a(2806);
Rating b(2577);
Rating new_a = a;
Rating new_b = b;
new_a.update(1, b, 10);
new_b.update(0, a, 10);
LIBBOARDGAME_CHECK_CLOSE_EPS(new_a.get(), 2808, 1)
LIBBOARDGAME_CHECK_CLOSE_EPS(new_b.get(), 2575, 1)
}
LIBBOARDGAME_TEST_CASE(boardgame_rating_update_3)
{
Rating a(2806);
Rating b(2577);
Rating new_a = a;
Rating new_b = b;
new_a.update(0.5, b, 10);
new_b.update(0.5, a, 10);
LIBBOARDGAME_CHECK_CLOSE_EPS(new_a.get(), 2803, 1)
LIBBOARDGAME_CHECK_CLOSE_EPS(new_b.get(), 2580, 1)
}
//-----------------------------------------------------------------------------
|