-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeepest_descent.py
More file actions
29 lines (22 loc) · 833 Bytes
/
deepest_descent.py
File metadata and controls
29 lines (22 loc) · 833 Bytes
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
from hill_climbing import *
TIPOS = [ (1,3), (4,6), (5,7) ]
def deepest_descent(types, max_size, state):
best_state = state
#print(best_state)
while True:
validStates = []
expandedStates = expandState(best_state)
validStates = list(
filter(
lambda state: stateIsValid(state, types, max_size),
expandedStates,
)
)
if not validStates:
return best_state
validStates.sort(key=lambda x: stateValue(x, types))
best_state = validStates.pop()
if __name__ == "__main__":
result = deepest_descent(TIPOS, 19, [0,0,0])
print(str(result)+" - Deepest Descent")
print("Custo da solução: "+str(stateSize(result, TIPOS))+", Valor da solução: "+str(stateValue(result, TIPOS)))