Subversion Repositories programming

Rev

Rev 394 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 394 Rev 395
Line 1... Line 1...
1
#!/usr/bin/env python
1
#!/usr/bin/env python
2
 
2
 
-
 
3
# Fix for the lame version of python on the school's computers (v2.1)
-
 
4
try:
-
 
5
	(True, False)
-
 
6
except NameError:
-
 
7
	(True, False) = (1, 0)
-
 
8
 
3
from Menu import Menu
9
from Menu import Menu
4
from PuzzlePiece import PuzzlePiece
10
from PuzzlePiece import PuzzlePiece
5
import PuzzleSearch
11
import PuzzleSearch
6
import sys
12
import sys
7
 
13
 
Line 47... Line 53...
47
			(goal_node, ), PuzzleSearch.astar_dfc)
53
			(goal_node, ), PuzzleSearch.astar_dfc)
48
 
54
 
49
################################################################################
55
################################################################################
50
 
56
 
51
def m_render_graph (result):
57
def m_render_graph (result):
52
	stupid_mode = False
-
 
53
 
-
 
54
	try:
58
	try:
-
 
59
		no_graphviz = False
55
		import yapgvb
60
		import yapgvb
56
		from DrawGraph import DrawGraph
-
 
57
	except:
61
	except ImportError:
58
		stupid_mode = True
62
		no_graphviz = True
-
 
63
 
-
 
64
	from DrawGraph import DrawGraph
59
 
65
 
60
	if stupid_mode:
66
	if no_graphviz:
61
		print 'In stupid mode!'
67
		dg = DrawGraph (result.search_name, result.result_graph)
62
		return
68
		dg.render_stupid ('generated_by')
63
 
69
 
64
	# Try to render the graph, nicely
70
	# Try to render the graph, nicely
65
	if result.result_graph != None:
71
	elif result.result_graph != None:
66
		fname = raw_input('Enter filename (press ENTER for \'res.svg\'): ')
72
		fname = raw_input('Enter filename (press ENTER for \'res.svg\'): ')
67
		print
73
		print
68
 
74
 
69
		if fname == '':
75
		if fname == '':
70
			fname = 'res.svg'
76
			fname = 'res.svg'
71
 
77
 
72
		# Actually draw the graph
78
		# Actually draw the graph
73
		dg = DrawGraph (result.search_name, result.result_graph)
79
		dg = DrawGraph (result.search_name, result.result_graph)
74
		dg.render_graph (fname, yapgvb.engines.dot)
80
		dg.render_graphviz (fname, yapgvb.engines.dot)
75
	else:
81
	else:
76
		print 'The search failed, therefore I cannot render the graph!'
82
		print 'The search failed, therefore I cannot render the graph!'
77
 
83
 
78
def gen_start_state (goal_node):
84
def gen_start_state (goal_node):
79
	DEPTH=12
85
	DEPTH=12