Frame 1
stop();
allowed = "false";
loadVariables ("http://www.srcf.ucam.org/~mdob2/cgi-bin/log/logflash.cgi", this);
Instance of Symbol 1 MovieClip in Frame 1
onClipEvent (load) {
whole = int(_root.getBytesTotal() / 100) / 10;
}
onClipEvent (enterFrame) {
if ((_root.getBytesLoaded() != _root.getBytesTotal()) && (_root.allowed != "true")) {
partial = int(_root.getBytesLoaded() / 100) / 10;
_root.loadtext = (((" loaded: " + partial) + "k of ") + whole) + "k";
} else if ((partial == whole) && (_root.allowed != "true")) {
_root.loadtext = "game loaded...";
trace(blip);
} else if ((partial != whole) && (_root.allowed == "true")) {
_root.secure = "security key obtained";
partial = int(_root.getBytesLoaded() / 100) / 10;
_root.loadtext = (((" loaded: " + partial) + "k of ") + whole) + "k";
} else {
_root.gotoAndStop(2);
}
}
Frame 2
stop();
level = 1;
startfirst = 0;
Frame 3
function cleanup() {
s = 0;
while (s < 7) {
r = 0;
while (r < 6) {
removeMovieClip(((s + 1) + "") + (r + 1));
removeMovieClip((("r" + (s + 1)) + "") + (r + 1));
r++;
}
s++;
}
}
function takego(c) {
if (myGame.isAllowed(c)) {
myGame.addPiece(c, 2);
tellTarget (c add myGame.getHeight(c)) {
gotoAndStop (2);
};
blip = myGame.oppose();
if (blip != 0) {
tellTarget (blip add myGame.getHeight(blip)) {
gotoAndStop (3);
};
}
winner = myGame.endGame();
if (winner != 0) {
_root.display.text = "";
_root.block._visible = 1;
_root.block.gotoAndStop(winner - 1);
}
}
}
function reset(startf) {
arr = 1;
while (arr < 7) {
i = 1;
while (i < 8) {
duplicateMovieClip ("ring", (("r" + i) + "") + arr, ((100 + i) + (7 * arr)) + 1);
_root[(("r" + i) + "") + arr]._y = 235 - int(29.5 * arr);
_root[(("r" + i) + "") + arr]._x = int(34.5 * i) + 61;
duplicateMovieClip ("counter", (i + "") + arr, (i + (7 * arr)) + 1);
_root[(i + "") + arr]._y = 235 - int(29.5 * arr);
_root[(i + "") + arr]._x = int(34.5 * i) + 61;
i++;
}
arr++;
}
block._visible = 0;
infobubble._visible = "0";
myGame = new connect4(level);
startfirst = 1 - startf;
if (startf == 1) {
myGame.addPiece(4, 3);
tellTarget ("4" + myGame.getHeight(4)) {
gotoAndStop (3);
};
}
}
stop();
if ((allowed = "true")) {
reset(startfirst);
}
Symbol 74 MovieClip [__Packages.connect4] Frame 0
class connect4
{
var level, except, gamestatem;
function connect4 (difficulty) {
level = difficulty;
var _local3 = 1;
while (_local3 <= 7) {
p[_local3] = new Array();
h[_local3] = 0;
var _local2 = 1;
while (_local2 <= 6) {
p[_local3][_local2] = 1;
_local2++;
}
_local3++;
}
}
function minimax2(depth, count, min, max) {
var _local3;
var _local10;
var _local4;
var _local9 = 0;
if (count == depth) {
return(evaluate());
}
if ((count % 2) == 1) {
_local3 = max;
_local10 = evaluate();
if (_local10 > 8000) {
return(_local10);
}
var _local2 = 1;
while (_local2 <= 7) {
if (h[_local2] < 6) {
h[_local2]++;
p[_local2][h[_local2]] = 2;
_local4 = minimax2(depth, count + 1, min, _local3);
p[_local2][h[_local2]] = 1;
h[_local2]--;
if (_local4 < _local3) {
_local3 = _local4;
}
if (_local3 < min) {
return(min);
}
}
_local2++;
}
return(_local3);
}
if ((count % 2) == 0) {
_local3 = min;
_local10 = evaluate();
if (_local10 < -8000) {
return(_local10);
}
var _local2 = 1;
while (_local2 <= 7) {
if (h[_local2] < 6) {
h[_local2]++;
p[_local2][h[_local2]] = 3;
_local4 = minimax2(depth, count + 1, _local3, max);
p[_local2][h[_local2]] = 1;
h[_local2]--;
if (_local4 > _local3) {
if (count == 0) {
_local9 = _local2;
}
_local3 = _local4;
}
if (_local3 > max) {
if (count == 0) {
return(_local2);
}
return(max);
}
}
_local2++;
}
if (count == 0) {
return(_local9);
}
return(_local3);
}
return(0);
}
function evaluate() {
except = false;
gamestatem = 0;
var _local3 = 1;
while (_local3 <= 7) {
var _local2 = 4;
while (_local2 <= 6) {
gamest(p[_local3][_local2], p[_local3][_local2 - 1], p[_local3][_local2 - 2], p[_local3][_local2 - 3]);
_local2++;
}
_local3++;
}
_local3 = 1;
while (_local3 <= 4) {
var _local2 = 6;
while (_local2 >= 1) {
gamest(p[_local3][_local2], p[_local3 + 1][_local2], p[_local3 + 2][_local2], p[_local3 + 3][_local2]);
_local2--;
}
_local3++;
}
_local3 = 1;
while (_local3 <= 4) {
var _local2 = 1;
while (_local2 <= 3) {
gamest(p[_local3][_local2], p[_local3 + 1][_local2 + 1], p[_local3 + 2][_local2 + 2], p[_local3 + 3][_local2 + 3]);
_local2++;
}
_local3++;
}
_local3 = 1;
while (_local3 <= 4) {
var _local2 = 4;
while (_local2 <= 6) {
gamest(p[_local3][_local2], p[_local3 + 1][_local2 - 1], p[_local3 + 2][_local2 - 2], p[_local3 + 3][_local2 - 3]);
_local2++;
}
_local3++;
}
return(gamestatem);
}
function gamest(s0, s1, s2, s3) {
var _local3 = true;
var _local2 = ((s3 * s2) * s1) * s0;
if (_local2 == 1) {
_local2 = 0;
} else if ((_local2 % 2) != 0) {
_local2 = ((((s3 + 1) / 2) * ((s2 + 1) / 2)) * ((s1 + 1) / 2)) * ((s0 + 1) / 2);
_local3 = false;
} else if ((_local2 % 6) == 0) {
_local2 = 0;
}
if (_local2 == 16) {
_local2 = 10000;
except = true;
}
if (_local2 == 8) {
_local2 = 200;
}
if (_local3) {
gamestatem = gamestatem - _local2;
} else {
gamestatem = gamestatem + _local2;
}
}
function addPiece(row, color) {
h[row]++;
p[row][h[row]] = color;
}
function oppose() {
if (evaluate() < -8000) {
endgame = true;
winner = 2;
return(0);
}
var _local2 = minimax2(level, 0, -100000, 100000);
h[_local2]++;
p[_local2][h[_local2]] = 3;
if (evaluate() > 8000) {
endgame = true;
winner = 3;
}
return(_local2);
}
function getHeight(row) {
return(h[row]);
}
function isAllowed(row) {
if (endgame) {
return(false);
}
if (h[row] < 6) {
return(true);
}
return(false);
}
function endGame() {
if (endgame) {
return(winner);
}
return(0);
}
var p = new Array();
var h = new Array(8);
var endgame = false;
var winner = 0;
}
Symbol 21 Button
on (release) {
getURL ("connect4.shtml");
}
Symbol 25 Button
on (release) {
level = 1;
gotoAndStop (3);
}
Symbol 29 Button
on (release) {
level = 2;
gotoAndStop (3);
}
Symbol 33 Button
on (release) {
level = 4;
gotoAndStop (3);
}
Symbol 41 Button
on (release) {
takego(1);
}
Symbol 42 Button
on (release) {
takego(2);
}
Symbol 43 Button
on (release) {
takego(3);
}
Symbol 44 Button
on (release) {
takego(4);
}
Symbol 45 Button
on (release) {
takego(5);
}
Symbol 46 Button
on (release) {
takego(6);
}
Symbol 47 Button
on (release) {
takego(7);
}
Symbol 48 Button
on (release) {
cleanup();
gotoAndStop (2);
}
Symbol 57 Button
on (release) {
if (allowed == "true") {
reset(startfirst);
}
}
Symbol 61 MovieClip Frame 1
stop();
Symbol 67 Button
on (release) {
getURL ("http://www.become.co.uk/games/sendto.php", "_blank");
}
Symbol 72 MovieClip Frame 1
stop();