-
Notifications
You must be signed in to change notification settings - Fork 0
/
testrun.py
46 lines (38 loc) · 1.36 KB
/
testrun.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
import environments as env
import agents as ag
# we are testing it on the very simple environment Celje
a = ag.Agent()
a.learn(env.CELJE, alg=ag.adp_random_exploration, numOfTrials=150, **{'maxItr': 20,
'tStep': 0.005,
'remember': True,
})
# outputs policy in graphics
print "Policy for all the possible positions of box: "
env.CELJE.printPolicy(a.getPolicy())
# get solution and print it for this simple example
solution = a.solve(env.CELJE, a.getPolicy())
print "Solution steps: " + str(solution)
# print solution steps in graphics
state = env.CELJE.getStartingState()
for move in solution[0]:
env.CELJE.printState(state)
state, reward, is_terminal = env.CELJE.do(state, move)
env.CELJE.printState(state)
# lets try it also on the GLIE scheme of R+ optimistic rewards
a.clearExperience()
a.learn(env.CELJE, alg=ag.adp_optimistic_rewards, numOfTrials=150, **{'maxItr': 20,
'R_plus': 1,
'N_e': 1,
})
# outputs policy in graphics
print "Policy for all the possible positions of box: "
env.CELJE.printPolicy(a.getPolicy())
# get solution and print it for this simple example
solution = a.solve(env.CELJE, a.getPolicy())
print "Solution steps: " + str(solution)
# print solution steps in graphics
state = env.CELJE.getStartingState()
for move in solution[0]:
env.CELJE.printState(state)
state, reward, is_terminal = env.CELJE.do(state, move)
env.CELJE.printState(state)