[fen]r4rk1/1p1n1qpb/p1p1pbnp/P2p4/R1PP4/1N1BBN2/1PQ2PPP/4R1K1 b - - 5 17[/fen]
Thought it might be interesting.
Pure Minimax:
![Image](https://i.imgur.com/IBv2H6s.png)
Alpha-Beta + move ordering (using SEE, history heuristics, hash table, killers):
![Image](https://i.imgur.com/xPDbuUN.png)
Normal search (Nalwald):
![Image](https://i.imgur.com/gmlZNMd.png)
Moderators: hgm, Rebel, chrisw
You know the biggest projects ever were started that way - Javascript was a quick 10 day hack to get stuff done. And now the web practically runs off it.
I don't think that's possible beyond depth 1, because UCI doesn't provide any introspective into the engine's search.dangi12012 wrote: ↑Wed Jun 08, 2022 8:59 pm I kind of want a UCI adapter that can output that graph for any uci engine from the Multi-PV score now![]()
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);
...
}
...
}
Code: Select all
0
1
...
1
info depth 1 time 0 nodes 19 nps 19000 hashfull 0 score cp 0 pv c2c3
0
1
2
...
1
1
info depth 2 time 0 nodes 41 nps 41000 hashfull 0 score cp 21 pv c2c3 c7c6
0 // copy this bit
1 // copy this bit
2 // copy this bit
3 // copy this bit
3 // copy this bit
... // copy this bit
1 // copy this bit
1 // copy this bit
1 // copy this bit
1 // copy this bit
1 // copy this bit
info depth 3 time 2 nodes 263 nps 87000 hashfull 0 score cp 11 pv c2c3 d7d5 d2d4
bestmove c2c3
Code: Select all
from treelib import Node, Tree
filename = "myTreeNumbers.txt"
with open(filename, 'r') as f:
data = f.read()
myNumbers = [int(i) for i in data.split()]
tree = Tree()
root = tree.create_node(tag = 0)
index = 1
def addNode(height, parent):
global index
assert myNumbers[index] == height
while myNumbers[index] >= height:
if myNumbers[index] == height:
if index % 100000 == 0:
print(index)
current = tree.create_node(tag=height, parent=parent)
index += 1
if index >= len(myNumbers):
return
if myNumbers[index] > height:
addNode(height + 1, current)
if index >= len(myNumbers):
return
assert myNumbers[index] < height
addNode(1, root)
tree.to_graphviz(filename="myTree.dot", shape="point", graph="graph")
Code: Select all
// from this:
connections.append('"{0}" -> "{1}"'.format(nid, cid))
// to this:
edgeop = '->' if graph == 'digraph' else '--'
connections.append(('"{0}" ' + edgeop + ' "{1}"').format(nid, cid))
Code: Select all
// from this:
graph tree {
"cb3be914-e8ab-11ec-b199-f859716de58e" [label="0", shape=point]
"cb3beab8-e8ab-11ec-b199-f859716de58e" [label="1", shape=point]
...
// to this:
graph tree {
nodesep=0.02;
"cb3be914-e8ab-11ec-b199-f859716de58e" [label="0", shape=point]
"cb3beab8-e8ab-11ec-b199-f859716de58e" [label="1", shape=point]
...
Code: Select all
from treelib import Node, Tree
filename = "myTreeNumbers.txt"
with open(filename, 'r') as f:
data = f.read()
myNumbers = [int(i) for i in data.split()]
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")