File: NodeTest.cpp

package info (click to toggle)
pentobi 29.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,892 kB
  • sloc: cpp: 25,719; javascript: 875; xml: 40; makefile: 13; sh: 6
file content (37 lines) | stat: -rw-r--r-- 1,283 bytes parent folder | download | duplicates (2)
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
//-----------------------------------------------------------------------------
/** @file libboardgame_mcts/tests/NodeTest.cpp
    @author Markus Enzenberger
    @copyright GNU General Public License version 3 or later */
//-----------------------------------------------------------------------------

#include "libboardgame_mcts/Node.h"

#include "libboardgame_test/Test.h"

using namespace std;

//-----------------------------------------------------------------------------

LIBBOARDGAME_TEST_CASE(libboardgame_mcts_node_add_value)
{
    libboardgame_mcts::Node<int, float, true> node;
    node.init(0, 0.5, 0, 1);
    node.add_value(5);
    LIBBOARDGAME_CHECK_CLOSE(node.get_value(), 5.f, 1e-4f)
    node.add_value(2);
    LIBBOARDGAME_CHECK_CLOSE(node.get_value(), 3.5f, 1e-4f)
}

LIBBOARDGAME_TEST_CASE(libboardgame_mcts_node_add_value_remove_loss)
{
    libboardgame_mcts::Node<int, float, true> node;
    node.init(0, 0.5, 0, 1);
    node.add_value(5);
    LIBBOARDGAME_CHECK_CLOSE(node.get_value(), 5.f, 1e-4f)
    node.add_value(0);
    LIBBOARDGAME_CHECK_CLOSE(node.get_value(), 2.5f, 1e-4f)
    node.add_value_remove_loss(2);
    LIBBOARDGAME_CHECK_CLOSE(node.get_value(), 3.5f, 1e-4f)
}

//-----------------------------------------------------------------------------