-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
151 lines (144 loc) · 6.46 KB
/
index.html
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
#content{
margin: auto;
margin-top: 50px;
padding: 50px;
border: dashed 2px royalblue;
border-radius: 10px;
width: 800px;
}
#debug{
border: solid 1px gray;
background-color: whitesmoke;
padding: 5px;
font-family: monospace;
}
</style>
</head>
<body>
<script type="template" id="q-table">
<% var decimalPlaces = 4 %>
<table>
<tr>
<td>
<!--empty -->
</td>
<td style="text-align: center; padding-right: 5px;">
<i style="color: gray">Action</i>
</td>
</tr>
<tr>
<td style="text-align: center; padding-right: 5px;">
<i style="color: gray">State</i>
</td>
<td>
<table cellspacing="0" style="padding: 5px;">
<tr style="padding: 5px; background-color: silver;">
<td style="background-color: whitesmoke;"></td>
<td>left</td>
<td>right</td>
</tr>
<% for(var i = 1; i <= N; i++) { %>
<% var qValue_left = Q[[i, -1]] || 0 %>
<% var qValue_right = Q[[i, +1]] || 0 %>
<tr>
<td style="padding: 5px; background-color: silver; "><%= i %></td>
<td style="font-weight: bold; padding: 5px; color: rgb( <%= Math.round(150*qValue_left + 100) %> , <%= (qValue_left)? 0 : 100 %>, <%= (qValue_left)? 100 : 100 %>)">
<%= (qValue_left).toFixed(decimalPlaces) %>
</td>
<td style="font-weight: bold; padding: 5px; color: rgb( <%= Math.round(150*qValue_right + 100) %> , <%= (qValue_right)? 0 : 100 %>, <%= (qValue_right)? 100 : 100 %>)">
<%= (qValue_right).toFixed(decimalPlaces) %>
</td>
</tr>
<% } %>
</table>
</td>
</tr>
</table>
</script>
<div id="content">
<h1>TODO: how to initialize and then decrease ε?</h1>
<h1>TODO: bug for ε values greedy vs explore?</h1>
<canvas id="canvas" width="800" height="300"></canvas>
<br>
States: <input type="number" id="num-of-states" min="1" max="50" step="1" value="10" style="width: 4em; text-align: center;" onchange="setNumberOfStates(+this.value)" />
<br>
Gamma: <input type="number" id="gamma" min="0" max="1" step="0.01" value="0.85" style="width: 4em; text-align: center;" onchange="learner.gamma = +this.value" />
<br>
Episodes per run: <input type="number" id="episodes-per-run" min="1" value="10" style="width: 3em; text-align: center;" />
<br>
<button id="reset" onclick="resetLearner();">reset</button>
<br>
<table>
<tr>
<td><b>Explore:</b> (ε = 1)</td>
<td>
<button id="step-explore" onclick="runQLearnerStepExploration();">step</button>
</td>
<td>
<button id="run-explore" onclick="runQLearnerExploration();">run</button>
</td>
</tr>
<tr>
<td><b>Exploit:</b>(ε = 0)</td>
<td>
<button id="step-exploit" onclick="runQLearnerStepGreedy();">step</button>
</td>
<td>
<button id="run-exploit" onclick="runQLearnerGreedy();">run</button>
</td>
</tr>
<tr>
<td><b>ε-greedy:</b>
(ε = <input type="number" id="epsilon" min="0" value="0.5" max="1" step="0.1" style="width: 3em; text-align: center;" />)
</td>
<td>
<button id="e-step" onclick="runQLearnerStepEpsilon();">step</button>
</td>
<td>
<button id="e-run" onclick="runQLearnerEpsilon();">run</button>
</td>
</tr>
<tr>
<td><b>varying ε-greedy:</b>
(initial ε = <input type="number" id="initial-epsilon" min="0" value="0.9" max="1" step="0.1" style="width: 3em; text-align: center;" />)
</td>
<td>
<button id="e-step" onclick="runQLearnerStepDecreaseEpsilon();" disabled="disabled">step</button>
</td>
<td>
<button id="e-run" onclick="runQLearnerDecreaseEpsilon();">run</button>
</td>
<td>
<button id="e-continue" onclick="runQLearnerDecreaseEpsilon(true);">continue (with current epsilon)</button>
</td>
</tr>
</table>
<!--<br>-->
<!--Total Episodes: <b id="total-episodes">0</b>-->
<br>
<br>
Delay: <b id="delay-current">?</b>
(
<b id="delay-from">10</b>
<input type="range" name="delay" value="500" min="10" max="1000" step="10" id="delay" onchange="document.getElementById('delay-current').innerHTML = this.value; setDelay(+this.value)">
<b id="delay-to">1000</b>
)
<br>
<!--<button id="run-NxN" onclick="runQLearner();">run N^2</button>-->
<br>
<br>
<b>Q-Function:</b>
<div id="debug">
hey
</div>
</div>
<script src="js/vendor/underscore.js"></script>
<script src="js/QLearner.js"></script>
<script src="js/main.js"></script>
</body>
</html>