Exemplo n.º 1
0
    def test_get_grandparents_value(self):
        board2 = Board()
        node1 = Node(True, board2)
        node2 = node1.createChild()
        node3 = node2.createChild()
        node3.get_grandparents_value()
        node2.get_grandparents_value()

        self.assertEqual(node3.value, node1.value)
        self.assertNotEquals(node2.value, node1.value)

        node2.value = -10
        node4 = node3.createChild()
        node4.get_grandparents_value()

        self.assertEqual(node4.value, -10)
Exemplo n.º 2
0
    def test_update_value(self):
        board = Board()
        node1 = Node(True, board)
        node2 = node1.createChild()
        node3 = node2.createChild()
        node3.get_grandparents_value()
        node2.get_grandparents_value()
        node3.value = 10
        node2.update_value()
        self.assertEqual(node2.value, node3.value)
        node1.value = 100
        node1.update_value()
        self.assertEqual(node1.value, 100)
        node3.update_value()
        self.assertEqual(node3.value, 10)

        self.assertEqual(node1.children[0].children[0], node3)
        self.assertEqual(node1.children[0], node2)
        self.assertEqual(node3.parent.parent, node1)
        self.assertEqual(node3.parent, node2)
Exemplo n.º 3
0
 def test_createChild(self):
     n = Node(True, board.blank)
     child = n.createChild()
     self.assertEqual(child.parent, n)