Create object outside of loop.
--- a/ai.js Thu Sep 25 02:05:48 2014 +0300
+++ b/ai.js Thu Sep 25 02:10:48 2014 +0300
@@ -395,12 +395,13 @@
if (wCached)
return wCached;
var wMin = +Infinity;
+ var randBoard = new this.brdEngine();
+ var nextBrd = new this.brdEngine();
for (var i = 0; i < 3; i++) {
for (var j = 0; j < 3; j++) {
if (brd.get(i, j) === 0) {
- var randBoard = brd.copy();
+ brd.copy(randBoard);
randBoard.set(i, j, 1);
- var nextBrd = new this.brdEngine();
var wMax2 = 0;
for (var diri = 0; diri < ai.dirs.length; diri++) {
if (randBoard[ai.dirs[diri]](nextBrd))