Frame 1
stop();
onEnterFrame = function () {
_root.pbar._width = 320 * (_root.getBytesLoaded() / _root.getBytesTotal());
if (_root.getBytesLoaded() == _root.getBytesTotal()) {
delete onEnterFrame;
play();
}
};
Instance of Symbol 21 MovieClip in Frame 1
on (release) {
getURL ("http://www.addicting-flash-games.com", "_blank");
}
Frame 2
stop();
var players = 0;
var player = 0;
var boxes = [];
var turns = 0;
Instance of Symbol 21 MovieClip in Frame 2
on (release) {
getURL ("http://www.addicting-flash-games.com", "_blank");
}
Instance of Symbol 23 MovieClip in Frame 2
on (press) {
_root.players = 1;
_root.gotoAndStop("game");
}
Instance of Symbol 25 MovieClip in Frame 2
on (press) {
_root.players = 2;
_root.gotoAndStop("game");
}
Frame 3
function boxPress(x, y, cpu) {
if (((_root.players == 2) || (_root.player == 1)) || (cpu)) {
if (!_root.boxes[x][y].player) {
_root.boxes[x][y].player = _root.player;
_root.boxes[x][y].gotoAndStop(_root.player + 1);
_root.checkPoints(_root.player, x, y, false);
_root.turns--;
if (!_root.turns) {
return(_root.gotoAndStop("over"));
}
_root.player = ((_root.player == 1) ? 2 : 1);
if ((_root.players == 1) && (_root.player == 2)) {
setTimeout(_root.aiPlay, 500);
}
}
}
}
function checkPoints(p, x, y, checkonly) {
var _local7 = [0, 5, 15, 30, 50];
var _local6 = 0;
var _local5 = [-1, 1];
j = 0;
while (j < 2) {
k = 0;
while (k < 2) {
if (((((_root.boxes[x][y].player == p) || (!_root.boxes[x][y].player)) && (_root.boxes[x + _local5[j]][y + _local5[k]].player == p)) && (_root.boxes[x + _local5[j]][y].player == p)) && (_root.boxes[x][y + _local5[k]].player == p)) {
_local6++;
}
k++;
}
j++;
}
if (!checkonly) {
_root["score" + p].text = int(_root["score" + p].text) + _local7[_local6];
}
return(_local7[_local6]);
}
function aiPlay() {
var _local10 = random(12);
var _local9 = random(12);
var _local5 = 0;
var _local8 = 0;
var _local4;
var _local7 = -1;
var _local6 = -1;
pass = 0;
while (pass <= 3) {
var _local3 = _local10;
var _local2 = _local9;
_local5 = 0;
var _local11 = false;
do {
if (_root.boxes[_local3][_local2] && (!_root.boxes[_local3][_local2].player)) {
switch (pass) {
case 0 :
_local4 = checkPoints(_root.player, _local3, _local2, true);
if (_local4 > _local5) {
_local7 = _local3;
_local6 = _local2;
_local5 = _local4;
}
break;
case 1 :
_local4 = checkPoints(((_root.player == 1) ? 2 : 1), _local3, _local2, true);
if (_local4 > _local5) {
_local7 = _local3;
_local6 = _local2;
_local5 = _local4;
}
break;
case 2 :
_local4 = 0;
if (_root.boxes[_local3 - 1][_local2].player == _root.player) {
_local4++;
}
if (_root.boxes[_local3][_local2 - 1].player == _root.player) {
_local4++;
}
if (_root.boxes[_local3 + 1][_local2].player == _root.player) {
_local4++;
}
if (_root.boxes[_local3][_local2 + 1].player == _root.player) {
_local4++;
}
if ((_root.boxes[_local3 - 1][_local2 - 1].player == _root.player) && ((_root.boxes[_local3 - 1][_local2].player == _root.player) || (_root.boxes[_local3][_local2 - 1].player == _root.player))) {
_local4++;
}
if ((_root.boxes[_local3 - 1][_local2 + 1].player == _root.player) && ((_root.boxes[_local3 - 1][_local2].player == _root.player) || (_root.boxes[_local3][_local2 + 1].player == _root.player))) {
_local4++;
}
if ((_root.boxes[_local3 + 1][_local2 - 1].player == _root.player) && ((_root.boxes[_local3][_local2 - 1].player == _root.player) || (_root.boxes[_local3 + 1][_local2].player == _root.player))) {
_local4++;
}
if ((_root.boxes[_local3 + 1][_local2 + 1].player == _root.player) && ((_root.boxes[_local3][_local2 + 1].player == _root.player) || (_root.boxes[_local3 + 1][_local2].player == _root.player))) {
_local4++;
}
if (_local4 > _local8) {
_local7 = _local3;
_local6 = _local2;
_local8 = _local4;
}
break;
case 3 :
if (_root.boxes[_local3][_local2].player) {
break;
}
return(boxPress(_local3, _local2, true));
}
}
_local3++;
if (_local3 >= 12) {
_local3 = 0;
_local2++;
}
if (_local2 >= 12) {
_local2 = 0;
}
} while ((_local2 != _local9) || (_local3 != _local10));
if ((pass >= 1) && ((_local7 >= 0) || (_local6 >= 0))) {
return(boxPress(_local7, _local6, true));
}
pass++;
}
_root.player = ((_root.player == 1) ? 2 : 1);
}
stop();
var player = 1;
var boxes = [];
var turns = 0;
x = 0;
while (x < 12) {
if (!boxes[x]) {
boxes[x] = [];
}
y = 0;
while (y < 12) {
_root.turns++;
if (!boxes[x][y]) {
boxes[x][y] = game.attachMovie("Box", (("box" + x) + "x") + y, game.getNextHighestDepth());
}
boxes[x][y].player = 0;
boxes[x][y].boxX = x;
boxes[x][y].boxY = y;
boxes[x][y]._x = (4 + (x * 30)) + ((x > 0) ? (x * 2) : 0);
boxes[x][y]._y = (4 + (y * 30)) + ((y > 0) ? (y * 2) : 0);
boxes[x][y]._width = 30;
boxes[x][y]._height = 30;
boxes[x][y].gotoAndStop(1);
y++;
}
x++;
}
Frame 4
stop();
Instance of Symbol 36 MovieClip in Frame 4
on (press) {
_root.gotoAndStop("start");
}
Symbol 5 MovieClip [Box] Frame 1
this.onPress = function () {
_root.boxPress(this.boxX, this.boxY, false);
};
stop();
Symbol 5 MovieClip [Box] Frame 2
stop();
Symbol 5 MovieClip [Box] Frame 3
stop();