Frame 1
function judge(row, col, nowplay) {
var row0;
var col0;
var n;
var i = 0;
while (i < 4) {
n = 0;
row0 = row;
col0 = col;
while (((table[row0][col0] == nowplay) && (row0 >= 0)) && (col0 >= 0)) {
row0 = row0 - direc[i][0];
col0 = col0 - direc[i][1];
n++;
}
if (n > 4) {
return(true);
}
row0 = row + direc[i][0];
col0 = col + direc[i][1];
while (((table[row0][col0] == nowplay) && (row0 < 15)) && (col0 < 15)) {
row0 = row0 + direc[i][0];
col0 = col0 + direc[i][1];
n++;
}
if (n > 4) {
return(true);
}
i++;
}
return(false);
}
function delmc() {
for (var mcobj in _root.myboard) {
_root.myboard[mcobj].removeMovieClip();
}
_root.temp.splice(0);
}
function auto() {
var friend;
var computer;
var score = 0;
var row = 0;
var col = 0;
var i = 0;
while (i < 15) {
var j = 0;
while (j < 15) {
if (table[i][j] == 0) {
computer = checkmax(i, j, 1);
friend = checkmax(i, j, -1);
if ((computer + friend) > score) {
score = computer + friend;
row = i;
col = j;
}
}
j++;
}
i++;
}
var mymc = _root.myboard.attachMovie("chess1", ("ch" + row) + col, _root.myboard.getNextHighestDepth());
_root.dianjs = _root.dianjs + 1;
mymc._x = (col * 30) + 15;
mymc._y = (row * 30) + 15;
_root.table[row][col] = 1;
_root.myboard.rect._x = col * _root.myboard.mycell;
_root.myboard.rect._y = row * _root.myboard.mycell;
_root.temp.push(new Array(row, col));
_root.bus.gotoAndStop(2);
if (_root.judge(row, col, 1)) {
_root.gotoAndStop("computerwin");
}
}
function checkmax(row, col, nowplay) {
var autopostion = 0;
var now_score = 0;
var score = new Array();
var d = 0;
while (d < 4) {
var row0 = row;
var col0 = col;
score[d] = 0;
while (((((table[row0 - direc[d][0]][col0 - direc[d][1]] == nowplay) && ((row0 - direc[d][0]) >= 0)) && ((col0 - direc[d][1]) >= 0)) && ((row1 - direc[d][0]) < 15)) && ((col1 - direc[d][1]) < 15)) {
row0 = row0 - direc[d][0];
col0 = col0 - direc[d][1];
score[d] = score[d] + 1;
}
row1 = row;
col1 = col;
while (((((table[row1 + direc[d][0]][col1 + direc[d][1]] == nowplay) && ((row1 + direc[d][0]) >= 0)) && ((col1 + direc[d][1]) >= 0)) && ((row1 + direc[d][0]) < 15)) && ((col1 + direc[d][1]) < 15)) {
row1 = row1 + direc[d][0];
col1 = col1 + direc[d][1];
score[d] = score[d] + 1;
}
if (score[d] >= 4) {
autopostion = 20000;
return(autopostion);
}
if (table[row0 - direc[d][0]][col0 - direc[d][1]] == (-nowplay)) {
score[d] = score[d] - 1;
}
if (table[row1 + direc[d][0]][col1 + direc[d][1]] == (-nowplay)) {
score[d] = score[d] - 1;
}
score[d] = Math.pow(10, score[d]);
now_score = now_score + score[d];
d++;
}
autopostion = now_score;
return(autopostion);
}
function huiqi() {
var i = 0;
while (i < (3 - _root.wjs)) {
if (comfirst) {
if (temp.length > 1) {
obj = temp.pop();
_root.table[obj[0]][obj[1]] = 0;
_root.myboard[("ch" + obj[0]) + obj[1]].removeMovieClip();
with (_root.myboard) {
my = _root.temp[_root.temp.length - 1];
rect._x = my[1] * 30;
rect._y = my[0] * 30;
}
}
} else {
obj = temp.pop();
_root.table[obj[0]][obj[1]] = 0;
_root.myboard[("ch" + obj[0]) + obj[1]].removeMovieClip();
with (_root.myboard) {
my = _root.temp[_root.temp.length - 1];
rect._x = my[1] * 30;
rect._y = my[0] * 30;
}
}
i++;
}
if (_root.wjs == 2) {
if (_root.bus._currentframe == 1) {
_root.bus.gotoAndStop(2);
} else {
_root.bus.gotoAndStop(1);
}
}
if (_root.dianjs > 1) {
_root.dianjs = _root.dianjs - (3 - _root.wjs);
}
}
_root.dianjs = 0;
var direc = new Array();
direc[0] = new Array(1, 0);
direc[1] = new Array(0, 1);
direc[2] = new Array(1, 1);
direc[3] = new Array(1, -1);
var player = false;
var ysound = new Sound();
ysound.attachSound("chimes");
var temp = new Array();
table = new Array();
i = 0;
while (i < 15) {
table[i] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
i++;
}
stop();
Instance of Symbol 46 MovieClip "myboard" in Frame 1
onClipEvent (load) {
mycell = Math.floor(this._width / 15);
var row;
var col;
}
onClipEvent (mouseDown) {
row = Math.floor(this._ymouse / mycell);
col = Math.floor(this._xmouse / mycell);
}
onClipEvent (mouseUp) {
if (_root.wanj == 1) {
if (this.hitTest(_root._xmouse, _root._ymouse) && (_root.player)) {
if (_root.table[row][col] == 0) {
var mymc = this.attachMovie("chess2", ("ch" + row) + col, this.getNextHighestDepth());
_root.dianjs = _root.dianjs + 1;
_root.table[row][col] = -1;
mymc._x = (col * mycell) + (mycell / 2);
mymc._y = (row * mycell) + (mycell / 2);
_root.ysound.start();
_root.temp.push(new Array(row, col));
_root.bus.gotoAndStop(1);
if (_root.judge(row, col, -1)) {
_root.gotoAndStop("playerwin");
} else if (_root.wjs == 1) {
_root.js.play();
}
}
}
if (_root.wjs == 2) {
_root.wanj = 2;
}
} else if (_root.wjs == 2) {
if (this.hitTest(_root._xmouse, _root._ymouse) && (_root.player)) {
if (_root.table[row][col] == 0) {
var mymc = this.attachMovie("chess1", ("ch" + row) + col, this.getNextHighestDepth());
_root.dianjs = _root.dianjs + 1;
_root.table[row][col] = 1;
mymc._x = (col * mycell) + (mycell / 2);
mymc._y = (row * mycell) + (mycell / 2);
_root.ysound.start();
_root.temp.push(new Array(row, col));
_root.bus.gotoAndStop(2);
if (_root.judge(row, col, 1)) {
_root.gotoAndStop("playerwinb");
}
}
}
_root.wanj = 1;
}
if (_root.wjs == 2) {
this.rect._x = col * mycell;
this.rect._y = row * mycell;
}
}
Frame 2
_root.delmc();
var mc = _root.myboard.attachMovie("chess1", "ch77", _root.myboard.getNextHighestDepth());
_root.dianjs = _root.dianjs + 1;
mc._x = (7 * _root.myboard.mycell) + 15;
mc._y = (7 * _root.myboard.mycell) + 15;
_root.bus.gotoAndStop(2);
_root.table[7][7] = 1;
_root.player = true;
_root.myboard.rect._visible = true;
_root.temp.push(new Array(7, 7));
_root.myboard.rect._x = mc._x - 15;
_root.myboard.rect._y = mc._y - 15;
var comfirst = true;
_root.wanj = 1;
Instance of Symbol 16 MovieClip in Frame 2
onClipEvent (enterFrame) {
if (this.hitTest(_root.tankk.getBounds(_root).xMin, _root.tankk._y, true)) {
_root.tank._x = _root.tank._x + _root.sd;
}
if (this.hitTest(_root.tankk.getBounds(_root).xMax, _root.tankk._y, true)) {
_root.tank._x = _root.tank._x - _root.sd;
}
if (this.hitTest(_root.tankk._x, _root.tankk.getBounds(_root).yMin, true)) {
_root.tank._y = _root.tank._y + _root.sd;
}
if (this.hitTest(_root.tankk._x, _root.tankk.getBounds(_root).yMax, true)) {
_root.tank._y = _root.tank._y - _root.sd;
}
if (this.hitTest(_root.tankk1.getBounds(_root).xMin, _root.tankk1._y, true)) {
_root.tank1._x = _root.tank1._x + _root.sd1;
}
if (this.hitTest(_root.tankk1.getBounds(_root).xMax, _root.tankk1._y, true)) {
_root.tank1._x = _root.tank1._x - _root.sd1;
}
if (this.hitTest(_root.tankk1._x, _root.tankk1.getBounds(_root).yMin, true)) {
_root.tank1._y = _root.tank1._y + _root.sd1;
}
if (this.hitTest(_root.tankk1._x, _root.tankk1.getBounds(_root).yMax, true)) {
_root.tank1._y = _root.tank1._y - _root.sd1;
}
}
Frame 3
stop();
_root.player = true;
var comfirst = false;
delmc();
_root.dianjs = 0;
Frame 4
stop();
player = false;
var i = 0;
while (i < 15) {
var j = 0;
while (j < 15) {
_root.table[i][j] = 0;
j++;
}
i++;
}
_root.dianjs = 0;
Frame 5
stop();
player = false;
var i = 0;
while (i < 15) {
var j = 0;
while (j < 15) {
_root.table[i][j] = 0;
j++;
}
i++;
}
_root.dianjs = 0;
Frame 6
stop();
player = false;
var i = 0;
while (i < 15) {
var j = 0;
while (j < 15) {
_root.table[i][j] = 0;
j++;
}
i++;
}
_root.dianjs = 0;
Frame 7
player = false;
var i = 0;
while (i < 15) {
var j = 0;
while (j < 15) {
_root.table[i][j] = 0;
j++;
}
i++;
}
_root.dianjs = 0;
gotoAndStop (1);
Frame 8
player = false;
var i = 0;
while (i < 15) {
var j = 0;
while (j < 15) {
_root.table[i][j] = 0;
j++;
}
i++;
}
_root.dianjs = 0;
gotoAndStop (2);
Symbol 8 MovieClip [chess2] Frame 1
stop();
Symbol 26 Button
on (release) {
_root.wjs = 2;
gotoAndStop ("playerfirst");
}
Symbol 29 Button
on (release) {
_root.wjs = 1;
gotoAndStop ("computerfirst");
}
Symbol 31 Button
on (rollOver) {
_root.sm.gotoAndStop(2);
}
on (rollOut) {
_root.sm.gotoAndStop(1);
}
Symbol 43 MovieClip Frame 1
stop();
Instance of Symbol 13 MovieClip [rect] "rect" in Symbol 46 MovieClip Frame 1
onClipEvent (enterFrame) {
if (((_parent._parent._currentframe > 1) and (_parent._parent._currentframe < 4)) and (_root.dianjs > 0)) {
this.play();
} else {
gotoAndStop (3);
}
}
Symbol 51 MovieClip Frame 1
stop();
Symbol 51 MovieClip Frame 7
_root.auto();
Symbol 65 MovieClip Frame 1
stop();
Instance of Symbol 59 MovieClip in Symbol 65 MovieClip Frame 1
onClipEvent (load) {
stop();
}
Symbol 66 Button
on (release) {
_root.huiqi();
}
Symbol 68 Button
on (release) {
gotoAndPlay ("over");
}
Symbol 70 Button
on (release) {
gotoAndPlay ("overt");
}
Symbol 72 Button
on (release) {
gotoAndStop ("computerfirst");
}
Symbol 77 Button
on (release) {
gotoAndStop ("playerfirst");
}