-
Notifications
You must be signed in to change notification settings - Fork 2
/
tester.py
90 lines (68 loc) · 2.24 KB
/
tester.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
__author__ = 'Johny Kannan'
import CreateRobot.myRobot as model
import CreateRobot as funcs
import numpy as np
state = [model.State(None, None, None, None) for i in range(0, 10)]
graph = model.PomdpGraph(10, 8)
graph.make_block(2, 1)
graph.make_block(2, 2)
graph.make_block(2, 3)
graph.make_block(2, 4)
graph.make_block(2, 5)
graph.make_block(2, 6)
graph.make_block(2, 7)
graph.make_block(4, 0)
graph.make_block(4, 1)
graph.make_block(4, 2)
graph.make_block(4, 3)
graph.make_block(4, 4)
graph.make_block(4, 5)
graph.re_graph()
for y in range(0, graph.dimension['breadth']):
for x in range(0, graph.dimension['length']):
if graph.get_state(x,y).left_state is None:
print('L', end='')
if graph.get_state(x,y).top_state is None:
print('T', end='')
if graph.get_state(x,y).right_state is None:
print('R', end='')
if graph.get_state(x,y).bottom_state is None:
print('D', end='')
print('\t', end='')
print()
graph.get_state(0, 2).belief = 200
graph.normalize()
funcs.print_graph_belief(graph)
graph.get_state(3, 3).set_as_destination(100)
graph.reward_state = graph.get_state(3, 3)
funcs.print_pomdp_utility(graph)
graph.find_optimal_pomdp()
funcs.print_pomdp_utility(graph)
# # action = {'Left': True, 'Right': False, 'Up': False, 'Down': False}
best_action = graph.give_next_action_pompd()
print(graph.give_next_action_pompd())
action = best_action
evidence = {'Left': 0.0, 'Right': 0.0, 'Up': 0.0,'Down': 0.0, 'Center': 1.0}
graph.update_beliefs(action)
#graph.normalize()
graph.update_evidence(evidence)
graph.normalize()
funcs.print_graph_belief(graph)
best_action = graph.give_next_action_pompd()
print(graph.give_next_action_pompd())
action = best_action
evidence = {'Left': 0.0, 'Right': 0.0, 'Up': 0.0,'Down': 0.0, 'Center': 1.0}
graph.update_beliefs(action)
#graph.normalize()
graph.update_evidence(evidence)
graph.normalize()
funcs.print_graph_belief(graph)
best_action = graph.give_next_action_pompd()
print(graph.give_next_action_pompd())
action = best_action
evidence = {'Left': 0.0, 'Right': 0.0, 'Up': 0.0,'Down': 0.0, 'Center': 1.0}
graph.update_beliefs(action)
#graph.normalize()
graph.update_evidence(evidence)
graph.normalize()
funcs.print_graph_belief(graph)