author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Mon, 08 Sep 2014 19:42:32 +0300 | |
changeset 21 | ed0292f0c7c6 |
parent 20 | ab294e8db00c |
child 25 | 2ef10a49a28f |
permissions | -rw-r--r-- |
0 | 1 |
<!DOCTYPE html> |
2 |
<html> |
|
3 |
<head> |
|
4 |
<title>2048 AI</title> |
|
5 |
<meta name="viewport" content="width=device-width; initial-scale=1.0"/> |
|
6 |
<meta charset="utf-8"/> |
|
7 |
||
10
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
8 |
<script src="rule.js"></script> |
7
d8106c8c0481
Rename methods and use sequential numbers instead of power of 2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
4
diff
changeset
|
9 |
<script src="board.js"></script> |
d8106c8c0481
Rename methods and use sequential numbers instead of power of 2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
4
diff
changeset
|
10 |
<script src="perf.js"></script> |
10
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
11 |
<script src="ai.js"></script> |
7
d8106c8c0481
Rename methods and use sequential numbers instead of power of 2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
4
diff
changeset
|
12 |
|
0 | 13 |
<style> |
14 |
body { |
|
15 |
width: 100%; |
|
16 |
} |
|
4 | 17 |
h1, div.area { |
0 | 18 |
text-align: center; |
4 | 19 |
margin: 10px auto; |
0 | 20 |
} |
21 |
#board { |
|
22 |
margin: 10px auto; |
|
23 |
} |
|
24 |
#board td { |
|
25 |
width: 40px; |
|
26 |
height: 40px; |
|
27 |
border: 1px solid red; |
|
28 |
margin: 0; |
|
29 |
text-align: center; |
|
30 |
} |
|
4 | 31 |
.report > .name { |
32 |
font-weight: bold; |
|
33 |
} |
|
0 | 34 |
</style> |
35 |
</head> |
|
36 |
<body> |
|
37 |
||
38 |
<h1>2048</h1> |
|
39 |
||
11
2264f7a3f7e0
Swap score parameters.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
10
diff
changeset
|
40 |
<div id="score-area" class="area">Score: <span id="score">0</span>, Max: <span id="max">0</span>, Turn: <span id="turn">0</span>, Speed: <span id="speed">0</span> t/s</div> |
0 | 41 |
|
4 | 42 |
<div id="message-area" class="area"></div> |
0 | 43 |
|
44 |
<table id="board"> |
|
45 |
<tr> |
|
46 |
<td></td> |
|
47 |
<td></td> |
|
48 |
<td></td> |
|
49 |
<td></td> |
|
50 |
</tr> |
|
51 |
<tr> |
|
52 |
<td></td> |
|
53 |
<td></td> |
|
54 |
<td></td> |
|
55 |
<td></td> |
|
56 |
</tr> |
|
57 |
<tr> |
|
58 |
<td></td> |
|
59 |
<td></td> |
|
60 |
<td></td> |
|
61 |
<td></td> |
|
62 |
</tr> |
|
63 |
<tr> |
|
64 |
<td></td> |
|
65 |
<td></td> |
|
66 |
<td></td> |
|
67 |
<td></td> |
|
68 |
</tr> |
|
69 |
</table> |
|
70 |
||
4 | 71 |
<div id="control-area" class="area"> |
0 | 72 |
<div> |
73 |
<button id="start">Start</button> |
|
74 |
<button id="step">Step</button> |
|
75 |
<button id="loop">Loop</button> |
|
76 |
<button id="finish">Finish</button> |
|
77 |
</div> |
|
78 |
<div> |
|
79 |
<button id="left">left</button> |
|
80 |
<button id="up">up</button> |
|
81 |
<button id="down">down</button> |
|
82 |
<button id="right">right</button> |
|
12
a9a44cfc3e08
Moves for 2d array board + test toolkit.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
11
diff
changeset
|
83 |
<button id="test">test</button> |
0 | 84 |
</div> |
85 |
<h1>AI</h1> |
|
86 |
<div> |
|
87 |
<button id="ai-random">random</button> |
|
88 |
<button id="ai-next-max-score">next max score</button> |
|
89 |
<button id="ai-next-max-value">next max value</button> |
|
14
9b49e710f5a7
Add "N level deep on score value without random" AI.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
13
diff
changeset
|
90 |
<button id="ai-deep-max-score">deep max score</button> |
20
ab294e8db00c
Add detecting value at edge or corner, free cell count. Added AI that count
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
17
diff
changeset
|
91 |
<button id="ai-deep-max-score-corner">deep max score corner</button> |
21
ed0292f0c7c6
Expectimax implementation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
20
diff
changeset
|
92 |
<button id="ai-expectimax">expectimax</button> |
0 | 93 |
</div> |
94 |
</div> |
|
95 |
||
4 | 96 |
<div id="report-area" class="area"> |
97 |
<h1>Reports</h1> |
|
98 |
<div class="report" class="area"> |
|
99 |
<div class="name">next max score</div> |
|
100 |
<table> |
|
101 |
<tr> |
|
102 |
<th>Max</th> |
|
103 |
<th>Count</th> |
|
104 |
<th>%</th> |
|
105 |
</tr> |
|
106 |
<tr> |
|
107 |
<td>128</td><td>8</td><td><div style="background: red; width: 100px">x</div></td> |
|
108 |
</tr> |
|
109 |
<tr> |
|
110 |
<td>256</td><td>4</td><td><div style="background: red; width: 50px">x</div></td> |
|
111 |
</tr> |
|
112 |
<tr> |
|
113 |
<td>512</td><td>12</td><td><div style="background: red; width: 150px">x</div></td> |
|
114 |
</tr> |
|
115 |
</table> |
|
116 |
</div> |
|
117 |
</div> |
|
118 |
||
0 | 119 |
<script> |
120 |
"use strict"; |
|
121 |
||
122 |
var boardDom = document.getElementById("board"); |
|
123 |
var ui = {}; |
|
124 |
ui.board = {}; |
|
15
0fa97e430a9e
ui.board.set care about 'val' argument.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
14
diff
changeset
|
125 |
/* 'val' typesafe. */ |
0 | 126 |
ui.board.set = function(i, j, val) { |
16 | 127 |
if (typeof val !== 'number') |
15
0fa97e430a9e
ui.board.set care about 'val' argument.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
14
diff
changeset
|
128 |
val = 0; |
13
b3bfa9d1b537
Add color to board depending on values..
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
12
diff
changeset
|
129 |
var dom = boardDom.querySelectorAll("tr")[i].querySelectorAll("td")[j]; |
15
0fa97e430a9e
ui.board.set care about 'val' argument.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
14
diff
changeset
|
130 |
if (0 < val && val < 15) { |
0fa97e430a9e
ui.board.set care about 'val' argument.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
14
diff
changeset
|
131 |
dom.innerHTML = val; |
0fa97e430a9e
ui.board.set care about 'val' argument.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
14
diff
changeset
|
132 |
var rgb = 'rgb(255,'+ (255-5*val-2*(val%2)) +','+ (255-10*val-5*((val-1)%2)) +')'; |
0fa97e430a9e
ui.board.set care about 'val' argument.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
14
diff
changeset
|
133 |
} else { |
0fa97e430a9e
ui.board.set care about 'val' argument.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
14
diff
changeset
|
134 |
dom.innerHTML = ''; |
0fa97e430a9e
ui.board.set care about 'val' argument.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
14
diff
changeset
|
135 |
var rgb = 'white'; |
0fa97e430a9e
ui.board.set care about 'val' argument.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
14
diff
changeset
|
136 |
} |
13
b3bfa9d1b537
Add color to board depending on values..
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
12
diff
changeset
|
137 |
dom.style.backgroundColor = rgb; |
0 | 138 |
} |
139 |
ui.board.update = function(brd) { |
|
140 |
for (var i = 0; i < 4; i++) { |
|
141 |
for (var j = 0; j < 4; j++) { |
|
15
0fa97e430a9e
ui.board.set care about 'val' argument.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
14
diff
changeset
|
142 |
ui.board.set(i, j, brd[i][j]); |
0 | 143 |
} |
144 |
} |
|
145 |
} |
|
17 | 146 |
ui.board.handleEdit = function(tdDom, i, j) { |
147 |
if (!tdDom.firstChild || tdDom.firstChild.nodeType === Node.TEXT_NODE) { |
|
148 |
if (tdDom.firstChild) |
|
149 |
tdDom.removeChild(tdDom.firstChild); |
|
150 |
var inputDom = document.createElement('input'); |
|
151 |
inputDom.value = board.current[i][j]; |
|
152 |
inputDom.style.width = '1em'; |
|
153 |
tdDom.appendChild(inputDom); |
|
154 |
inputDom.focus(); |
|
155 |
inputDom.select(); |
|
156 |
inputDom.addEventListener("blur", function(tdDom, i, j) { |
|
157 |
return function(event) { |
|
158 |
ui.board.handleEdit(tdDom, i, j); |
|
159 |
return false; |
|
160 |
} |
|
161 |
}(tdDom, i, j)); |
|
162 |
} else { |
|
163 |
var inputDom = tdDom.firstChild; |
|
164 |
var val = parseInt(inputDom.value); |
|
165 |
if (0 <= val && val < 15) { |
|
166 |
board.current[i][j] = val; |
|
167 |
ui.board.set(i, j, val); |
|
168 |
} else { |
|
169 |
ui.board.set(i, j, board.current[i][j]); |
|
170 |
} |
|
171 |
} |
|
172 |
} |
|
173 |
ui.board.enableEdit = function() { |
|
174 |
var trDoms = boardDom.querySelectorAll("tr"); |
|
175 |
for (var i = 0; i < 4; i++) { |
|
176 |
var tdDoms = trDoms[i].querySelectorAll("td"); |
|
177 |
for (var j = 0; j < 4; j++) { |
|
178 |
var tdDom = tdDoms[j]; |
|
179 |
tdDom.addEventListener("click", function(tdDom, i, j) { |
|
180 |
return function(event) { |
|
181 |
ui.board.handleEdit(tdDom, i, j); |
|
182 |
return false; |
|
183 |
} |
|
184 |
}(tdDom, i, j)); |
|
185 |
tdDom.addEventListener("keyup", function(tdDom, i, j) { |
|
186 |
return function(event) { |
|
187 |
if (event.keyCode === 13) |
|
188 |
ui.board.handleEdit(tdDom, i, j); |
|
189 |
} |
|
190 |
}(tdDom, i, j)); |
|
191 |
} |
|
192 |
} |
|
193 |
} |
|
194 |
ui.board.enableEdit(); |
|
195 |
||
0 | 196 |
ui.score = {}; |
197 |
var scoreDom = document.getElementById("score"); |
|
198 |
var maxDom = document.getElementById("max"); |
|
1 | 199 |
var speedDom = document.getElementById("speed"); |
200 |
var turnDom = document.getElementById("turn"); |
|
0 | 201 |
ui.score.clear = function(brd) { |
202 |
scoreDom.innerHTML = '0'; |
|
203 |
maxDom.innerHTML = '0'; |
|
1 | 204 |
speedDom.innerHTML = '0'; |
205 |
turnDom.innerHTML = '0'; |
|
0 | 206 |
} |
207 |
ui.score.update = function(brd) { |
|
208 |
var score = board.score(brd); |
|
209 |
scoreDom.innerHTML = '' + score.score; |
|
210 |
maxDom.innerHTML = '' + score.max; |
|
211 |
} |
|
1 | 212 |
ui.score.speed = function(speed, turn) { |
213 |
speedDom.innerHTML = '' + speed; |
|
214 |
turnDom.innerHTML = '' + turn; |
|
215 |
} |
|
0 | 216 |
|
217 |
function start() { |
|
218 |
ui.score.clear(); |
|
219 |
ui.message.clear(); |
|
220 |
board.current = board.create(); |
|
7
d8106c8c0481
Rename methods and use sequential numbers instead of power of 2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
4
diff
changeset
|
221 |
board.putRandom(board.current); |
0 | 222 |
ui.board.update(board.current); |
223 |
} |
|
224 |
document.getElementById("start").addEventListener("click", start); |
|
225 |
||
226 |
function up() { |
|
227 |
var updated = board.move.up(board.current); |
|
228 |
if (updated) { |
|
7
d8106c8c0481
Rename methods and use sequential numbers instead of power of 2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
4
diff
changeset
|
229 |
board.putRandom(board.current); |
0 | 230 |
ui.board.update(board.current); |
231 |
ui.score.update(board.current); |
|
232 |
} |
|
233 |
} |
|
234 |
document.getElementById("up").addEventListener("click", up); |
|
235 |
function down() { |
|
236 |
var updated = board.move.down(board.current); |
|
237 |
if (updated) { |
|
7
d8106c8c0481
Rename methods and use sequential numbers instead of power of 2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
4
diff
changeset
|
238 |
board.putRandom(board.current); |
0 | 239 |
ui.board.update(board.current); |
240 |
ui.score.update(board.current); |
|
241 |
} |
|
242 |
} |
|
243 |
document.getElementById("down").addEventListener("click", down); |
|
244 |
function left() { |
|
245 |
var updated = board.move.left(board.current); |
|
246 |
if (updated) { |
|
7
d8106c8c0481
Rename methods and use sequential numbers instead of power of 2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
4
diff
changeset
|
247 |
board.putRandom(board.current); |
0 | 248 |
ui.board.update(board.current); |
249 |
ui.score.update(board.current); |
|
250 |
} |
|
251 |
} |
|
252 |
document.getElementById("left").addEventListener("click", left); |
|
253 |
function right() { |
|
254 |
var updated = board.move.right(board.current); |
|
255 |
if (updated) { |
|
7
d8106c8c0481
Rename methods and use sequential numbers instead of power of 2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
4
diff
changeset
|
256 |
board.putRandom(board.current); |
0 | 257 |
ui.board.update(board.current); |
258 |
ui.score.update(board.current); |
|
259 |
} |
|
260 |
} |
|
261 |
document.getElementById("right").addEventListener("click", right); |
|
262 |
||
263 |
document.body.addEventListener("keydown", function(event) { |
|
264 |
var key = event.keyCode || event.which; |
|
265 |
switch (key) { |
|
266 |
case 38: up(); break; |
|
267 |
case 40: down(); break; |
|
268 |
case 37: left(); break; |
|
269 |
case 39: right(); break; |
|
270 |
} |
|
271 |
return false; |
|
272 |
}); |
|
12
a9a44cfc3e08
Moves for 2d array board + test toolkit.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
11
diff
changeset
|
273 |
|
a9a44cfc3e08
Moves for 2d array board + test toolkit.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
11
diff
changeset
|
274 |
document.getElementById("test").addEventListener("click", function() { |
a9a44cfc3e08
Moves for 2d array board + test toolkit.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
11
diff
changeset
|
275 |
board.move.replaceByBoardJS(ui.brdEngine); |
a9a44cfc3e08
Moves for 2d array board + test toolkit.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
11
diff
changeset
|
276 |
}); |
0 | 277 |
|
278 |
ui.message = {}; |
|
279 |
var messageDom = document.getElementById("message-area"); |
|
280 |
ui.message.clear = function() { |
|
281 |
messageDom.innerHTML = ""; |
|
282 |
} |
|
283 |
ui.message.set = function(msg) { |
|
284 |
messageDom.innerHTML = msg; |
|
285 |
} |
|
286 |
||
287 |
function step() { |
|
288 |
ui.message.clear(); |
|
289 |
if (board.gameOver(board.current)) { |
|
290 |
ui.message.set("Game over!"); |
|
291 |
return; |
|
292 |
} |
|
293 |
var tmpBrd = board.create(); |
|
294 |
board.copy(board.current, tmpBrd); |
|
10
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
295 |
var move = ui.ai.analyse(tmpBrd); |
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
296 |
if (typeof move === 'undefined') { |
0 | 297 |
ui.message.set("I don't know how to move!"); |
298 |
return; |
|
299 |
} |
|
10
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
300 |
var updated = board.move[move].call(null, board.current); |
0 | 301 |
if (updated) { |
7
d8106c8c0481
Rename methods and use sequential numbers instead of power of 2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
4
diff
changeset
|
302 |
board.putRandom(board.current); |
0 | 303 |
ui.board.update(board.current); |
304 |
ui.score.update(board.current); |
|
305 |
} else { |
|
306 |
ui.message.set("Wrong move!"); |
|
307 |
} |
|
308 |
} |
|
309 |
document.getElementById("step").addEventListener("click", step); |
|
310 |
||
311 |
function finish() { |
|
312 |
ui.message.clear(); |
|
1 | 313 |
var step = 0; |
314 |
var tsFrom = new Date().getTime(); |
|
0 | 315 |
while (!board.gameOver(board.current)) { |
316 |
var tmpBrd = board.create(); |
|
317 |
board.copy(board.current, tmpBrd); |
|
10
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
318 |
var move = ui.ai.analyse(tmpBrd); |
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
319 |
if (typeof move === 'undefined') { |
0 | 320 |
ui.message.set("I don't know how to move!"); |
321 |
return; |
|
322 |
} |
|
10
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
323 |
var updated = board.move[move].call(null, board.current); |
0 | 324 |
if (updated) { |
7
d8106c8c0481
Rename methods and use sequential numbers instead of power of 2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
4
diff
changeset
|
325 |
board.putRandom(board.current); |
0 | 326 |
} else { |
327 |
ui.board.update(board.current); |
|
328 |
ui.score.update(board.current); |
|
329 |
ui.message.set("Wrong move!"); |
|
330 |
return; |
|
331 |
} |
|
1 | 332 |
step++; |
0 | 333 |
} |
1 | 334 |
var tsTo = new Date().getTime(); |
0 | 335 |
ui.board.update(board.current); |
336 |
ui.score.update(board.current); |
|
1 | 337 |
ui.score.speed(step*1000.0/(tsTo-tsFrom), step); |
0 | 338 |
ui.message.set("Game over!"); |
339 |
} |
|
340 |
document.getElementById("finish").addEventListener("click", finish); |
|
341 |
||
10
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
342 |
//////////////////////////////////////////////////////////////// |
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
343 |
// Register AIs. |
0 | 344 |
|
10
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
345 |
ui.brdEngine = BoardArr2d; // TODO make user selectable |
0 | 346 |
|
10
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
347 |
document.getElementById("ai-random").addEventListener("click", function() { |
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
348 |
ui.ai = new ai.random(ui.brdEngine); |
0 | 349 |
}); |
10
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
350 |
document.getElementById("ai-next-max-score").addEventListener("click", function() { |
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
351 |
ui.ai = new ai.nextMaxScore(ui.brdEngine); |
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
352 |
}); |
0 | 353 |
document.getElementById("ai-next-max-value").addEventListener("click", function() { |
10
70ece7f758a0
Move rule and AI engine to separate files.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
7
diff
changeset
|
354 |
ui.ai = new ai.nextMaxValue(ui.brdEngine); |
0 | 355 |
}); |
14
9b49e710f5a7
Add "N level deep on score value without random" AI.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
13
diff
changeset
|
356 |
document.getElementById("ai-deep-max-score").addEventListener("click", function() { |
9b49e710f5a7
Add "N level deep on score value without random" AI.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
13
diff
changeset
|
357 |
ui.ai = new ai.deepMaxScore(ui.brdEngine); |
9b49e710f5a7
Add "N level deep on score value without random" AI.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
13
diff
changeset
|
358 |
}); |
20
ab294e8db00c
Add detecting value at edge or corner, free cell count. Added AI that count
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
17
diff
changeset
|
359 |
document.getElementById("ai-deep-max-score-corner").addEventListener("click", function() { |
ab294e8db00c
Add detecting value at edge or corner, free cell count. Added AI that count
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
17
diff
changeset
|
360 |
ui.ai = new ai.deepMaxScoreCorner(ui.brdEngine); |
ab294e8db00c
Add detecting value at edge or corner, free cell count. Added AI that count
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
17
diff
changeset
|
361 |
}); |
21
ed0292f0c7c6
Expectimax implementation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
20
diff
changeset
|
362 |
document.getElementById("ai-expectimax").addEventListener("click", function() { |
ed0292f0c7c6
Expectimax implementation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
20
diff
changeset
|
363 |
ui.ai = new ai.expectimax(ui.brdEngine); |
ed0292f0c7c6
Expectimax implementation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
20
diff
changeset
|
364 |
}); |
0 | 365 |
|
366 |
</script> |
|
367 |
||
368 |
</body> |
|
369 |
</html> |