This repository was archived by the owner on May 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
57 lines (48 loc) · 1.29 KB
/
main.py
File metadata and controls
57 lines (48 loc) · 1.29 KB
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
"""
Runs a test for debugging.
"""
import graphviz as gv
from IPython.core.display import display, Image
from algo_viz.algorithm import alpha_beta
from algo_viz.tree_builder import build_graph
from algo_viz.utility import print_pretty
from algo_viz.visualizer import build_viz
def test():
order, graph2 = build_graph([10, 8, 7, 12, 9, 6, 4, 17, 20], branching=3)
print_pretty(graph2, order)
desc = alpha_beta(graph2, root=order[0])
print_pretty(desc, order)
viz = build_viz(order, graph2, desc, branching=3)
if type(viz) is gv.Graph:
print("PASSED!")
else:
print("ERR")
def test2():
graph = {
# 1. Layer
'X': ['A', 'B'],
# 2. Layer
'A': ['AA', 'AB'],
'B': ['BA', 'BB'],
# 3. Layer
'AA': ['AAA', 'AAB'],
'AB': ['ABA', 'ABB'],
'BA': ['BAA', 'BAB'],
'BB': ['BBA', 'BBB'],
# 4. Layer
'AAA': 10,
'AAB': 8,
'ABA': 7,
'ABB': 12,
'BAA': 9,
'BAB': 6,
'BBA': 4,
'BBB': 17,
}
desc = alpha_beta(graph)
print_pretty(desc)
digraph = build_viz(graph.keys(), graph, desc, branching=2)
digraph.render(filename='img/graph')
display(Image(filename='img/graph.png'))
if __name__ == '__main__':
test2()