------------------------------------------------------------------
What you need to do first is to add a line to the search of the engine, that prints out the height of each node that gets entered (I only did regular search, but could probably also work with quiesce). So like this:
Code: Select all
int alphaBeta(int alpha, const int beta, const int depth, const int height) {
std::cout << height << std::endl; // <----- print out height
if (depth <= 0) return quiesce(alpha, beta);
for (all moves) {
// important, height must be increased by exactly one with each recursive call
score = -alphaBeta(-beta, -alpha, depth - 1, height + 1);
...
}
...
}
Copy the whole output (can include UCI chattering) and paste it into a text file called "myTreeNumbers.txt".
Then run the following Python program:
Code: Select all
from treelib import Node, Tree
filename = "myTreeNumbers.txt"
myNumbers = None
with open(filename, 'r') as file:
for line in file:
line = line[0:-1]
if line.isdigit():
number = int(line)
if number == 0:
myNumbers = []
myNumbers.append(number)
tree = Tree()
root = tree.create_node(tag = 0)
index = 0
print("myNumbers:", len(myNumbers))
def addNode(height, parent):
global index
assert myNumbers[index] == height
while myNumbers[index] >= height:
if myNumbers[index] == height:
current = tree.create_node(tag=height, parent=parent)
print("Created node:", index, height)
index += 1
if index >= len(myNumbers):
print("Returning node:", index)
return
if myNumbers[index] > height:
addNode(height + 1, current)
if index >= len(myNumbers):
print("Returning node:", index)
return
assert myNumbers[index] < height
addNode(0, root)
tree.to_graphviz(filename="myTree.dot", shape="point", graph="graph")
Code: Select all
#!/bin/bash
dot -Tpng myTree.dot -o myTree.png
twopi -Tpng myTree.dot -o myTreeRadial.png
This below is an example image (you probably need to zoom in a little to see anything):
