Instance of Symbol 8 MovieClip "Loading_mc" in Frame 1
onClipEvent (enterFrame) {
var iPercent = Math.ceil((_root.getBytesLoaded() * 100) / _root.getBytesTotal());
this.ProgressBar_mc._width = iPercent * 2;
if (iPercent >= 100) {
SoundControl.Mute();
_root.gotoAndPlay(6);
} else {
_root.gotoAndPlay(1);
}
}
Instance of Symbol 11 MovieClip "Scoreboard_mc" in Frame 3
onClipEvent (load) {
function SetScoreRed(iScore) {
if (iScore < 10) {
this.ScoreRed.text = "0" + iScore;
} else {
this.ScoreRed.text = "" + iScore;
}
this.ScoreRed.setTextFormat(oScoreText);
}
function SetScoreBlue(iScore) {
if (iScore < 10) {
this.ScoreBlue.text = "0" + iScore;
} else {
this.ScoreBlue.text = "" + iScore;
}
this.ScoreBlue.setTextFormat(oScoreText);
}
var oScoreText = new TextFormat();
oScoreText.size = 24;
this.createTextField("ScoreRed", 21, 60, 34, 1, 1);
this.ScoreRed.textColor = 13369344 /* 0xCC0000 */;
this.ScoreRed.autoSize = "left";
this.ScoreRed.type = "dynamic";
this.ScoreRed.selectable = false;
this.createTextField("ScoreBlue", 25, 510, 34, 1, 1);
this.ScoreBlue.textColor = 204;
this.ScoreBlue.autoSize = "left";
this.ScoreBlue.type = "dynamic";
this.ScoreBlue.selectable = false;
}
Instance of Symbol 14 MovieClip [s_RedSide] "RedSide_mc" in Frame 3
/* no clip actions */
Instance of Symbol 28 MovieClip "Menu_mc" in Frame 3
onClipEvent (load) {
function ShowMenu() {
bOptions = false;
bInstructions = false;
this._visible = true;
}
function PlayGame() {
bOptions = false;
oGameCtr.Play(_root.Options_mc.bHuman, _root.Options_mc.iAILevel, _root.Options_mc.iBoardDim, _root.Options_mc.iTargetSum, _root.Options_mc.iScore);
}
var c_sVersion = "Ver 1.0";
var c_sClr0 = "Black";
var c_sClr1 = "Red";
var c_sClr2 = "Blue";
var bPlayClicked = false;
var bInstructionsClicked = false;
var bOptions = false;
var bInstructions = false;
var iCount;
_root.Options_mc._visible = false;
_root.Instructions_mc._visible = false;
this.attachMovie("s_MenuTitle", "MenuTitle_mc", 10);
this.MenuTitle_mc._x = 100;
this.MenuTitle_mc._y = 50;
this.attachMovie("s_PlayBlack", "PlayBlack_mc", 11);
this.PlayBlack_mc._x = 200;
this.PlayBlack_mc._y = 150;
this.attachMovie("s_PlayRed", "PlayRed_mc", 12);
this.PlayRed_mc._x = 200;
this.PlayRed_mc._y = 150;
this.PlayRed_mc._visible = false;
this.attachMovie("s_InstructionsBlack", "InstructionsBlack_mc", 13);
this.InstructionsBlack_mc._x = 200;
this.InstructionsBlack_mc._y = 225;
this.attachMovie("s_InstructionsRed", "InstructionsRed_mc", 14);
this.InstructionsRed_mc._x = 200;
this.InstructionsRed_mc._y = 225;
this.InstructionsRed_mc._visible = false;
this.attachMovie("s_Copyright", "Copyright_mc", 15);
this.Copyright_mc._x = 128;
this.Copyright_mc._y = 360;
var oVersionFormat = new TextFormat();
oVersionFormat.size = 12;
this.createTextField("Version", 16, 532, 370, 1, 1);
this.Version.text = c_sVersion;
this.Version.setTextFormat(oVersionFormat);
this.Version.textColor = 16777215 /* 0xFFFFFF */;
this.Version.autoSize = "left";
this.Version.type = "dynamic";
this.Version.selectable = false;
SoundControl.UnMute();
SoundControl.Init();
var oGameCtr = new GameControl();
oGameCtr.Init();
}
onClipEvent (mouseDown) {
var mx = _root._xmouse;
var my = _root._ymouse;
if (oGameCtr.IsRunning()) {
oGameCtr.Click(mx, my);
} else if (bOptions) {
_root.Options_mc.Click(mx, my);
iCount = 0;
} else if (bInstructions) {
_root.Instructions_mc.Click(mx, my);
iCount = 0;
} else if (this.PlayBlack_mc.hitTest(mx, my)) {
bPlayClicked = true;
iCount = 0;
this.PlayRed_mc._visible = true;
this.PlayBlack_mc._visible = false;
SoundControl.ButtonClick();
} else if (this.InstructionsBlack_mc.hitTest(mx, my)) {
bInstructionsClicked = true;
iCount = 0;
this.InstructionsRed_mc._visible = true;
this.InstructionsBlack_mc._visible = false;
SoundControl.ButtonClick();
}
}
onClipEvent (keyDown) {
if (Key.isDown(77)) {
SoundControl.ToggleMute();
return(undefined);
}
if (oGameCtr.IsRunning()) {
if (Key.isDown(81)) {
oGameCtr.End();
} else if (Key.isDown(73)) {
oGameCtr.ToggleInfo();
}
} else if (bOptions) {
if (Key.isDown(13)) {
_root.Options_mc.PlayAction();
}
} else if (bInstructions) {
if (Key.isDown(13)) {
_root.Instructions_mc.MainMenu();
} else if (Key.isDown(38)) {
_root.Instructions_mc.PageUp();
} else if (Key.isDown(40)) {
_root.Instructions_mc.PageDown();
}
}
}
onClipEvent (enterFrame) {
if (oGameCtr.IsRunning()) {
oGameCtr.Refresh();
} else if (bOptions) {
if (iCount < 1) {
iCount++;
_root.gotoAndPlay(3);
return(undefined);
}
_root.Options_mc.Refresh();
} else if (bInstructions) {
if (iCount < 1) {
iCount++;
_root.gotoAndPlay(3);
return(undefined);
}
_root.Instructions_mc.Refresh();
} else {
if (iCount < 1) {
iCount++;
_root.gotoAndPlay(3);
return(undefined);
}
if (bPlayClicked) {
bPlayClicked = false;
this.PlayRed_mc._visible = false;
this.PlayBlack_mc._visible = true;
this._visible = false;
_root.Options_mc._visible = true;
bOptions = true;
} else if (bInstructionsClicked) {
bInstructionsClicked = false;
this.InstructionsRed_mc._visible = false;
this.InstructionsBlack_mc._visible = true;
this._visible = false;
_root.Instructions_mc._visible = true;
bInstructions = true;
}
}
_root.gotoAndPlay(3);
}
Instance of Symbol 28 MovieClip "Options_mc" in Frame 3
onClipEvent (load) {
function PlayAction() {
bPlay = true;
this.PlayBlack_mc._visible = false;
this.PlayRed_mc._visible = true;
SoundControl.ButtonClick();
}
function MainMenu() {
this._visible = false;
_root.Menu_mc.Show();
}
function Click(mx, my) {
var _local5 = 0;
while (_local5 < 5) {
if (iAILevel != _local5) {
if (this[("Op" + _local5) + "Black_mc"].hitTest(mx, my)) {
this[("Op" + iAILevel) + "Blue_mc"]._visible = false;
this[("Op" + iAILevel) + "Black_mc"]._visible = true;
iAILevel = _local5;
this[("Op" + iAILevel) + "Blue_mc"]._visible = true;
this[("Op" + iAILevel) + "Black_mc"]._visible = false;
if (iAILevel == 4) {
bHuman = true;
} else {
bHuman = false;
}
return(undefined);
}
}
_local5++;
}
var _local3 = 3;
while (_local3 < 6) {
if (iBoardDim != _local3) {
if (this[("B" + _local3) + "Black_mc"].hitTest(mx, my)) {
this[("B" + iBoardDim) + "Blue_mc"]._visible = false;
this[("B" + iBoardDim) + "Black_mc"]._visible = true;
iBoardDim = _local3;
this[("B" + iBoardDim) + "Blue_mc"]._visible = true;
this[("B" + iBoardDim) + "Black_mc"]._visible = false;
return(undefined);
}
}
_local3++;
}
var _local2 = 11;
while (_local2 < 16) {
if (iTargetSum != _local2) {
if (this[("Target" + _local2) + "Black_mc"].hitTest(mx, my)) {
this[("Target" + iTargetSum) + "Blue_mc"]._visible = false;
this[("Target" + iTargetSum) + "Black_mc"]._visible = true;
iTargetSum = _local2;
this[("Target" + iTargetSum) + "Blue_mc"]._visible = true;
this[("Target" + iTargetSum) + "Black_mc"]._visible = false;
return(undefined);
}
}
_local2 = _local2 + 2;
}
var _local4 = 9;
while (_local4 < 37) {
if (iScore != _local4) {
if (this[("Score" + _local4) + "Black_mc"].hitTest(mx, my)) {
this[("Score" + iScore) + "Blue_mc"]._visible = false;
this[("Score" + iScore) + "Black_mc"]._visible = true;
iScore = _local4;
this[("Score" + iScore) + "Blue_mc"]._visible = true;
this[("Score" + iScore) + "Black_mc"]._visible = false;
return(undefined);
}
}
_local4 = _local4 * 2;
}
if (this.PlayBlack_mc.hitTest(mx, my)) {
PlayAction();
}
}
function Refresh() {
if (bPlay) {
bPlay = false;
this.PlayBlack_mc._visible = true;
this.PlayRed_mc._visible = false;
this._visible = false;
_root.Menu_mc.PlayGame();
}
}
var bHuman = false;
var iAILevel = 0;
var iBoardDim = 3;
var iTargetSum = 13;
var iScore = 18;
var bPlay = false;
this.attachMovie("s_Opponent", "Opponent_mc", 15);
this.Opponent_mc._x = 0;
this.Opponent_mc._y = 5;
this.attachMovie("s_EasyBlack", "Op0Black_mc", 21);
this.Op0Black_mc._x = 14;
this.Op0Black_mc._y = 45;
this.Op0Black_mc._visible = false;
this.attachMovie("s_EasyBlue", "Op0Blue_mc", 26);
this.Op0Blue_mc._x = 14;
this.Op0Blue_mc._y = 45;
this.attachMovie("s_NormalBlack", "Op1Black_mc", 22);
this.Op1Black_mc._x = 158;
this.Op1Black_mc._y = 45;
this.attachMovie("s_NormalBlue", "Op1Blue_mc", 27);
this.Op1Blue_mc._x = 158;
this.Op1Blue_mc._y = 45;
this.Op1Blue_mc._visible = false;
this.attachMovie("s_HardBlack", "Op2Black_mc", 23);
this.Op2Black_mc._x = 302;
this.Op2Black_mc._y = 45;
this.attachMovie("s_HardBlue", "Op2Blue_mc", 28);
this.Op2Blue_mc._x = 302;
this.Op2Blue_mc._y = 45;
this.Op2Blue_mc._visible = false;
this.attachMovie("s_VeryHardBlack", "Op3Black_mc", 24);
this.Op3Black_mc._x = 446;
this.Op3Black_mc._y = 45;
this.attachMovie("s_VeryHardBlue", "Op3Blue_mc", 29);
this.Op3Blue_mc._x = 446;
this.Op3Blue_mc._y = 45;
this.Op3Blue_mc._visible = false;
this.attachMovie("s_HumanBlack", "Op4Black_mc", 25);
this.Op4Black_mc._x = 230;
this.Op4Black_mc._y = 77;
this.attachMovie("s_HumanBlue", "Op4Blue_mc", 30);
this.Op4Blue_mc._x = 230;
this.Op4Blue_mc._y = 77;
this.Op4Blue_mc._visible = false;
this.attachMovie("s_BoardSize", "BoardSize_mc", 16);
this.BoardSize_mc._x = 0;
this.BoardSize_mc._y = 120;
this.attachMovie("s_3x3Black", "B3Black_mc", 31);
this.B3Black_mc._x = 80;
this.B3Black_mc._y = 158;
this.B3Black_mc._visible = false;
this.attachMovie("s_3x3Blue", "B3Blue_mc", 34);
this.B3Blue_mc._x = 80;
this.B3Blue_mc._y = 158;
this.attachMovie("s_4x4Black", "B4Black_mc", 32);
this.B4Black_mc._x = 236;
this.B4Black_mc._y = 158;
this.attachMovie("s_4x4Blue", "B4Blue_mc", 35);
this.B4Blue_mc._x = 236;
this.B4Blue_mc._y = 158;
this.B4Blue_mc._visible = false;
this.attachMovie("s_5x5Black", "B5Black_mc", 33);
this.B5Black_mc._x = 392;
this.B5Black_mc._y = 158;
this.attachMovie("s_5x5Blue", "B5Blue_mc", 36);
this.B5Blue_mc._x = 392;
this.B5Blue_mc._y = 158;
this.B5Blue_mc._visible = false;
this.attachMovie("s_TargetOption", "TargetOption_mc", 17);
this.TargetOption_mc._x = 0;
this.TargetOption_mc._y = 199;
this.attachMovie("s_15_21Black", "Target15Black_mc", 40);
this.Target15Black_mc._x = 80;
this.Target15Black_mc._y = 237;
this.attachMovie("s_15_21Blue", "Target15Blue_mc", 41);
this.Target15Blue_mc._x = 80;
this.Target15Blue_mc._y = 237;
this.Target15Blue_mc._visible = false;
this.attachMovie("s_13_23Black", "Target13Black_mc", 42);
this.Target13Black_mc._x = 236;
this.Target13Black_mc._y = 237;
this.Target13Black_mc._visible = false;
this.attachMovie("s_13_23Blue", "Target13Blue_mc", 43);
this.Target13Blue_mc._x = 236;
this.Target13Blue_mc._y = 237;
this.attachMovie("s_11_25Black", "Target11Black_mc", 44);
this.Target11Black_mc._x = 392;
this.Target11Black_mc._y = 237;
this.attachMovie("s_11_25Blue", "Target11Blue_mc", 45);
this.Target11Blue_mc._x = 392;
this.Target11Blue_mc._y = 237;
this.Target11Blue_mc._visible = false;
this.attachMovie("s_ScoreOption", "ScoreOption_mc", 18);
this.ScoreOption_mc._x = 0;
this.ScoreOption_mc._y = 278;
this.attachMovie("s_Score9Black", "Score9Black_mc", 50);
this.Score9Black_mc._x = 80;
this.Score9Black_mc._y = 316;
this.attachMovie("s_Score9Blue", "Score9Blue_mc", 51);
this.Score9Blue_mc._x = 80;
this.Score9Blue_mc._y = 316;
this.Score9Blue_mc._visible = false;
this.attachMovie("s_Score18Black", "Score18Black_mc", 52);
this.Score18Black_mc._x = 236;
this.Score18Black_mc._y = 316;
this.Score18Black_mc._visible = false;
this.attachMovie("s_Score18Blue", "Score18Blue_mc", 53);
this.Score18Blue_mc._x = 236;
this.Score18Blue_mc._y = 316;
this.attachMovie("s_Score36Black", "Score36Black_mc", 54);
this.Score36Black_mc._x = 392;
this.Score36Black_mc._y = 316;
this.attachMovie("s_Score36Blue", "Score36Blue_mc", 55);
this.Score36Blue_mc._x = 392;
this.Score36Blue_mc._y = 316;
this.Score36Blue_mc._visible = false;
this.attachMovie("s_OptionsPlay", "OptionsPlay_mc", 19);
this.OptionsPlay_mc._x = 0;
this.OptionsPlay_mc._y = 357;
this.attachMovie("s_PlayBlack", "PlayBlack_mc", 60);
this.PlayBlack_mc._x = 230;
this.PlayBlack_mc._y = 362;
this.PlayBlack_mc._width = 140;
this.PlayBlack_mc._height = 28;
this.attachMovie("s_PlayRed", "PlayRed_mc", 61);
this.PlayRed_mc._x = 230;
this.PlayRed_mc._y = 362;
this.PlayRed_mc._width = 140;
this.PlayRed_mc._height = 28;
this.PlayRed_mc._visible = false;
}
Instance of Symbol 28 MovieClip "Instructions_mc" in Frame 3
onClipEvent (load) {
function MainMenu() {
this.CloseBlack_mc._visible = false;
this.CloseRed_mc._visible = true;
bClose = true;
}
function PageUp() {
if (iPageNum > 0) {
this.UpBlack_mc._visible = false;
this.UpRed_mc._visible = true;
bUp = true;
}
}
function PageDown() {
if (iPageNum < (aPages.length - 1)) {
this.DownBlack_mc._visible = false;
this.DownRed_mc._visible = true;
bDown = true;
}
}
function Click(mx, my) {
if (this.CloseBlack_mc.hitTest(mx, my)) {
MainMenu();
} else if (this.UpBlack_mc._visible && (this.UpBlack_mc.hitTest(mx, my))) {
PageUp();
} else if (this.DownBlack_mc._visible && (this.DownBlack_mc.hitTest(mx, my))) {
PageDown();
}
}
function Refresh() {
if (bClose) {
this.CloseBlack_mc._visible = true;
this.CloseRed_mc._visible = false;
bClose = false;
Page(0);
this._visible = false;
_root.Menu_mc.ShowMenu();
} else if (bUp) {
this.UpBlack_mc._visible = true;
this.UpRed_mc._visible = false;
bUp = false;
Page(iPageNum - 1);
} else if (bDown) {
this.DownBlack_mc._visible = true;
this.DownRed_mc._visible = false;
bDown = false;
Page(iPageNum + 1);
}
}
function Page(iNum) {
var _local3 = 0;
while (_local3 < aPages[iPageNum].length) {
aPages[iPageNum][_local3]._visible = false;
_local3++;
}
iPageNum = iNum;
var _local2 = 0;
while (_local2 < aPages[iPageNum].length) {
aPages[iPageNum][_local2]._visible = true;
_local2++;
}
this.UpBlack_mc._visible = true;
this.DownBlack_mc._visible = true;
if (iPageNum == 0) {
this.UpBlack_mc._visible = false;
} else if (iPageNum == (aPages.length - 1)) {
this.DownBlack_mc._visible = false;
}
}
var bClose = false;
var bUp = false;
var bDown = false;
this.attachMovie("s_CloseBlack", "CloseBlack_mc", 1);
this.CloseBlack_mc._x = 570;
this.CloseBlack_mc._y = 0;
this.attachMovie("s_CloseRed", "CloseRed_mc", 2);
this.CloseRed_mc._x = 570;
this.CloseRed_mc._y = 0;
this.CloseRed_mc._visible = false;
this.attachMovie("s_UpBlack", "UpBlack_mc", 3);
this.UpBlack_mc._x = 570;
this.UpBlack_mc._y = 30;
this.UpBlack_mc._visible = false;
this.attachMovie("s_UpRed", "UpRed_mc", 4);
this.UpRed_mc._x = 570;
this.UpRed_mc._y = 30;
this.UpRed_mc._visible = false;
this.attachMovie("s_DownBlack", "DownBlack_mc", 5);
this.DownBlack_mc._x = 570;
this.DownBlack_mc._y = 370;
this.attachMovie("s_DownRed", "DownRed_mc", 6);
this.DownRed_mc._x = 570;
this.DownRed_mc._y = 370;
this.DownRed_mc._visible = false;
var aPages = new Array(11);
var p = 0;
while (p < aPages.length) {
aPages[p] = new Array();
p++;
}
var iPageNum = 0;
var oHeaderText = new TextFormat();
oHeaderText.size = 24;
var oText = new TextFormat();
oText.size = 20;
var oNote = new TextFormat();
oNote.size = 15;
this.createTextField("Objective", 10, 20, 10, 1, 1);
this.Objective.textColor = 16711680 /* 0xFF0000 */;
this.Objective.autoSize = "left";
this.Objective.type = "dynamic";
this.Objective.selectable = false;
this.Objective.text = "Objective:";
this.Objective.setTextFormat(oHeaderText);
aPages[0].push(this.Objective);
this.createTextField("ObjectiveText", 11, 20, 45, 530, 100);
this.ObjectiveText.textColor = 16777215 /* 0xFFFFFF */;
this.ObjectiveText.type = "dynamic";
this.ObjectiveText.selectable = false;
this.ObjectiveText.wordWrap = true;
this.ObjectiveText.text = "The objective of Deulsums is to beat your opponent in reaching the winning score by placing or modifing numbers on a board in an attempt to reach a target sum.";
this.ObjectiveText.setTextFormat(oText);
aPages[0].push(this.ObjectiveText);
this.createTextField("Controls", 12, 20, 150, 1, 1);
this.Controls.textColor = 16711680 /* 0xFF0000 */;
this.Controls.autoSize = "left";
this.Controls.type = "dynamic";
this.Controls.selectable = false;
this.Controls.text = "Controls:";
this.Controls.setTextFormat(oHeaderText);
aPages[0].push(this.Controls);
this.createTextField("ControlsText", 13, 20, 185, 530, 200);
this.ControlsText.textColor = 16777215 /* 0xFFFFFF */;
this.ControlsText.type = "dynamic";
this.ControlsText.selectable = false;
this.ControlsText.wordWrap = true;
this.ControlsText.text = "Duelsums is played using the mouse. Press 'Q' to exit the current game and return to the menu.\n\nPress \u2018I\u2019 to toggle extra information on or off. The extra information includes the current sum of each grid (see Scoring) and the current carry value if any (see Modify Phase).\n\nPress 'M' to mute the sound.";
this.ControlsText.setTextFormat(oText);
aPages[0].push(this.ControlsText);
this.createTextField("Options", 14, 20, 10, 1, 1);
this.Options.textColor = 16711680 /* 0xFF0000 */;
this.Options.autoSize = "left";
this.Options.type = "dynamic";
this.Options.selectable = false;
this.Options.text = "Options:";
this.Options.setTextFormat(oHeaderText);
this.Options._visible = false;
aPages[1].push(this.Options);
this.createTextField("OptionsText", 15, 20, 45, 530, 350);
this.OptionsText.textColor = 16777215 /* 0xFFFFFF */;
this.OptionsText.type = "dynamic";
this.OptionsText.selectable = false;
this.OptionsText.wordWrap = true;
this.OptionsText.text = "When starting a game you will be able to select several options which affect the game.\n\n\nOpponent - selects who will control the blue player\n\t\t\t (computer AI ranging from Easy to Very Hard,\n\t\t\t or a human controlled opponent).\n\nBoard Size - sets the dimensions of the board in tiles.\n\nTarget Sum - sets the target sums for both players.\n\nWinning Score - sets the score that is required to win the game.";
this.OptionsText.setTextFormat(oText);
this.OptionsText._visible = false;
aPages[1].push(this.OptionsText);
this.createTextField("Board", 16, 20, 10, 1, 1);
this.Board.textColor = 16711680 /* 0xFF0000 */;
this.Board.autoSize = "left";
this.Board.type = "dynamic";
this.Board.selectable = false;
this.Board.text = "The Board:";
this.Board.setTextFormat(oHeaderText);
this.Board._visible = false;
aPages[2].push(this.Board);
this.createTextField("BoardText", 17, 20, 45, 530, 100);
this.BoardText.textColor = 16777215 /* 0xFFFFFF */;
this.BoardText.type = "dynamic";
this.BoardText.selectable = false;
this.BoardText.wordWrap = true;
this.BoardText.text = "The board is a square grid of tiles located in the center of the play area. Initially the board tiles have no values assigned.";
this.BoardText.setTextFormat(oText);
this.BoardText._visible = false;
aPages[2].push(this.BoardText);
this.attachMovie("s_Instructions_Board", "Inst_Board_mc", 100);
this.Inst_Board_mc._x = 115;
this.Inst_Board_mc._y = 90;
this.Inst_Board_mc._visible = false;
aPages[2].push(this.Inst_Board_mc);
this.createTextField("BoardNote", 200, 30, 360, 540, 55);
this.BoardNote.textColor = 16777215 /* 0xFFFFFF */;
this.BoardNote.type = "dynamic";
this.BoardNote.selectable = false;
this.BoardNote.wordWrap = true;
this.BoardNote.text = "The 3x3 board on the left has info turned off, the 5x5 board on the right has the info turned on so the current sum of each 2x2 grid is shown";
this.BoardNote.setTextFormat(oNote);
this.BoardNote._visible = false;
aPages[2].push(this.BoardNote);
this.createTextField("Players", 18, 20, 10, 1, 1);
this.Players.textColor = 16711680 /* 0xFF0000 */;
this.Players.autoSize = "left";
this.Players.type = "dynamic";
this.Players.selectable = false;
this.Players.text = "The Players:";
this.Players.setTextFormat(oHeaderText);
this.Players._visible = false;
aPages[3].push(this.Players);
this.createTextField("PlayersText", 19, 20, 40, 530, 200);
this.PlayersText.textColor = 16777215 /* 0xFFFFFF */;
this.PlayersText.type = "dynamic";
this.PlayersText.selectable = false;
this.PlayersText.wordWrap = true;
this.PlayersText.text = "Duelsusm is played with two players -- Red against Blue. Each player area displays the player\u2019s target sum as well as the four player tiles. The tiles have random values from 0 to 9. The values on the tiles can be selected during that players turn by clicking on the desired tile. Once a value is used the tile will be empty until it is replaced by a random value at the start of the player\u2019s next turn.";
this.PlayersText.setTextFormat(oText);
this.PlayersText._visible = false;
aPages[3].push(this.PlayersText);
this.attachMovie("s_Instructions_Players", "Inst_Players_mc", 101);
this.Inst_Players_mc._x = 112;
this.Inst_Players_mc._y = 198;
this.Inst_Players_mc._visible = false;
aPages[3].push(this.Inst_Players_mc);
this.createTextField("Placement", 20, 20, 10, 1, 1);
this.Placement.textColor = 16711680 /* 0xFF0000 */;
this.Placement.autoSize = "left";
this.Placement.type = "dynamic";
this.Placement.selectable = false;
this.Placement.text = "Placement phase:";
this.Placement.setTextFormat(oHeaderText);
this.Placement._visible = false;
aPages[4].push(this.Placement);
this.createTextField("PlacementText", 21, 20, 45, 530, 100);
this.PlacementText.textColor = 16777215 /* 0xFFFFFF */;
this.PlacementText.type = "dynamic";
this.PlacementText.selectable = false;
this.PlacementText.wordWrap = true;
this.PlacementText.text = "At the start of the game the board is empty. Each player takes turns placing values on the empty board tiles until every tile has a value.";
this.PlacementText.setTextFormat(oText);
this.PlacementText._visible = false;
aPages[4].push(this.PlacementText);
this.attachMovie("s_Instructions_Placement_A", "Inst_PlaceA_mc", 102);
this.Inst_PlaceA_mc._x = 115;
this.Inst_PlaceA_mc._y = 125;
this.Inst_PlaceA_mc._visible = false;
aPages[4].push(this.Inst_PlaceA_mc);
this.createTextField("PlacementNoteA", 201, 120, 330, 350, 55);
this.PlacementNoteA.textColor = 16777215 /* 0xFFFFFF */;
this.PlacementNoteA.type = "dynamic";
this.PlacementNoteA.selectable = false;
this.PlacementNoteA.wordWrap = true;
this.PlacementNoteA.text = "The value of 2 is selected by the Red player to be placed on the selected board tile.";
this.PlacementNoteA.setTextFormat(oNote);
this.PlacementNoteA._visible = false;
aPages[4].push(this.PlacementNoteA);
this.attachMovie("s_Instructions_Placement_B", "Inst_PlaceB_mc", 103);
this.Inst_PlaceB_mc._x = 115;
this.Inst_PlaceB_mc._y = 125;
this.Inst_PlaceB_mc._visible = false;
aPages[5].push(this.Inst_PlaceB_mc);
this.createTextField("PlacementNoteB", 202, 120, 330, 350, 65);
this.PlacementNoteB.textColor = 16777215 /* 0xFFFFFF */;
this.PlacementNoteB.type = "dynamic";
this.PlacementNoteB.selectable = false;
this.PlacementNoteB.wordWrap = true;
this.PlacementNoteB.text = "The value of 2 has been placed on the board and is removed from the Red player tile. The updated sums of each 2x2 grid are show when info is turned on.";
this.PlacementNoteB.setTextFormat(oNote);
this.PlacementNoteB._visible = false;
aPages[5].push(this.PlacementNoteB);
this.createTextField("Modify", 22, 20, 10, 1, 1);
this.Modify.textColor = 16711680 /* 0xFF0000 */;
this.Modify.autoSize = "left";
this.Modify.type = "dynamic";
this.Modify.selectable = false;
this.Modify.text = "Modify Phase:";
this.Modify.setTextFormat(oHeaderText);
this.Modify._visible = false;
aPages[6].push(this.Modify);
this.createTextField("ModifyText", 23, 20, 45, 530, 350);
this.ModifyText.textColor = 16777215 /* 0xFFFFFF */;
this.ModifyText.type = "dynamic";
this.ModifyText.selectable = false;
this.ModifyText.wordWrap = true;
this.ModifyText.text = "Once the board is full the modify phase begins. Three operation buttons -- Plus (+), Minus (-) and Multiply (x) -- will appear in each player area. The active operator -- selected by clicking on the appropriate button -- is used in conjunction with the chosen value to modify the selected board tile.\n\nIf the resulting value is not within the range 0-9 then an adjacent tile will be chosen to act as a tens column of a two-digit number. For values greater than 9 a carry will be added to the tens column. For values less than 0 a carry will be subtracted from the tens column. The tiles eligible to receive the carry will be shown in green. The value of the carry will be shown if info is turned on.\n\nSee the following pages for examples.";
this.ModifyText.setTextFormat(oText);
this.ModifyText._visible = false;
aPages[6].push(this.ModifyText);
this.createTextField("ExamplesText", 25, 20, 10, 530, 350);
this.ExamplesText.textColor = 16777215 /* 0xFFFFFF */;
this.ExamplesText.type = "dynamic";
this.ExamplesText.selectable = false;
this.ExamplesText.wordWrap = true;
this.ExamplesText.text = "Examples:\n6 + 7 = 13. So the 1 from the tens column will be added to a selected green tile and the 3 from the ones column will become the new tile value. (i.e. a carry of 1 is applied to an adjacent tile)\n\n3 - 7 = -4. So a 1 will be subtracted from a selected green tile and carried into the tens column of the original value of 3 making 13. Resulting in 13 - 7 = 6. (i.e. a carry of 1 is subtracted from an adjacent tile, or in other words the carry value is -1)\n\n6 x 7 = 42. So the 4 from the tens column will be added to a selected green tile and the 2 from the ones column will become the new tile value. (i.e. a carry of 4 is applied to an adjacent tile)";
this.ExamplesText.setTextFormat(oText);
this.ExamplesText._visible = false;
aPages[7].push(this.ExamplesText);
this.attachMovie("s_Instructions_Modify_A", "Inst_ModA_mc", 104);
this.Inst_ModA_mc._x = 115;
this.Inst_ModA_mc._y = 125;
this.Inst_ModA_mc._visible = false;
aPages[8].push(this.Inst_ModA_mc);
this.createTextField("ModifyNoteA", 203, 120, 330, 350, 55);
this.ModifyNoteA.textColor = 16777215 /* 0xFFFFFF */;
this.ModifyNoteA.type = "dynamic";
this.ModifyNoteA.selectable = false;
this.ModifyNoteA.wordWrap = true;
this.ModifyNoteA.text = "The Red player has selected the value 6 and the operator '+' to be applied to the board tile with value 7";
this.ModifyNoteA.setTextFormat(oNote);
this.ModifyNoteA._visible = false;
aPages[8].push(this.ModifyNoteA);
this.attachMovie("s_Instructions_Modify_B", "Inst_ModB_mc", 105);
this.Inst_ModB_mc._x = 60;
this.Inst_ModB_mc._y = 30;
this.Inst_ModB_mc._visible = false;
aPages[9].push(this.Inst_ModB_mc);
this.createTextField("ModifyNoteB", 204, 60, 250, 220, 120);
this.ModifyNoteB.textColor = 16777215 /* 0xFFFFFF */;
this.ModifyNoteB.type = "dynamic";
this.ModifyNoteB.selectable = false;
this.ModifyNoteB.wordWrap = true;
this.ModifyNoteB.text = "6 + 7 = 13 so the result is a board tile value of 3 with a carry of 1 to be applied to an adjacent tile";
this.ModifyNoteB.setTextFormat(oNote);
this.ModifyNoteB._visible = false;
aPages[9].push(this.ModifyNoteB);
this.attachMovie("s_Instructions_Modify_C", "Inst_ModC_mc", 106);
this.Inst_ModC_mc._x = 320;
this.Inst_ModC_mc._y = 30;
this.Inst_ModC_mc._visible = false;
aPages[9].push(this.Inst_ModC_mc);
this.createTextField("ModifyNoteC", 205, 320, 250, 220, 120);
this.ModifyNoteC.textColor = 16777215 /* 0xFFFFFF */;
this.ModifyNoteC.type = "dynamic";
this.ModifyNoteC.selectable = false;
this.ModifyNoteC.wordWrap = true;
this.ModifyNoteC.text = "The carry of 1 is added to a board tile with value 4 resulting in a value of 5";
this.ModifyNoteC.setTextFormat(oNote);
this.ModifyNoteC._visible = false;
aPages[9].push(this.ModifyNoteC);
this.createTextField("Scoring", 26, 20, 10, 1, 1);
this.Scoring.textColor = 16711680 /* 0xFF0000 */;
this.Scoring.autoSize = "left";
this.Scoring.type = "dynamic";
this.Scoring.selectable = false;
this.Scoring.text = "Scoring:";
this.Scoring.setTextFormat(oHeaderText);
this.Scoring._visible = false;
aPages[10].push(this.Scoring);
this.createTextField("ScoringText", 27, 20, 45, 530, 100);
this.ScoringText.textColor = 16777215 /* 0xFFFFFF */;
this.ScoringText.type = "dynamic";
this.ScoringText.selectable = false;
this.ScoringText.wordWrap = true;
this.ScoringText.text = "After each move in the modify phase both players will score a point for any 2 x 2 grid of board tiles whose values sum up to the player\u2019s target sum.";
this.ScoringText.setTextFormat(oText);
this.ScoringText._visible = false;
aPages[10].push(this.ScoringText);
this.attachMovie("s_Instructions_Score", "Inst_Score_mc", 107);
this.Inst_Score_mc._x = 115;
this.Inst_Score_mc._y = 150;
this.Inst_Score_mc._visible = false;
aPages[10].push(this.Inst_Score_mc);
}
Instance of Symbol 226 MovieClip "Music_mc" in Frame 7
onClipEvent (load) {
SoundControl.StopAll();
}
onClipEvent (enterFrame) {
_root.ButtonSound_mc.stop();
_root.BoardTileSound_mc.stop();
_root.PlayerTileSound_mc.stop();
_root.WinSound_mc.stop();
_root.ScoreSound_mc.stop();
_root.Music_mc.stop();
_root.gotoAndPlay(3);
}
Symbol 234 MovieClip [__Packages.SoundControl] Frame 0
class SoundControl
{
static var m_oSnd;
function SoundControl () {
}
static function Init() {
m_oSnd = new SoundControl();
m_oSnd.m_wButton = new Sound(_root.Menu_mc);
m_oSnd.m_wButton.attachSound("w_ButtonClick");
m_oSnd.m_wButton.setVolume(50);
m_oSnd.m_wPlayerTile = new Sound(_root.RedSide_mc);
m_oSnd.m_wPlayerTile.attachSound("w_PlayerTileClick");
m_oSnd.m_wPlayerTile.setVolume(90);
m_oSnd.m_wBoardTile = new Sound(_root.Board_mc);
m_oSnd.m_wBoardTile.attachSound("w_BoardTileClick");
m_oSnd.m_wBoardTile.setVolume(50);
m_oSnd.m_wScore = new Sound(_root.Scoreboard_mc);
m_oSnd.m_wScore.attachSound("w_Score");
m_oSnd.m_wScore.setVolume(16);
m_oSnd.m_wWin = new Sound(_root.Options_mc);
m_oSnd.m_wWin.attachSound("w_Win");
m_oSnd.m_wWin.setVolume(50);
m_oSnd.m_wMusic = new Sound(_root.Instructions_mc);
m_oSnd.m_wMusic.attachSound("w_Music");
m_oSnd.m_wMusic.setVolume(16);
m_oSnd.m_wMusic.onSoundComplete = PlayMusic;
}
static function ButtonClick() {
m_oSnd.m_wButton.start();
}
static function PlayerTileClick() {
m_oSnd.m_wPlayerTile.start();
}
static function BoardTileClick() {
m_oSnd.m_wBoardTile.start();
}
static function Score() {
m_oSnd.m_wScore.start();
}
static function PlayWin() {
m_oSnd.m_wWin.start();
}
static function PlayMusic() {
m_oSnd.m_wMusic.start(0, 256);
}
static function StopMusic() {
m_oSnd.m_wMusic.stop();
}
static function StopAll() {
var _local1 = new Sound();
_local1.stop();
}
static function Mute() {
var _local1 = new Sound();
_local1.setVolume(0);
}
static function UnMute() {
var _local1 = new Sound();
_local1.setVolume(100);
}
static function ToggleMute() {
var _local1 = new Sound();
if (_local1.getVolume() == 100) {
_local1.setVolume(0);
} else {
_local1.setVolume(100);
}
}
}
Symbol 235 MovieClip [__Packages.GameControl] Frame 0
class GameControl
{
var m_bRunning, m_oBoard, m_oRed, m_oBlue, m_oAI, m_bScoringRed, m_bScoringBlue, m_bRedWon, m_bBlueWon, m_aAIMoves, m_iAIMove, m_bHumanBlue, m_iRedTarget, m_iGoal, m_iRefresh, m_bRedTurn, m_iScoreRed, m_iScoreBlue, m_bPlacement;
function GameControl () {
m_bRunning = false;
}
function Init() {
m_oBoard = new Board();
m_oRed = new Player();
m_oBlue = new Player();
m_oAI = new AI();
m_oBoard.Init();
var _local4 = new Array("s_PlusRed", "s_MinusRed", "s_MultiplyRed");
var _local5 = new Array("s_PlusBlue", "s_MinusBlue", "s_MultiplyBlue");
var _local3 = new Array("s_PlusBlack", "s_MinusBlack", "s_MultiplyBlack");
_root.PlusRed_mc._visible = false;
_root.MinusRed_mc._visible = false;
_root.MultiplyRed_mc._visible = false;
_root.PlusBlue_mc._visible = false;
_root.MinusBlue_mc._visible = false;
_root.MultiplyBlue_mc._visible = false;
_root.PlusBlack_mc._visible = false;
_root.MinusBlack_mc._visible = false;
_root.MultiplyBlack_mc._visible = false;
m_oRed.Init(_root.RedSide_mc, 14614528, _local4, _local3);
m_oBlue.Init(_root.BlueSide_mc, 223, _local5, _local3);
}
function IsRunning() {
return(m_bRunning);
}
function ToggleInfo() {
m_oBoard.ToggleInfo();
}
function Play(bHuman, iAI, iBoardDim, iTargetSum, iScore) {
m_bRunning = true;
m_bScoringRed = false;
m_bScoringBlue = false;
m_bRedWon = false;
m_bBlueWon = false;
_root.RedWins_mc._visible = false;
_root.BlueWins_mc._visible = false;
m_aAIMoves = new Array();
m_iAIMove = 0;
if (bHuman) {
m_bHumanBlue = true;
} else {
m_oAI.SetLevel(iAI);
m_bHumanBlue = false;
}
m_oRed.SetHuman(true);
m_oBlue.SetHuman(m_bHumanBlue);
m_iRedTarget = iTargetSum;
m_iGoal = iScore;
m_iRefresh = 0;
SoundControl.PlayMusic();
StartRound(iBoardDim);
}
function End() {
m_bRunning = false;
m_oBoard.End();
_root.RedSide_mc._visible = false;
_root.BlueSide_mc._visible = false;
_root.Board_mc._visible = false;
SoundControl.StopMusic();
_root.Menu_mc._visible = true;
}
function Click(mx, my) {
if (m_bRedWon || (m_bBlueWon)) {
End();
return(undefined);
}
if (m_bScoringRed || (m_bScoringBlue)) {
return(undefined);
}
if (m_oBoard.HasCarry()) {
m_oBoard.Carry(mx, my);
if (!CheckCarry()) {
if (m_bRedTurn) {
m_oRed.ReplaceValue();
} else {
m_oBlue.ReplaceValue();
}
}
return(undefined);
}
if (m_bRedTurn) {
if (_root.RedSide_mc.hitTest(mx, my, false)) {
m_oRed.Click(mx, my);
} else {
ClickBoard(mx, my, m_oRed, m_oBlue);
}
} else if (m_bHumanBlue) {
if (_root.BlueSide_mc.hitTest(mx, my, false)) {
m_oBlue.Click(mx, my);
} else {
ClickBoard(mx, my, m_oBlue, m_oRed);
}
}
}
function Refresh() {
m_iRefresh++;
if (m_iRefresh < 4) {
return(undefined);
}
if (m_bScoringRed) {
if (m_oBoard.Sum(m_oRed.GetTarget(), m_oRed.GetColour())) {
m_iScoreRed = m_iScoreRed + 1;
_root.Scoreboard_mc.SetScoreRed(m_iScoreRed);
m_iRefresh = 0;
} else {
m_bScoringRed = false;
m_bScoringBlue = true;
m_iRefresh = 2;
}
} else if (m_bScoringBlue) {
if (m_oBoard.Sum(m_oBlue.GetTarget(), m_oBlue.GetColour())) {
m_iScoreBlue = m_iScoreBlue + 1;
_root.Scoreboard_mc.SetScoreBlue(m_iScoreBlue);
m_iRefresh = 0;
} else {
m_bScoringBlue = false;
m_iRefresh = 0;
CheckGoal();
}
}
if (m_iRefresh < 5) {
return(undefined);
}
if ((((!m_bRedWon) && (!m_bBlueWon)) && (!m_bRedTurn)) && (!m_bHumanBlue)) {
if (m_iAIMove == 0) {
if (m_bPlacement) {
m_aAIMoves.push(m_oAI.GetPlacement(m_oBlue.GetValues(), m_oRed.GetValues(), m_oBoard.GetData()));
} else {
m_aAIMoves = m_oAI.GetMove(m_oBlue.GetValues(), m_oRed.GetValues(), m_oBoard.GetData());
}
var _local4 = m_aAIMoves[0];
m_oBlue.Select(_local4.value, _local4.operator);
m_iAIMove = 1;
} else {
if (m_iAIMove == 1) {
m_oBlue.RemoveValue();
m_iAIMove = 2;
}
var _local3 = m_aAIMoves.shift();
if (m_bPlacement) {
m_oBoard.SetValue(_local3.row, _local3.col, _local3.value, m_oBlue.GetColour());
m_oRed.ReplaceValue();
m_iAIMove = 0;
m_bRedTurn = true;
if (m_oBoard.IsFull()) {
m_bPlacement = false;
m_oRed.EndPlacement();
m_oBlue.EndPlacement();
}
} else {
m_oBoard.AdjustValue(_local3.row, _local3.col, _local3.value, _local3.operator, m_oBlue.GetColour());
if (!CheckCarry()) {
m_oRed.ReplaceValue();
m_iAIMove = 0;
}
}
}
m_iRefresh = 0;
}
if (m_iRefresh < 240) {
return(undefined);
}
if (m_bRedWon || (m_bBlueWon)) {
End();
return(undefined);
}
}
function StartRound(iDimension) {
m_bPlacement = true;
m_bRedTurn = true;
m_iScoreRed = 0;
m_iScoreBlue = 0;
var _local3 = 36 - m_iRedTarget;
m_oRed.StartRound(m_iRedTarget);
m_oBlue.StartRound(_local3);
m_oBoard.SetBoard(iDimension);
m_oBoard.SetTargets(m_iRedTarget, _local3, m_oRed.GetColour(), m_oBlue.GetColour());
if (!m_bHumanBlue) {
m_oAI.SetTargets(_local3, m_iRedTarget);
}
_root.Scoreboard_mc.SetScoreRed(m_iScoreRed);
_root.Scoreboard_mc.SetScoreBlue(m_iScoreBlue);
}
function ClickBoard(mx, my, oPlayer, oOpponent) {
var _local3 = oPlayer.GetValue();
if (_local3 >= 0) {
var _local5 = oPlayer.GetOperator();
if (m_oBoard.Click(mx, my, m_bPlacement, _local3, _local5, oPlayer.GetColour())) {
oPlayer.RemoveValue();
if (m_bPlacement) {
if (m_oBoard.IsFull()) {
m_bPlacement = false;
oPlayer.EndPlacement();
oOpponent.EndPlacement();
}
m_iRefresh = 0;
m_bRedTurn = !m_bRedTurn;
oOpponent.ReplaceValue();
} else if (!CheckCarry()) {
m_iRefresh = 0;
oOpponent.ReplaceValue();
}
}
}
}
function CheckCarry() {
if (m_oBoard.HasCarry()) {
return(true);
}
m_bScoringRed = true;
m_bRedTurn = !m_bRedTurn;
return(false);
}
function CheckGoal() {
if (((m_iScoreRed >= m_iGoal) || (m_iScoreBlue >= m_iGoal)) && (m_iScoreRed != m_iScoreBlue)) {
if (m_iScoreRed > m_iScoreBlue) {
_root.RedWins_mc._visible = true;
m_bRedWon = true;
SoundControl.StopMusic();
SoundControl.PlayWin();
} else {
_root.BlueWins_mc._visible = true;
m_bBlueWon = true;
SoundControl.StopMusic();
SoundControl.PlayWin();
}
_root.RedSide_mc._visible = false;
_root.BlueSide_mc._visible = false;
_root.Board_mc._visible = false;
m_iRefresh = 0;
}
}
}
Symbol 236 MovieClip [__Packages.Board] Frame 0
class Board
{
var m_aTiles, m_oSumTextFormat, m_aSumText, m_oCarryText, m_aColoured, m_aTargets, m_aPlayerColours, m_bInfo, m_oData, m_iSize, m_iX, m_iY, m_iGridRow, m_iGridCol, m_iCarryColour;
function Board () {
}
function Init() {
Tile.oTileFormat = new TextFormat();
Tile.oTileFormat.size = 56;
Tile.oTileFormat.bold = true;
_root.Tile_mc._visible = false;
m_aTiles = new Array(c_iMaxTiles);
m_oSumTextFormat = new TextFormat();
m_oSumTextFormat.size = 14;
m_oSumTextFormat.bold = true;
m_aSumText = new Array(c_iMaxTiles - 1);
var _local4 = 0;
while (_local4 < c_iMaxTiles) {
m_aTiles[_local4] = new Array(c_iMaxTiles);
if (_local4 < (c_iMaxTiles - 1)) {
m_aSumText[_local4] = new Array(c_iMaxTiles - 1);
}
var _local3 = 0;
while (_local3 < c_iMaxTiles) {
m_aTiles[_local4][_local3] = new Tile(_root.Board_mc);
m_aTiles[_local4][_local3].Hide();
if ((_local4 < (c_iMaxTiles - 1)) && (_local3 < (c_iMaxTiles - 1))) {
_root.Board_mc.createTextField((("Sum_" + _local4) + "_") + _local3, (300 + (_local4 * c_iMaxTiles)) + _local3, 0, 0, 1, 1);
m_aSumText[_local4][_local3] = _root.Board_mc[(("Sum_" + _local4) + "_") + _local3];
m_aSumText[_local4][_local3].type = "dynamic";
m_aSumText[_local4][_local3].selectable = false;
m_aSumText[_local4][_local3].background = true;
m_aSumText[_local4][_local3].backgroundColor = 16777215 /* 0xFFFFFF */;
}
_local3++;
}
_local4++;
}
_root.Board_mc.createTextField("CarryText", 400, _root.Board_mc._width / 2, _root.Board_mc._height - 30, 1, 1);
m_oCarryText = _root.Board_mc.CarryText;
m_oCarryText.type = "dynamic";
m_oCarryText.selectable = false;
m_oCarryText._visible = false;
m_aColoured = new Array();
m_aTargets = new Array(2);
m_aPlayerColours = new Array(2);
m_bInfo = true;
}
function SetBoard(iTiles) {
m_oData = new BoardData(iTiles);
m_iSize = (iTiles * (Tile.c_iSize + c_iBuffer)) - c_iBuffer;
m_iX = (_root.Board_mc._width / 2) - (m_iSize / 2);
m_iY = (_root.Board_mc._height / 2) - (m_iSize / 2);
var _local4 = 0;
while (_local4 < c_iMaxTiles) {
var _local3 = 0;
while (_local3 < c_iMaxTiles) {
if ((_local4 < iTiles) && (_local3 < iTiles)) {
m_aTiles[_local4][_local3].Reset(m_iX + (_local3 * (Tile.c_iSize + c_iBuffer)), m_iY + (_local4 * (Tile.c_iSize + c_iBuffer)));
m_aTiles[_local4][_local3].Show();
if ((_local4 < (iTiles - 1)) && (_local3 < (iTiles - 1))) {
m_aSumText[_local4][_local3]._x = ((m_iX + (_local3 * (Tile.c_iSize + c_iBuffer))) + Tile.c_iSize) + 2;
m_aSumText[_local4][_local3]._y = ((m_iY + (_local4 * (Tile.c_iSize + c_iBuffer))) + Tile.c_iSize) + 1;
m_aSumText[_local4][_local3].text = "00";
m_aSumText[_local4][_local3].setTextFormat(m_oSumTextFormat);
m_aSumText[_local4][_local3].textColor = 0;
m_aSumText[_local4][_local3].autoSize = "left";
if (m_bInfo) {
m_aSumText[_local4][_local3]._visible = true;
} else {
m_aSumText[_local4][_local3]._visible = false;
}
} else {
m_aSumText[_local4][_local3]._visible = false;
}
} else {
m_aTiles[_local4][_local3].Hide();
if ((_local4 < (c_iMaxTiles - 1)) && (_local3 < (c_iMaxTiles - 1))) {
m_aSumText[_local4][_local3]._visible = false;
}
}
_local3++;
}
_local4++;
}
m_iGridRow = 0;
m_iGridCol = 0;
_root.Board_mc._visible = true;
}
function End() {
Uncolour();
m_oCarryText.text = "";
m_oCarryText._visible = false;
}
function SetTargets(iTarget0, iTarget1, iColour0, iColour1) {
m_aTargets[0] = iTarget0;
m_aTargets[1] = iTarget1;
m_aPlayerColours[0] = iColour0;
m_aPlayerColours[1] = iColour1;
}
function GetData() {
return(m_oData);
}
function ToggleInfo() {
m_bInfo = !m_bInfo;
ShowSums();
if (m_oCarryText.text != "") {
m_oCarryText._visible = m_bInfo;
}
}
function Click(mx, my, bPlacement, iValue, iOperator, iColour) {
var _local3 = 0;
while (_local3 < m_oData.GetDim()) {
var _local2 = 0;
while (_local2 < m_oData.GetDim()) {
if (m_aTiles[_local3][_local2].Click(mx, my)) {
if (bPlacement) {
if (!m_aTiles[_local3][_local2].IsSet()) {
SetValue(_local3, _local2, iValue, iColour);
return(true);
}
} else {
AdjustValue(_local3, _local2, iValue, iOperator, iColour);
return(true);
}
}
_local2++;
}
_local3++;
}
return(false);
}
function Carry(mx, my) {
var _local3 = 0;
while (_local3 < m_oData.GetDim()) {
var _local2 = 0;
while (_local2 < m_oData.GetDim()) {
if (m_aTiles[_local3][_local2].GetColour() == c_iCarryColour) {
if (m_aTiles[_local3][_local2].Click(mx, my)) {
AdjustValue(_local3, _local2, m_oData.CarryValue(), m_oData.CarryOperator(), m_iCarryColour);
}
}
_local2++;
}
_local3++;
}
return(false);
}
function HasCarry() {
return(m_oData.HasCarry());
}
function IsFull() {
return(m_oData.IsFull());
}
function Sum(iTarget, iColour) {
Uncolour();
while (m_iGridRow < (m_oData.GetDim() - 1)) {
if (m_iGridCol == (m_oData.GetDim() - 1)) {
m_iGridRow = m_iGridRow + 1;
m_iGridCol = 0;
}
var _local3 = m_oData.GetSum(m_iGridRow, m_iGridCol);
if (_local3 == iTarget) {
m_aTiles[m_iGridRow][m_iGridCol].SetColour(iColour);
m_aTiles[m_iGridRow][m_iGridCol + 1].SetColour(iColour);
m_aTiles[m_iGridRow + 1][m_iGridCol].SetColour(iColour);
m_aTiles[m_iGridRow + 1][m_iGridCol + 1].SetColour(iColour);
m_aColoured.push(m_aTiles[m_iGridRow][m_iGridCol]);
m_aColoured.push(m_aTiles[m_iGridRow][m_iGridCol + 1]);
m_aColoured.push(m_aTiles[m_iGridRow + 1][m_iGridCol]);
m_aColoured.push(m_aTiles[m_iGridRow + 1][m_iGridCol + 1]);
SoundControl.Score();
m_iGridCol = m_iGridCol + 1;
return(true);
}
m_iGridCol = m_iGridCol + 1;
}
m_iGridRow = 0;
m_iGridCol = 0;
return(false);
}
function SetValue(row, col, iValue, iColour) {
Uncolour();
m_aTiles[row][col].SetValue(iValue);
m_oData.Set(row, col, iValue);
SoundControl.BoardTileClick();
m_aTiles[row][col].SetColour(iColour);
m_aColoured.push(m_aTiles[row][col]);
UpdateSums(row, col);
}
function AdjustValue(row, col, iValue, iOperator, iColour) {
Uncolour();
m_aTiles[row][col].SetValue(m_oData.Adjust(row, col, iValue, iOperator));
SoundControl.BoardTileClick();
m_aTiles[row][col].SetColour(iColour);
m_aColoured.push(m_aTiles[row][col]);
m_oCarryText.text = "";
m_oCarryText._visible = false;
if (m_oData.HasCarry()) {
m_iCarryColour = iColour;
var _local3 = m_oData.GetCarryList();
var _local2 = 0;
while (_local2 < _local3.length) {
m_aTiles[_local3[_local2].row][_local3[_local2].col].SetColour(c_iCarryColour);
m_aColoured.push(m_aTiles[_local3[_local2].row][_local3[_local2].col]);
_local2++;
}
m_oCarryText.text = "" + m_oData.CarryValue();
m_oCarryText.setTextFormat(m_oSumTextFormat);
m_oCarryText.textColor = 57088;
m_oCarryText.autoSize = "left";
if (m_bInfo) {
m_oCarryText._visible = true;
}
}
UpdateSums(row, col);
}
function ShowSums() {
var _local6 = c_iMaxTiles - 1;
var _local5 = m_oData.GetDim() - 1;
var _local3 = 0;
while (_local3 < _local6) {
var _local2 = 0;
while (_local2 < _local6) {
if ((m_bInfo && (_local3 < _local5)) && (_local2 < _local5)) {
var _local4 = m_oData.GetSum(_local3, _local2);
if (_local4 < 10) {
m_aSumText[_local3][_local2].text = "0" + _local4;
} else {
m_aSumText[_local3][_local2].text = "" + _local4;
}
m_aSumText[_local3][_local2].setTextFormat(m_oSumTextFormat);
if (_local4 == m_aTargets[0]) {
m_aSumText[_local3][_local2].textColor = m_aPlayerColours[0];
} else if (_local4 == m_aTargets[1]) {
m_aSumText[_local3][_local2].textColor = m_aPlayerColours[1];
} else {
m_aSumText[_local3][_local2].textColor = 0;
}
m_aSumText[_local3][_local2].autoSize = "left";
m_aSumText[_local3][_local2]._visible = true;
} else {
m_aSumText[_local3][_local2]._visible = false;
}
_local2++;
}
_local3++;
}
}
function UpdateSums(row, col) {
if (!m_bInfo) {
return(undefined);
}
var _local5 = m_oData.GetSumsAffected(row, col);
var _local3 = _local5[0];
while (_local3 <= _local5[1]) {
var _local2 = _local5[2];
while (_local2 <= _local5[3]) {
var _local4 = m_oData.GetSum(_local3, _local2);
if (_local4 < 10) {
m_aSumText[_local3][_local2].text = "0" + _local4;
} else {
m_aSumText[_local3][_local2].text = "" + _local4;
}
m_aSumText[_local3][_local2].setTextFormat(m_oSumTextFormat);
if (_local4 == m_aTargets[0]) {
m_aSumText[_local3][_local2].textColor = m_aPlayerColours[0];
} else if (_local4 == m_aTargets[1]) {
m_aSumText[_local3][_local2].textColor = m_aPlayerColours[1];
} else {
m_aSumText[_local3][_local2].textColor = 0;
}
m_aSumText[_local3][_local2].autoSize = "left";
_local2++;
}
_local3++;
}
}
function Uncolour() {
while (m_aColoured.length > 0) {
var _local2 = m_aColoured.pop();
_local2.SetColour(0);
}
}
static var c_iMaxTiles = 5;
static var c_iBuffer = 22;
static var c_iCarryColour = 43520;
}
Symbol 237 MovieClip [__Packages.BoardData] Frame 0
class BoardData
{
var m_iDim, m_iTotalCells, m_iSetCells, m_aCells, m_aSums, m_bCarry, m_iCarryValue, m_iCarryOp, m_aCarryList;
function BoardData (iDim) {
m_iDim = iDim;
m_iTotalCells = m_iDim * m_iDim;
m_iSetCells = 0;
m_aCells = new Array(m_iDim);
var _local5 = 0;
while (_local5 < m_iDim) {
m_aCells[_local5] = new Array(m_iDim);
var _local3 = 0;
while (_local3 < m_iDim) {
m_aCells[_local5][_local3] = -1;
_local3++;
}
_local5++;
}
m_aSums = new Array(m_iDim - 1);
var _local4 = 0;
while (_local4 < (m_iDim - 1)) {
m_aSums[_local4] = new Array(m_iDim - 1);
var _local2 = 0;
while (_local2 < (m_iDim - 1)) {
m_aSums[_local4][_local2] = 0;
_local2++;
}
_local4++;
}
}
function GetDim() {
return(m_iDim);
}
function IsFull() {
return(m_iSetCells == m_iTotalCells);
}
function EmptyCount() {
return(m_iTotalCells - m_iSetCells);
}
function Set(iRow, iCol, iValue) {
m_aCells[iRow][iCol] = iValue;
m_iSetCells = m_iSetCells + 1;
UpdateSums(iRow, iCol, 0, iValue);
}
function IsSet(iRow, iCol) {
return(m_aCells[iRow][iCol] >= 0);
}
function Adjust(iRow, iCol, iValue, iOp) {
var _local11 = m_aCells[iRow][iCol];
var _local8;
if (iOp == 0) {
_local8 = _local11 + iValue;
} else if (iOp == 1) {
_local8 = _local11 - iValue;
} else {
_local8 = _local11 * iValue;
}
if (_local8 > 9) {
m_bCarry = true;
m_iCarryValue = Math.floor(_local8 / 10);
m_iCarryOp = 0;
_local8 = _local8 % 10;
} else if (_local8 < 0) {
m_bCarry = true;
m_iCarryValue = -1;
m_iCarryOp = 0;
_local8 = _local8 + 10;
} else {
m_bCarry = false;
}
m_aCells[iRow][iCol] = _local8;
var _local10;
var _local9;
var _local7;
var _local6;
if (m_bCarry) {
_local10 = iRow - 1;
_local9 = iRow + 1;
_local7 = iCol - 1;
_local6 = iCol + 1;
if (_local10 < 0) {
_local10 = 0;
}
if (_local9 == m_iDim) {
_local9 = m_iDim - 1;
}
if (_local7 < 0) {
_local7 = 0;
}
if (_local6 == m_iDim) {
_local6 = m_iDim - 1;
}
m_aCarryList = new Array();
var _local3 = _local10;
while (_local3 <= _local9) {
var _local2 = _local7;
while (_local2 <= _local6) {
if ((_local3 != iRow) || (_local2 != iCol)) {
m_aCarryList.push(new Point(_local3, _local2));
}
_local2++;
}
_local3++;
}
}
UpdateSums(iRow, iCol, _local11, _local8);
return(_local8);
}
function HasCarry() {
return(m_bCarry);
}
function GetCarryList() {
return(m_aCarryList);
}
function CarryValue() {
return(m_iCarryValue);
}
function CarryOperator() {
return(m_iCarryOp);
}
function GetSum(iRow, iCol) {
return(m_aSums[iRow][iCol]);
}
function GetSumsAffected(iRow, iCol) {
var _local5 = iRow - 1;
var _local3 = iRow;
var _local4 = iCol - 1;
var _local2 = iCol;
if (_local5 < 0) {
_local5 = 0;
}
if (_local3 == (m_iDim - 1)) {
_local3 = m_iDim - 2;
}
if (_local4 < 0) {
_local4 = 0;
}
if (_local2 == (m_iDim - 1)) {
_local2 = m_iDim - 2;
}
return(new Array(_local5, _local3, _local4, _local2));
}
function Duplicate() {
var _local4 = new BoardData(m_iDim);
_local4.m_iTotalCells = m_iTotalCells;
_local4.m_iSetCells = m_iSetCells;
var _local3 = 0;
while (_local3 < m_iDim) {
var _local2 = 0;
while (_local2 < m_iDim) {
_local4.m_aCells[_local3][_local2] = m_aCells[_local3][_local2];
if ((_local3 < (m_iDim - 1)) && (_local2 < (m_iDim - 1))) {
_local4.m_aSums[_local3][_local2] = m_aSums[_local3][_local2];
}
_local2++;
}
_local3++;
}
_local4.m_bCarry = m_bCarry;
_local4.m_iCarryValue = m_iCarryValue;
_local4.m_iCarryOp = m_iCarryOp;
var _local5 = 0;
while (_local5 < m_aCarryList.length) {
_local4.m_aCarryList[_local5] = m_aCarryList[_local5];
_local5++;
}
return(_local4);
}
function UpdateSums(iRow, iCol, iOldValue, iNewValue) {
var _local9 = iRow - 1;
var _local8 = iRow;
var _local5 = iCol - 1;
var _local4 = iCol;
if (_local9 < 0) {
_local9 = 0;
}
if (_local8 == (m_iDim - 1)) {
_local8 = m_iDim - 2;
}
if (_local5 < 0) {
_local5 = 0;
}
if (_local4 == (m_iDim - 1)) {
_local4 = m_iDim - 2;
}
var _local3 = _local9;
while (_local3 <= _local8) {
var _local2 = _local5;
while (_local2 <= _local4) {
m_aSums[_local3][_local2] = m_aSums[_local3][_local2] + (iNewValue - iOldValue);
_local2++;
}
_local3++;
}
}
}
Symbol 238 MovieClip [__Packages.Point] Frame 0
class Point
{
var row, col;
function Point (r, c) {
row = r;
col = c;
}
}
Symbol 239 MovieClip [__Packages.Tile] Frame 0
class Tile
{
static var oTileFormat;
var m_oClip_mc, m_oText, m_bSet, m_iValue, m_iX, m_iY;
function Tile (m_oParent_mc) {
var _local2;
if (m_oParent_mc._x < 10) {
_local2 = "s_TileLeft";
} else if (m_oParent_mc._x > 200) {
_local2 = "s_TileRight";
} else {
_local2 = "s_Tile";
}
m_oParent_mc.attachMovie(_local2, ("Tile" + iIndex) + "_mc", c_iClipIndex + iIndex);
m_oClip_mc = m_oParent_mc[("Tile" + iIndex) + "_mc"];
m_oClip_mc._width = c_iSize;
m_oClip_mc._height = c_iSize;
m_oClip_mc.createTextField("TileText" + iIndex, c_iTextIndex + iIndex, 16, -2, 1, 1);
m_oText = m_oClip_mc["TileText" + iIndex];
m_oText.type = "dynamic";
m_oText.selectable = false;
m_oText.text = "";
iIndex = iIndex + 1;
}
function Show() {
m_oClip_mc._visible = true;
}
function Hide() {
m_oClip_mc._visible = false;
}
function IsSet() {
return(m_bSet);
}
function GetValue() {
return(m_iValue);
}
function SetValue(iValue) {
m_iValue = iValue;
m_oText.text = "" + m_iValue;
m_oText.autoSize = "left";
m_oText.setTextFormat(oTileFormat);
m_bSet = true;
}
function SetOperator(sSign) {
m_oText.text = sSign;
m_oText.autoSize = "left";
m_oText.setTextFormat(oTileFormat);
}
function GetColour() {
return(m_oText.textColor);
}
function SetColour(iColour) {
m_oText.textColor = iColour;
}
function Blank() {
m_bSet = false;
m_iValue = -1;
m_oText.text = "";
m_oText.textColor = 0;
}
function Reset(iX, iY) {
m_iX = iX;
m_iY = iY;
m_oClip_mc._x = m_iX;
m_oClip_mc._y = m_iY;
Blank();
}
function Click(mx, my) {
return(m_oClip_mc.hitTest(mx, my, false));
}
static var c_iSize = 32;
static var c_iClipIndex = 100;
static var c_iTextIndex = 200;
static var iIndex = 1;
}
Symbol 240 MovieClip [__Packages.Player] Frame 0
class Player
{
var m_oSide_mc, m_iColour, m_oTargetTextFormat, m_aValues, m_aOpsSel, m_aOpsUnSel, m_bHuman, m_iTarget, m_iSelValue, m_bPlacement, m_iSelOperator;
function Player () {
}
function Init(oSide_mc, iColour, aOpsSel, aOpsUnSel) {
m_oSide_mc = oSide_mc;
m_iColour = iColour;
m_oTargetTextFormat = new TextFormat();
m_oTargetTextFormat.size = 18;
m_oSide_mc.createTextField("Target", c_iIndex + iIndex, 65, 32, 1, 1);
iIndex++;
m_oSide_mc.Target.text = "";
m_oSide_mc.Target.setTextFormat(m_oTargetTextFormat);
m_oSide_mc.Target.textColor = m_iColour;
m_oSide_mc.Target.autoSize = "left";
m_oSide_mc.Target.type = "dynamic";
m_oSide_mc.Target.selectable = false;
m_aValues = new Array(c_iValues);
var _local3 = 0;
while (_local3 < c_iValues) {
m_aValues[_local3] = new Tile(m_oSide_mc);
m_aValues[_local3].Reset(59, 75 + (_local3 * 40));
m_aValues[_local3].Hide();
_local3++;
}
m_aOpsSel = new Array(c_iOperators);
m_aOpsUnSel = new Array(c_iOperators);
var _local2 = 0;
while (_local2 < c_iOperators) {
m_oSide_mc.attachMovie(aOpsSel[_local2], ("OpsSel" + _local2) + "_mc", c_iIndex + iIndex);
iIndex++;
m_aOpsSel[_local2] = m_oSide_mc[("OpsSel" + _local2) + "_mc"];
m_aOpsSel[_local2]._x = 16 + (_local2 * 40);
m_aOpsSel[_local2]._y = 270;
m_aOpsSel[_local2]._visible = false;
m_oSide_mc.attachMovie(aOpsUnSel[_local2], ("OpsUnSel" + _local2) + "_mc", c_iIndex + iIndex);
iIndex++;
m_aOpsUnSel[_local2] = m_oSide_mc[("OpsUnSel" + _local2) + "_mc"];
m_aOpsUnSel[_local2]._x = 16 + (_local2 * 40);
m_aOpsUnSel[_local2]._y = 270;
m_aOpsUnSel[_local2]._visible = false;
_local2++;
}
}
function SetHuman(bHuman) {
m_bHuman = bHuman;
}
function StartRound(iTarget) {
m_iTarget = iTarget;
m_oSide_mc.Target.text = "" + iTarget;
m_oSide_mc.Target.setTextFormat(m_oTargetTextFormat);
m_oSide_mc.Target.autoSize = "left";
var _local2 = 0;
while (_local2 < c_iValues) {
m_iSelValue = _local2;
ReplaceValue();
m_aValues[_local2].Show();
_local2++;
}
m_iSelValue = -1;
m_bPlacement = true;
var _local3 = 0;
while (_local3 < c_iOperators) {
m_aOpsSel[_local3]._visible = false;
m_aOpsUnSel[_local3]._visible = false;
_local3++;
}
m_oSide_mc._visible = true;
}
function GetTarget() {
return(m_iTarget);
}
function EndPlacement() {
m_bPlacement = false;
m_iSelOperator = 0;
m_aOpsSel[m_iSelOperator]._visible = true;
m_aOpsUnSel[m_iSelOperator]._visible = false;
var _local2 = 1;
while (_local2 < c_iOperators) {
m_aOpsSel[_local2]._visible = false;
m_aOpsUnSel[_local2]._visible = true;
_local2++;
}
}
function GetValue() {
if (m_iSelValue >= 0) {
return(m_aValues[m_iSelValue].GetValue());
}
return(-1);
}
function GetOperator() {
return(m_iSelOperator);
}
function Select(iValue, iOperator) {
var _local2 = 0;
while (_local2 < c_iValues) {
if (m_aValues[_local2].GetValue() == iValue) {
m_aValues[m_iSelValue].SetColour(0);
m_iSelValue = _local2;
m_aValues[m_iSelValue].SetColour(m_iColour);
SoundControl.PlayerTileClick();
}
_local2++;
}
if (iOperator >= 0) {
m_aOpsSel[m_iSelOperator]._visible = false;
m_aOpsUnSel[m_iSelOperator]._visible = true;
m_iSelOperator = iOperator;
m_aOpsSel[m_iSelOperator]._visible = true;
m_aOpsUnSel[m_iSelOperator]._visible = false;
SoundControl.ButtonClick();
}
}
function GetColour() {
return(m_iColour);
}
function Click(mx, my) {
var _local2 = 0;
while (_local2 < c_iValues) {
if (m_aValues[_local2].Click(mx, my)) {
m_aValues[m_iSelValue].SetColour(0);
m_iSelValue = _local2;
m_aValues[m_iSelValue].SetColour(m_iColour);
SoundControl.PlayerTileClick();
}
_local2++;
}
if (!m_bPlacement) {
var _local3 = 0;
while (_local3 < c_iOperators) {
if (m_aOpsUnSel[_local3].hitTest(mx, my)) {
m_aOpsSel[m_iSelOperator]._visible = false;
m_aOpsUnSel[m_iSelOperator]._visible = true;
m_iSelOperator = _local3;
m_aOpsSel[m_iSelOperator]._visible = true;
m_aOpsUnSel[m_iSelOperator]._visible = false;
SoundControl.ButtonClick();
}
_local3++;
}
}
}
function GetValues() {
var _local3 = new Array();
var _local2 = 0;
while (_local2 < m_aValues.length) {
_local3[_local2] = m_aValues[_local2].GetValue();
_local2++;
}
return(_local3);
}
function RemoveValue() {
m_aValues[m_iSelValue].Blank();
}
function ReplaceValue() {
m_aValues[m_iSelValue].SetValue(Math.floor(Math.random() * 10));
m_iSelValue = -1;
}
static var c_iValues = 4;
static var c_iOperators = 3;
static var c_iIndex = 30;
static var iIndex = 0;
}
Symbol 241 MovieClip [__Packages.AI] Frame 0
class AI
{
var m_iLevel, m_iTarget, m_iOpTarget;
function AI () {
}
function SetLevel(iLevel) {
m_iLevel = iLevel;
}
function SetTargets(iTarget, iOpTarget) {
m_iTarget = iTarget;
m_iOpTarget = iOpTarget;
}
function GetPlacement(aValues, aOpValues, oData) {
return(MyPlacement(aValues, aOpValues, oData, 0).moves[0]);
}
function GetMove(aValues, aOpValues, oData) {
return(MyMove(aValues, aOpValues, oData, 0));
}
function MyPlacement(aV, aO, oD, iLevel) {
var _local9 = oD.GetDim();
var _local8 = new BestMove();
var _local5 = 0;
while (_local5 < _local9) {
var _local4 = 0;
while (_local4 < _local9) {
if (oD.IsSet(_local5, _local4)) {
} else {
var _local3 = 0;
while (_local3 < aV.length) {
var _local7 = oD.Duplicate();
var _local2 = new BestMove();
_local2.moves.push(new Move(_local5, _local4, aV[_local3], -1));
_local7.Set(_local5, _local4, aV[_local3]);
_local2.eval = Evaluate(_local7);
if (m_iLevel > 1) {
if (aV[_local3] == Math.ceil(m_iTarget / 4)) {
_local2.eval = _local2.eval + 50;
} else {
_local2.eval = _local2.eval + (aV[_local3] * 3);
}
if ((_local5 > 0) && (_local5 < (_local9 - 1))) {
_local2.eval = _local2.eval + 20;
}
if ((_local4 > 0) && (_local4 < (_local9 - 1))) {
_local2.eval = _local2.eval + 20;
}
}
if (_local2.eval > _local8.eval) {
_local8.eval = _local2.eval;
_local8.moves = _local2.moves;
}
_local3++;
}
}
_local4++;
}
_local5++;
}
return(_local8);
}
function MyMove(aV, aO, oD, iLevel) {
var _local12 = oD.GetDim();
var _local5 = new BestMove();
var _local8 = 0;
while (_local8 < _local12) {
var _local6 = 0;
while (_local6 < _local12) {
var _local2 = 0;
while (_local2 < aV.length) {
var _local4 = 0;
while (_local4 < Player.c_iOperators) {
var _local3 = MyTest(_local8, _local6, aV[_local2], _local4, RemoveValue(aV, _local2), aO, oD, iLevel);
if (_local3.eval > _local5.eval) {
_local5.eval = _local3.eval;
_local5.moves = _local3.moves;
}
_local4++;
}
_local2++;
}
_local6++;
}
_local8++;
}
return(_local5.moves);
}
function MyCarry(aV, aO, oD, iLevel) {
var _local7 = oD.GetCarryList();
var _local5 = new BestMove();
var _local2 = 0;
while (_local2 < _local7.length) {
var _local4 = _local7[_local2];
var _local3 = MyTest(_local4.row, _local4.col, oD.CarryValue(), oD.CarryOperator(), aV, aO, oD, iLevel);
if (_local3.eval > _local5.eval) {
_local5.eval = _local3.eval;
_local5.moves = _local3.moves;
}
_local2++;
}
return(_local5);
}
function MyTest(iR, iC, iV, iO, aV, aO, oD, iLevel) {
var _local3 = oD.Duplicate();
var _local2 = new BestMove();
_local2.moves.push(new Move(iR, iC, iV, iO));
_local3.Adjust(iR, iC, iV, iO);
if (_local3.HasCarry()) {
_local2.Append(MyCarry(aV, aO, _local3, iLevel));
} else {
_local2.eval = Evaluate(_local3);
}
return(_local2);
}
function Evaluate(oD) {
var _local7 = oD.GetDim() - 1;
var _local3 = Math.floor(Math.random() * 10);
var _local5;
var _local2;
var _local6 = 0;
while (_local6 < _local7) {
var _local4 = 0;
while (_local4 < _local7) {
_local5 = oD.GetSum(_local6, _local4);
_local2 = Math.abs(m_iTarget - _local5);
if (m_iLevel > 2) {
if (_local2 == 0) {
_local3 = _local3 + 250;
} else if (_local2 == 1) {
_local3 = _local3 + 50;
} else if (_local2 < 5) {
_local3 = _local3 + 25;
} else if (_local2 < 10) {
_local3 = _local3 + 15;
} else if (_local2 < 20) {
_local3 = _local3 + 5;
}
_local2 = Math.abs(m_iOpTarget - _local5);
if (_local2 == 0) {
_local3 = _local3 - 500;
} else if (_local2 == 1) {
_local3 = _local3 - 75;
} else if (_local2 < 5) {
_local3 = _local3 - 20;
} else if (_local2 < 10) {
_local3 = _local3 - 10;
}
} else if (m_iLevel == 2) {
if (_local2 == 0) {
_local3 = _local3 + 100;
}
_local2 = Math.abs(m_iOpTarget - _local5);
if (_local2 == 0) {
_local3 = _local3 - 100;
}
} else if (m_iLevel == 1) {
if (_local2 == 0) {
_local3 = _local3 + 100;
}
} else if (m_iLevel == 0) {
if (_local2 == 0) {
_local3 = 5 + Math.floor(Math.random() * 10);
}
}
_local4++;
}
_local6++;
}
return(_local3);
}
function RemoveValue(aValues, iIndex) {
var _local3 = new Array();
var _local1 = 0;
while (_local1 < aValues.length) {
if (_local1 != iIndex) {
_local3.push(aValues[_local1]);
}
_local1++;
}
return(_local3);
}
}
Symbol 242 MovieClip [__Packages.Move] Frame 0
class Move
{
var row, col, value, operator;
function Move (r, c, v, o) {
row = r;
col = c;
value = v;
operator = o;
}
}
Symbol 243 MovieClip [__Packages.BestMove] Frame 0
class BestMove
{
var eval, moves;
function BestMove () {
eval = -32000;
moves = new Array();
}
function Append(oBestMove) {
eval = oBestMove.eval;
var _local2 = 0;
while (_local2 < oBestMove.moves.length) {
moves.push(oBestMove.moves[_local2]);
_local2++;
}
}
}