コード例 #1
0

#Transfors the priority queue into an array of strings
def adaptSolution(node):
    path = []
    finalCost = node.cost
    while node.parentNode:
        path.append("(" + str(node.movement[0]) + ", " +
                    str(node.movement[1]) + "); ")
        node = node.parentNode
    return finalCost, path


#Read the input file
reader = InputReader()
data = reader.read()
#print data

#Store the reading results in the global variables
maxHeight = data[0]
initialConfiguration = data[1]
goalState = data[2]

cost = 0
path = []
#Search
if searchingByBFS():
    cost, path = adaptSolution(success)
#Print solution
if len(path) > 0:
    print(len(visitedNodes))
コード例 #2
0
ファイル: bayes.py プロジェクト: bucalexis/AI-LAB4
	
	acumAux = 0.0
	if not denominator:
		acumAux = 1.0
	if denominator:
		relevants = getRelevants(denominator)
		combinations = combinateRelevants(relevants)
		if combinations:
			for combination in combinations:
				fullList = denominator+ combination
				acumAux += chain(fullList)
		else:
			fullList = denominator
			acumAux += chain(fullList)

	result = round(acum/acumAux,7)
	print (result)


reader = InputReader()
nodes, queries = reader.read()
for query in queries:
	convertToJoinProb(query)

#noChilds= getNodesWithoutChilds(["-Alarm", "+JohnCalls","-Earthquake", "-MaryCalls", "+Burglary"])
#noChilds= getNodesWithoutChilds(["-Earthquake", "-Alarm", "+Burglary"])
#noChilds= getNodesWithoutChilds(["-Earthquake",  "+Burglary"])