ခုေတာ့ ေနာက္ဂိမ္းအသစ္တင္ဆက္ပါမယ္။ HTML နဲ႕ Javascript တို႕ေပါင္းစပ္ၿပီးလုပ္ထားတာပါ။ C++ language ကေန HTML တို႕ Javascript အျဖစ္ေျပာင္းလုပ္ထားတာပါ။ ကုဒ္ေတြအလုပ္မလုပ္လို႕ အခ်ိန္ေပးၿပီး ထြင္ေနရတာပါ။ ပံုေတြက အလုပ္မလုပ္လို႕ blogspot.com နဲ႕ပံုတင္ၿပီး ျပင္ထားပါတယ္။ ကြ်န္ေတာ္ကေတာ့ ဒီဟာကို Dreamweaver နဲ႕ Notepad++ နဲ႕လုပ္တာပါ။ ၂နာရီေလာက္ၾကာသြားပါတယ္ဗ်ာ။ အဆင္မေျပရင္ ပံုေတြပါေပးလိုက္မယ္။ ပံုေလးေတြကို download လုပ္ခ်င္ရင္...
အေပၚက ဂိမ္းမဟုတ္ေသးဘူး။ ဂိမ္းက ေအာက္က ေနာက္ download button ကို click ၿပီးေဒါင္းေစဗ်ာ။
အဲ့မွာ html ဖိုင္ေတြ႕လိမ့္မယ္။ ဖြင့္သာဖြင့္ခ်လိုက္။ ဒါဆုိရင္ ဂိမ္းစတင္ေဆာ့ကစားလို႕ရပါၿပီခင္ဗ်ာ။
ကိုယ့္ဘာသာကိုယ္ထြင္ၿပီးကစားခ်င္ရင္ေတာ့ လြယ္လြယ္ေလးပဲ။
ခင္ဗ်ားတို႕အတြက္ ေဆာ့စရာေလးပါ။ Notepad ကိုဖြင့္လိုက္ပါ။ မဖြင့္တတ္ရင္
Start >> Programs >> Accessories >> Notepad ဆိုတဲ့
အျပာေရာင္စာအုပ္ေလးေပါ့(Windows XP ကိုင္တဲ့သူေတြဖြင့္ဖို႕)။ ဒါေပမယ့္
ကြ်န္ေတာ္ Windows 7 အေၾကာင္းကုိ သိပ္နားမလည္ပါဘူး။ ဒါေၾကာင့္ ကိုယ့္ဘာသာ
ကိုယ္ရွာၾကည့္ပါ။ Notepad မွာ ေအာက္ပါ ကြ်န္ေတာ္ေပးတဲ့ HTML Code
ကိုကူးၿပီးေတာ့ TicTacToe3D.html လို႕ေပးၿပီး save လိုက္ပါ။ ၿပီးရင္
Mozilla Firefox မွာဖြင့္ၾကည့္ပါ။ ဒါမွမဟုတ္ရင္ ကိုယ္ဖြင့္ခ်င္တဲ့ browser မွာဖြင့္ေပးလိုက္။ ၿပီးရင္ စိတ္ခ်လက္ခ်ေဆာ့လို႕ရပါၿပီ။ ကုဒ္က ေအာက္ပါအတုိင္းကူးလိုက္ပါ။
ကုဒ္ကအလုပ္မလုပ္လို႕ တစ္ပတ္အၾကာမွ တင္တာကိုေတာင္းပန္ပါတယ္ဗ်ာ။
<HTML>
<HEAD>
<META NAME="description" content="TicTac3D is a
PC-Game, which is a part of the '7 by one stroke'
package, translated from C++ into HTML and
JavaScript">
<META NAME="author"
content="http://pyae-phyo.blogspot.com">
<META NAME="keywords" content="Game,
TicTac3D, Streich, Stroke, JavaScript">
<META HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=iso-8859-1">
<title>TicTac3D</title>
<script language="JavaScript">
var i, j, k, RotAng, XMouseOver, YMouseOver,
LastEvent, IsOver=-1, IsStart0;
var Start, I_Sel, J_Sel, Start0, NBlink=0;
var NeedBallDown, MoveCount, MaxMoveCount;
IsPlayer = new Array(2);
Level = new Array(2);
Fld = new Array(4);
for (i=0; i<4; i++)
Fld[i] = new Array(4);
for (i=0; i<4; i++)
{ for (j=0; j<4; j++)
Fld[i][j] = new Array(4);
}
ScreenFld = new Array(4);
for (i=0; i<4; i++)
ScreenFld[i] = new Array(4);
for (i=0; i<4; i++)
{ for (j=0; j<4; j++)
ScreenFld[i][j] = new Array(2);
}
FldCount = new Array(4);
for (i=0; i<4; i++)
FldCount[i] = new Array(4);
Value = new Array(4);
for (i=0; i<4; i++)
Value[i] = new Array(4);
History = new Array(64);
for (i=0; i<64; i++)
History[i] = new Array(2);
Pic= new Array(4);
Pic[0] = new Image(); Pic[0].src =
"http://3.bp.blogspot.com/-H9y5f78O_hQ/UQ42q5X4
6wI/AAAAAAAAClU/K_cDVioy1cg/s1600/tt3d_0.gif";
Pic[1] = new Image(); Pic[1].src =
"http://4.bp.blogspot.com/--drIEih8Xfs/UQ42sECQ4
TI/AAAAAAAACls/UEXzI0DP6i8/s1600/tt3dred.gif";
Pic[2] = new Image(); Pic[2].src =
"http://4.bp.blogspot.com/-YY-ZssbHboY/UQ42s4hV
-hI/AAAAAAAACl4/43ctLNDHKFY/s1600/tt3d_1.gif";
Pic[3] = new Image(); Pic[3].src =
"http://1.bp.blogspot.com/-lmjCjncseII/UQ42sx4hKu
I/AAAAAAAACl0/dnjpTpg9B7E/s1600/tt3dblue.gif";
BG= new Array(2);
BG[0] = new Image(); BG[0].src =
"http://3.bp.blogspot.com/-O8220I2a7LM/UQ42rQN
Wh3I/AAAAAAAAClk/vvGPsu84LYI/s1600/tt3d0bg.gif
";
BG[1] = new Image(); BG[1].src =
"http://2.bp.blogspot.com/-BNo56_uZ_Kc/UQ42q3uz
IsI/AAAAAAAAClY/f_ONZCsLdYY/s1600/tt3d1bg.gif";
IsStart0=true;
IsPlayer[0]=true;
IsPlayer[1]=false;
Level[0]=2;
Level[1]=3;
WinFlds=new Array(2);
WinFlds[0]=new Array(3);
WinFlds[1]=new Array(3);
function Init()
{ var ii, jj, kk;
for (ii=0; ii<4; ii++)
{ for (jj=0; jj<4; jj++)
{ for (kk=0; kk<4; kk++)
Fld[ii][jj][kk]=0;
FldCount[ii][jj]=0;
}
}
if (IsStart0) Start0=true;
else Start0=false;
LastEvent="";
NeedBallDown=0;
I_Sel=-1; J_Sel=-1;
MoveCount=0;
MaxMoveCount=0;
RotAng=0;
XMouseOver=-1;
YMouseOver=-1;
RefreshScreen();
IsOver=0;
NBlink=0;
}
function SetOption(nn, mm)
{ if (nn<2)
{ if (mm==0)
IsPlayer[nn]=true;
else
IsPlayer[nn]=false;
}
else IsStart0=mm;
}
function SetLevel(nn, mm)
{ Level[nn]=mm;
}
function MoveString(nn)
{ if (nn>9) return(" "+nn+" ");
return(" "+nn+" ");
}
function Timer()
{ if (IsOver<0) return;
if (IsOver>0) { Blink(); return; }
if (NeedBallDown==0)
{ if
((((MoveCount+Start0)%2==1)&&(IsPlayer[0]))||
(((MoveCount+Start0)%2==0)&&(IsPlayer[1])));
else
{ if (LastEvent=="")
GetBestMove(((MoveCount+1+Start0)%2)*2-1);
if (LastEvent=="TurnLeft") { TurnLeft();
LastEvent=""; }
if (LastEvent=="TurnRight") { TurnRight();
LastEvent=""; }
if (LastEvent=="Back") { Back(); LastEvent="";
}
if (LastEvent=="Replay") { Replay();
LastEvent=""; }
}
}
if (NeedBallDown>0)
{ if (Fld[I_Sel][J_Sel][NeedBallDown-1]==0)
{ if (NeedBallDown<4)
window.document.images[13*(YMouseOver+3-Need
BallDown)+XMouseOver].src = Pic[2].src;
if ((MoveCount+Start0)%2==1)
window.document.images[13*(YMouseOver+4-Need
BallDown)+XMouseOver].src = Pic[1].src;
else
window.document.images[13*(YMouseOver+4-Need
BallDown)+XMouseOver].src = Pic[3].src;
}
if (NeedBallDown>1)
{ if (Fld[I_Sel][J_Sel][NeedBallDown-2]!=0)
NeedBallDown=1;
}
if (NeedBallDown==1)
{
window.document.OptionsForm.Moves.value=MoveS
tring(MoveCount+1);
MakeMove();
}
NeedBallDown--;
}
}
function TurnLeft()
{ if (NeedBallDown!=0) { LastEvent="TurnLeft";
return; }
RotAng--;
if (RotAng<0) RotAng=7;
RefreshScreen();
}
function TurnRight()
{ if (NeedBallDown!=0) { LastEvent="TurnRight";
return; }
RotAng++;
if (RotAng>7) RotAng=0;
RefreshScreen();
}
function Back()
{ if (NeedBallDown!=0) { LastEvent="Back"; return;
}
if (MoveCount>0)
{ IsOver=0;
NBlink=0;
MoveCount--;
var ii=History[MoveCount][0];
var jj=History[MoveCount][1];
var kk=--FldCount[ii][jj];
Fld[ii][jj][kk]=0;
window.document.OptionsForm.Moves.value=MoveS
tring(MoveCount);
RefreshPic(ii, jj, kk);
}
}
function Replay()
{ if (NeedBallDown!=0) { LastEvent="Replay";
return; }
if (MoveCount<MaxMoveCount)
{ I_Sel=History[MoveCount][0];
J_Sel=History[MoveCount][1];
window.document.OptionsForm.Moves.value=MoveS
tring(MoveCount+1);
MakeMove();
RefreshPic(I_Sel, J_Sel,
FldCount[I_Sel][J_Sel]-1);
}
}
function MakeMove()
{ var ccol, kk;
ccol=((MoveCount+1+Start0)%2)*2-1;
kk=FldCount[I_Sel][J_Sel]++;
Fld[I_Sel][J_Sel][kk]=ccol;
if (History[MoveCount][0]!=I_Sel)
{ History[MoveCount][0]=I_Sel;
MaxMoveCount=MoveCount+1;
}
if (History[MoveCount][1]!=J_Sel)
{ History[MoveCount][1]=J_Sel;
MaxMoveCount=MoveCount+1;
}
MoveCount++;
if (MaxMoveCount<MoveCount)
MaxMoveCount=MoveCount;
IsOver=IsWinning(I_Sel, J_Sel, kk, ccol);
if (IsOver>0)
{ if (ccol<0) alert("Red has won !");
else alert("Blue has won !");
}
else
{ if (MoveCount==64)
{ IsOver=-1;
alert("It's a draw !");
}
}
}
function GetBestMove(theCol)
{ var ii, jj, kk, zz, vv, vvbest, nn, cc=theCol;
var iiw,jjw,kkw,wwcount;
var LLevel=Level[(MoveCount+1+Start0)%2];
I_Sel=-1; J_Sel=-1;
for (ii=0; ii<4; ii++)
{ for (jj=0; jj<4; jj++)
{ if ((kk=FldCount[ii][jj])<4)
{ Fld[ii][jj][kk]=cc;
if (IsWinning(ii, jj, kk, cc)>0)
{ Fld[ii][jj][kk]=0;
Select(ii, jj);
return;
}
Fld[ii][jj][kk]=0;
}
}
}
nn=0;
for (ii=0; ii<4; ii++)
{ for (jj=0; jj<4; jj++)
{ Value[ii][jj]=0;
if ((kk=FldCount[ii][jj])<4)
{ nn++;
Fld[ii][jj][kk]=-cc;
if (IsWinning(ii, jj, kk, -cc)>0)
{ Fld[ii][jj][kk]=0;
Select(ii, jj);
return;
}
Fld[ii][jj][kk]=0;
}
}
}
if (LLevel>2)
{ for (ii=0; ii<4; ii++)
{ for (jj=0; jj<4; jj++)
{ if ((kk=FldCount[ii][jj])<4)
{ wwcount=0;
Fld[ii][jj][kk]=cc;
if (kk<3)
{ if ((wwcount=CanWin(ii,jj,kk+1,cc))==2)
{ Fld[ii][jj][kk]=0;
Select(ii, jj);
return;
}
}
if (wwcount>=0)
{ for (iiw=0; iiw<4; iiw++)
{ for (jjw=0; jjw<4; jjw++)
{ if ((kkw=FldCount[iiw][jjw])<4)
{ if (!((ii==iiw)&&(jj==jjw)))
{ Fld[iiw][jjw][kkw]=cc;
if (IsWinning(iiw, jjw, kkw, cc)>0)
wwcount++;
Fld[iiw][jjw][kkw]=0;
if (wwcount>1)
{ Fld[ii][jj][kk]=0;
Select(ii, jj);
return;
}
}
}
}
}
}
Fld[ii][jj][kk]=0;
}
}
}
}
if (LLevel>3)
{ for (ii=0; ii<4; ii++)
{ for (jj=0; jj<4; jj++)
{ if ((kk=FldCount[ii][jj])<4)
{ vv=0;
Fld[ii][jj][kk]=cc;
if (kk<3)
{ Fld[ii][jj][kk+1]=-cc;
if (IsWinning(ii, jj, kk+1, -cc)>0)
vv=-1;
Fld[ii][jj][kk+1]=0;
}
if (vv==0)
{ Fld[ii][jj][kk]=-cc;
if(kk<3)
{ Fld[ii][jj][kk+1]=cc;
if (IsWinning(ii, jj, kk+1, cc)>0)
Value[ii][jj]=-200;
Fld[ii][jj][kk+1]=0;
}
for (iiw=0; iiw<4; iiw++)
{ for (jjw=0; jjw<4; jjw++)
{ if ((kkw=FldCount[iiw][jjw])<4)
{ if (!((ii==iiw)&&(jj==jjw)))
{ if
((vv=CanWin(iiw,jjw,kkw,-cc))==2)
{ Fld[ii][jj][kk]=0;
Select(ii, jj);
return;
}
if (vv==-1)
Value[ii][jj]=-100;
}
}
}
}
Fld[ii][jj][kk]=cc;
if (kk<3)
{ Fld[ii][jj][kk+1]=-cc;
for (iiw=0; iiw<4; iiw++)
{ for (jjw=0; jjw<4; jjw++)
{ if ((kkw=FldCount[iiw][jjw])<4)
{ if (!((ii==iiw)&&(jj==jjw)))
{ if (CanWin(iiw,jjw,kkw,-cc)==2)
Value[ii][jj]=-5000;
}
}
}
}
Fld[ii][jj][kk+1]=0;
}
}
Fld[ii][jj][kk]=0;
}
}
}
}
if (nn==0)
{ IsOver=-1; return; }
zz=0;
nn=0;
for (ii=0; ii<4; ii++)
{ for (jj=0; jj<4; jj++)
{ if ((kk=FldCount[ii][jj])<4)
{ Fld[ii][jj][kk]=cc;
if (kk<3)
{ Fld[ii][jj][kk+1]=-cc;
if (IsWinning(ii, jj, kk+1, -cc)>0)
{ vv=-8100;
Fld[ii][jj][kk+1]=0;
}
else
{ Fld[ii][jj][kk+1]=0;
vv=GetValue(ii, jj, kk, cc);
}
}
else
vv=GetValue(ii, jj, kk, cc);
if (LLevel<2) vv%=200;
if (LLevel<3)
vv+=Math.floor(Math.random()*108);
if (LLevel==3)
vv+=Math.floor(Math.random()*27);
Value[ii][jj]+=vv;
if (zz==0) vvbest=Value[ii][jj];
zz++;
if (Value[ii][jj]==vvbest)
nn++;
if (Value[ii][jj]>vvbest)
{ nn=1;
vvbest=Value[ii][jj];
}
Fld[ii][jj][kk]=0;
}
}
}
zz=Math.floor(Math.random()*nn);
nn=-1;
for (ii=0; ii<4; ii++)
{ for (jj=0; jj<4; jj++)
{ if ((kk=FldCount[ii][jj])<4)
{ if (vvbest==Value[ii][jj])
{ nn++;
if (nn==zz)
{ Select(ii, jj);
return;
}
}
}
}
}
}
function CanWin(ii, jj, kk, cc)
{ var kkl, kkk=kk-1;
var vv=0;
do
{ kkk++;
Fld[ii][jj][kkk]=-cc;
if (IsWinning(ii, jj, kkk, -cc)>0)
{ for (kkl=kk; kkl<=kkk; kkl++)
Fld[ii][jj][kkl]=0;
if (kkk==kk) return(-1);
else return(vv);
}
Fld[ii][jj][kkk]=cc;
if ((IsWinning(ii, jj, kkk, cc)>0)&&(kkk<3))
{ if (kkk==kk) vv++;
Fld[ii][jj][kkk]=-cc;
Fld[ii][jj][kkk+1]=cc;
if (IsWinning(ii, jj, kkk+1, cc)>0)
{ for (kkl=kk; kkl<=kkk+1; kkl++)
Fld[ii][jj][kkl]=0;
return(2);
}
Fld[ii][jj][kkk+1]=0;
}
Fld[ii][jj][kkk]=-cc;
}
while (kkk<3);
for (kkl=kk; kkl<=kkk; kkl++)
Fld[ii][jj][kkl]=0;
return(vv);
}
function GetValue(ii, jj, kk, ccol)
{ var ll, cc, ccount1, ccount2, vval=0;
var dd1, dd2, ddv, ddd, ddr;
if (MoveCount%2==0)
{ dd1=1;
dd2=1;
ddv=(3-kk)*2;
ddd=4; ddr=4;
if (kk==2)
{ ddd=8; ddr=8; }
}
else
{ dd1=1;
dd2=1;
ddv=(3-kk)*(3-kk)+1;
ddd=4; ddr=4;
if (kk==2)
{ ddd=8; ddr=8; }
}
var ss1=0;
var ss2=0;
var ww1count=3*dd1;
var ww1=0;
var ww2count=2*dd2;
var ww2=0;
ccount1=0;
ccount2=0;
for (ll=0; ll<4; ll++)
{ if ((cc=Fld[ll][jj][kk])==ccol) ccount1+=dd1;
if (cc==-ccol) ccount2+=dd2;
}
if ((ccount1>dd1)&&(ccount2>0));
else
{ vval+=(ccount1+1)*(ccount2+1)*ddv;
ss1+=ccount1-dd1; ss2+=ccount2;
if (ccount1>=ww1count) ww1++;
if (ccount2>=ww2count) ww2++;
}
ccount1=0;
ccount2=0;
for (ll=0; ll<4; ll++)
{ if ((cc=Fld[ii][ll][kk])==ccol) ccount1+=dd1;
if (cc==-ccol) ccount2+=dd2;
}
if ((ccount1>dd1)&&(ccount2>0));
else
{ vval+=(ccount1+1)*(ccount2+1)*ddv;
ss1+=ccount1-dd1; ss2+=ccount2;
if (ccount1>=ww1count) ww1++;
if (ccount2>=ww2count) ww2++;
}
ccount1=0;
ccount2=0;
for (ll=0; ll<=kk; ll++)
{ if ((cc=Fld[ii][jj][ll])==ccol) ccount1+=dd1;
if (cc==-ccol) ccount2+=dd2;
}
if ((ccount1>dd1)&&(ccount2>0));
else
{ vval+=(ccount1+1)*(ccount2+1)*ddv;
ss1+=ccount1-dd1; ss2+=ccount2;
if (ccount1>=ww1count) ww1++;
if (ccount2>=ww2count) ww2++;
}
if (jj==kk)
{ ccount1=0;
ccount2=0;
for (ll=0; ll<4; ll++)
{ if ((cc=Fld[ii][ll][ll])==ccol) ccount1+=dd1;
if (cc==-ccol) ccount2+=dd2;
}
if ((ccount1>dd1)&&(ccount2>0));
else
{ vval+=(ccount1+1)*(ccount2+1)*ddd;
ss1+=ccount1-dd1; ss2+=ccount2;
if (ccount1>=ww1count) ww1++;
if (ccount2>=ww2count) ww2++;
}
}
if ((3-jj)==kk)
{ ccount1=0;
ccount2=0;
for (ll=0; ll<4; ll++)
{ if ((cc=Fld[ii][3-ll][ll])==ccol) ccount1+=dd1;
if (cc==-ccol) ccount2+=dd2;
}
if ((ccount1>dd1)&&(ccount2>0));
else
{ vval+=(ccount1+1)*(ccount2+1)*ddd;
ss1+=ccount1-dd1; ss2+=ccount2;
if (ccount1>=ww1count) ww1++;
if (ccount2>=ww2count) ww2++;
}
}
if (ii==kk)
{ ccount1=0;
ccount2=0;
for (ll=0; ll<4; ll++)
{ if ((cc=Fld[ll][jj][ll])==ccol) ccount1+=dd1;
if (cc==-ccol) ccount2+=dd2;
}
if ((ccount1>dd1)&&(ccount2>0));
else
{ vval+=(ccount1+1)*(ccount2+1)*ddd;
ss1+=ccount1-dd1; ss2+=ccount2;
if (ccount1>=ww1count) ww1++;
if (ccount2>=ww2count) ww2++;
}
}
if ((3-ii)==kk)
{ ccount1=0;
ccount2=0;
for (ll=0; ll<4; ll++)
{ if ((cc=Fld[3-ll][jj][ll])==ccol) ccount1+=dd1;
if (cc==-ccol) ccount2+=dd2;
}
if ((ccount1>dd1)&&(ccount2>0));
else
{ vval+=(ccount1+1)*(ccount2+1)*ddd;
ss1+=ccount1-dd1; ss2+=ccount2;
if (ccount1>=ww1count) ww1++;
if (ccount2>=ww2count) ww2++;
}
}
if (jj==ii)
{ ccount1=0;
ccount2=0;
for (ll=0; ll<4; ll++)
{ if ((cc=Fld[ll][ll][kk])==ccol) ccount1+=dd1;
if (cc==-ccol) ccount2+=dd2;
}
if ((ccount1>dd1)&&(ccount2>0));
else
{ vval+=(ccount1+1)*(ccount2+1)*ddd;
ss1+=ccount1-dd1; ss2+=ccount2;
if (ccount1>=ww1count) ww1++;
if (ccount2>=ww2count) ww2++;
}
}
if ((3-jj)==ii)
{ ccount1=0;
ccount2=0;
for (ll=0; ll<4; ll++)
{ if ((cc=Fld[ll][3-ll][kk])==ccol) ccount1+=dd1;
if (cc==-ccol) ccount2+=dd2;
}
if ((ccount1>dd1)&&(ccount2>0));
else
{ vval+=(ccount1+1)*(ccount2+1)*ddd;
ss1+=ccount1-dd1; ss2+=ccount2;
if (ccount1>=ww1count) ww1++;
if (ccount2>=ww2count) ww2++;
}
}
if ((ii==jj)&&(jj==kk))
{ ccount1=0;
ccount2=0;
for (ll=0; ll<4; ll++)
{ if ((cc=Fld[ll][ll][ll])==ccol) ccount1+=dd1;
if (cc==-ccol) ccount2+=dd2;
}
if ((ccount1>dd1)&&(ccount2>0));
else
{ vval+=(ccount1+1)*(ccount2+1)*ddr;
ss1+=ccount1-dd1; ss2+=ccount2;
if (ccount1>=ww1count) ww1++;
if (ccount2>=ww2count) ww2++;
}
}
if ((ii==kk)&&((3-jj)==kk))
{ ccount1=0;
ccount2=0;
for (ll=0; ll<4; ll++)
{ if ((cc=Fld[ll][3-ll][ll])==ccol) ccount1+=dd1;
if (cc==-ccol) ccount2+=dd2;
}
if ((ccount1>dd1)&&(ccount2>0));
else
{ vval+=(ccount1+1)*(ccount2+1)*ddr;
ss1+=ccount1-dd1; ss2+=ccount2;
if (ccount1>=ww1count) ww1++;
if (ccount2>=ww2count) ww2++;
}
}
if ((ii==jj)&&(jj==(3-kk)))
{ ccount1=0;
ccount2=0;
for (ll=0; ll<4; ll++)
{ if ((cc=Fld[ll][ll][3-ll])==ccol) ccount1+=dd1;
if (cc==-ccol) ccount2+=dd2;
}
if ((ccount1>dd1)&&(ccount2>0));
else
{ vval+=(ccount1+1)*(ccount2+1)*ddr;
ss1+=ccount1-dd1; ss2+=ccount2;
if (ccount1>=ww1count) ww1++;
if (ccount2>=ww2count) ww2++;
}
}
if (((3-ii)==kk)&&(jj==kk))
{ ccount1=0;
ccount2=0;
for (ll=0; ll<4; ll++)
{ if ((cc=Fld[3-ll][ll][ll])==ccol) ccount1+=dd1;
if (cc==-ccol) ccount2+=dd2;
}
if ((ccount1>dd1)&&(ccount2>0));
else
{ vval+=(ccount1+1)*(ccount2+1)*ddr;
ss1+=ccount1-dd1; ss2+=ccount2;
if (ccount1>=ww1count) ww1++;
if (ccount2>=ww2count) ww2++;
}
}
if (ww1>1) vval+=ww1*4000;
if (ss1>3*dd1) vval+=(ss1-3*dd1)*20;
if ((ww2>=1)&&(ss2>2*dd2))
vval+=(ss2-2*dd2)*(kk+1)*50;
if (ww2>1) vval+=ww2*500;
return(vval);
}
function IsWinning(ii, jj, kk, ccol)
{ var ll, ccount;
ccount=0;
for (ll=0; ll<4; ll++)
{ if (Fld[ll][jj][kk]==ccol) ccount++;
}
if (ccount==4) return(1);
ccount=0;
for (ll=0; ll<4; ll++)
{ if (Fld[ii][ll][kk]==ccol) ccount++;
}
if (ccount==4) return(2);
ccount=0;
for (ll=0; ll<=kk; ll++)
{ if (Fld[ii][jj][ll]==ccol) ccount++;
}
if (ccount==4) return(3);
if (jj==kk)
{ ccount=0;
for (ll=0; ll<4; ll++)
{ if (Fld[ii][ll][ll]==ccol) ccount++;
}
if (ccount==4) return(4);
}
if ((3-jj)==kk)
{ ccount=0;
for (ll=0; ll<4; ll++)
{ if (Fld[ii][3-ll][ll]==ccol) ccount++;
}
if (ccount==4) return(5);
}
if (ii==kk)
{ ccount=0;
for (ll=0; ll<4; ll++)
{ if (Fld[ll][jj][ll]==ccol) ccount++;
}
if (ccount==4) return(6);
}
if ((3-ii)==kk)
{ ccount=0;
for (ll=0; ll<4; ll++)
{ if (Fld[3-ll][jj][ll]==ccol) ccount++;
}
if (ccount==4) return(7);
}
if (jj==ii)
{ ccount=0;
for (ll=0; ll<4; ll++)
{ if (Fld[ll][ll][kk]==ccol) ccount++;
}
if (ccount==4) return(8);
}
if ((3-jj)==ii)
{ ccount=0;
for (ll=0; ll<4; ll++)
{ if (Fld[ll][3-ll][kk]==ccol) ccount++;
}
if (ccount==4) return(9);
}
if ((ii==jj)&&(jj==kk))
{ ccount=0;
for (ll=0; ll<4; ll++)
{ if (Fld[ll][ll][ll]==ccol) ccount++;
}
if (ccount==4) return(10);
}
if ((ii==kk)&&((3-jj)==kk))
{ ccount=0;
for (ll=0; ll<4; ll++)
{ if (Fld[ll][3-ll][ll]==ccol) ccount++;
}
if (ccount==4) return(11);
}
if ((ii==jj)&&(jj==(3-kk)))
{ ccount=0;
for (ll=0; ll<4; ll++)
{ if (Fld[ll][ll][3-ll]==ccol) ccount++;
}
if (ccount==4) return(12);
}
if (((3-ii)==kk)&&(jj==kk))
{ ccount=0;
for (ll=0; ll<4; ll++)
{ if (Fld[3-ll][ll][ll]==ccol) ccount++;
}
if (ccount==4) return(13);
}
return(0);
}
function Blink()
{ var ii=I_Sel, jj=J_Sel, kk=FldCount[ii][jj]-1, ll, cc;
cc=NeedBallDown;
if (NeedBallDown==0)
NeedBallDown=Fld[ii][jj][kk];
else { NeedBallDown=0; NBlink++; }
if (IsOver==1)
{ for (ll=0; ll<4; ll++) { Fld[ll][jj][kk]=cc;
RefreshPic(ll,jj,kk); }
}
if (IsOver==2)
{ for (ll=0; ll<4; ll++) { Fld[ii][ll][kk]=cc;
RefreshPic(ii,ll,kk); }
}
if (IsOver==3)
{ for (ll=0; ll<=kk; ll++) { Fld[ii][jj][ll]=cc;
RefreshPic(ii,jj,ll); }
}
if (IsOver==4)
{ for (ll=0; ll<4; ll++) { Fld[ii][ll][ll]=cc;
RefreshPic(ii,ll,ll); }
}
if (IsOver==5)
{ for (ll=0; ll<4; ll++) { Fld[ii][3-ll][ll]=cc;
RefreshPic(ii,3-ll,ll); }
}
if (IsOver==6)
{ for (ll=0; ll<4; ll++) { Fld[ll][jj][ll]=cc;
RefreshPic(ll,jj,ll); }
}
if (IsOver==7)
{ for (ll=0; ll<4; ll++) { Fld[3-ll][jj][ll]=cc;
RefreshPic(3-ll,jj,ll); }
}
if (IsOver==8)
{ for (ll=0; ll<4; ll++) { Fld[ll][ll][kk]=cc;
RefreshPic(ll,ll,kk); }
}
if (IsOver==9)
{ for (ll=0; ll<4; ll++) { Fld[ll][3-ll][kk]=cc;
RefreshPic(ll,3-ll,kk); }
}
if (IsOver==10)
{ for (ll=0; ll<4; ll++) { Fld[ll][ll][ll]=cc;
RefreshPic(ll,ll,ll); }
}
if (IsOver==11)
{ for (ll=0; ll<4; ll++) { Fld[ll][3-ll][ll]=cc;
RefreshPic(ll,3-ll,ll); }
}
if (IsOver==12)
{ for (ll=0; ll<4; ll++) { Fld[ll][ll][3-ll]=cc;
RefreshPic(ll,ll,3-ll); }
}
if (IsOver==13)
{ for (ll=0; ll<4; ll++) { Fld[3-ll][ll][ll]=cc;
RefreshPic(3-ll,ll,ll); }
}
if (NBlink==7) IsOver=-1;
}
function Select(ii, jj)
{ I_Sel=ii;
J_Sel=jj;
XMouseOver=ScreenFld[ii][jj][0];
YMouseOver=ScreenFld[ii][jj][1];
NeedBallDown=4;
}
function Clicked(xx, yy)
{ if (IsOver!=0) return;
if (NeedBallDown!=0) return;
MouseOut();
MouseOver(xx, yy);
if (XMouseOver>=0)
NeedBallDown=4;
window.document.OptionsForm.HelpButton.focus();
window.document.OptionsForm.HelpButton.blur();
}
function MouseOver(xx, yy)
{ if (IsOver!=0) return;
if (XMouseOver>=0) return;
if
((((MoveCount+Start0)%2==1)&&(IsPlayer[0]))||
(((MoveCount+Start0)%2==0)&&(IsPlayer[1])))
{ if (NeedBallDown==0)
{ for (ii=0; ii<4; ii++)
{ for (jj=0; jj<4; jj++)
{ if
((ScreenFld[ii][jj][0]==xx)&&(ScreenFld[ii][jj][1]=
=yy))
{ if (Fld[ii][jj][3]==0)
{ if ((MoveCount+Start0)%2==1)
window.document.images[13*yy+xx].src =
Pic[1].src;
else
window.document.images[13*yy+xx].src =
Pic[3].src;
XMouseOver=xx;
YMouseOver=yy;
I_Sel=ii;
J_Sel=jj;
}
}
}
}
}
}
}
function MouseOut()
{ if (IsOver!=0) return;
if (XMouseOver>=0)
{ if (NeedBallDown==0)
{ for (ii=0; ii<4; ii++)
{ for (jj=0; jj<4; jj++)
{ if
((ScreenFld[ii][jj][0]==XMouseOver)&&(ScreenFld[i
i][jj][1]==YMouseOver))
window.document.images[13*YMouseOver+XMouse
Over].src = Pic[2+Fld[ii][jj][3]].src;
}
}
XMouseOver=-1;
}
}
}
function RefreshPic(ii, jj, kk)
{ var xx=ScreenFld[ii][jj][0];
var yy=ScreenFld[ii][jj][1];
window.document.images[13*(yy+3-kk)+xx].src =
Pic[2+Fld[ii][jj][kk]].src;
}
function RefreshScreen()
{ var ii, jj, kk, xx, yy;
if (document.getElementById)
document.getElementById('board').style.backgroun
dImage="url("+BG[RotAng%2].src+")";
for (ii=0; ii<13; ii++)
{ for (jj=0; jj<13; jj++)
window.document.images[13*ii+jj].src =
Pic[0].src;
}
for (ii=0; ii<4; ii++)
{ for (jj=0; jj<4; jj++)
{ if (RotAng==0) { xx=3*ii+jj; yy=9-2*jj+ii; }
if (RotAng==1) { xx=3*ii+3-jj; yy=9-2*jj+3-ii;
}
if (RotAng==2) { xx=3*(3-jj)+ii;
yy=9-2*ii+(3-jj); }
if (RotAng==3) { xx=3*(3-jj)+3-ii;
yy=9-2*ii+3-(3-jj); }
if (RotAng==4) { xx=3*(3-ii)+(3-jj);
yy=9-2*(3-jj)+(3-ii); }
if (RotAng==5) { xx=3*(3-ii)+3-(3-jj);
yy=9-2*(3-jj)+3-(3-ii); }
if (RotAng==6) { xx=3*jj+(3-ii);
yy=9-2*(3-ii)+jj; }
if (RotAng==7) { xx=3*jj+3-(3-ii);
yy=9-2*(3-ii)+3-jj; }
ScreenFld[ii][jj][0]=xx;
ScreenFld[ii][jj][1]=yy-3;
for (kk=0; kk<4; kk++)
window.document.images[13*(yy-kk)+xx].src
= Pic[2+Fld[ii][jj][kk]].src;
}
}
window.document.OptionsForm.Moves.value=MoveS
tring(MoveCount);
}
function Resize()
{ if (navigator.appName == "Netscape")
history.go(0);
}
function Help()
{ alert("This game is similar to \"Tic Tac Toe\" and
\"Connect Four\"."+
"\nThere are 4x4 sticks on a square game
board and 2 players."+
"\nOne of them has 32 red balls, the other has
32 blue balls."+
"\nThe two players alternately put a ball on a
stick. The player,"+
"\nwho first gets 4 balls in a horizontal,
vertical or diagonal line,"+
"\nis the winner.");
}
</script>
</head>
<BODY bgcolor=#cccc88 text=#000000
onResize="javascript:Resize()">
<form name="OptionsForm">
<DIV ALIGN=center>
<table noborder cellpadding=0 cellspacing=10
width=650 heigth=390>
<tr height=100%>
<td width=60% valign=center
bgcolor=#88cc88><div id="board">
<table border cellpadding=22 cellspacing=0
width=100%><tr><td>
<table noborder cellpadding=0
cellspacing=0><tr><td>
<script language="JavaScript">
document.open("text/plain");
for (j=0; j < 13; j++)
{ document.writeln("<NOBR>");
for (i=0; i < 13; i++)
document.write("<a
href=\"javascript:Clicked("+i+","+j+")\"
onMouseOver=\"MouseOver("+i+","+j+")\"
onMouseOut=\"MouseOut()\"><IMG
src=\"tt3d_0.gif\" border=0></a>");
document.writeln("</NOBR><BR>");
}
document.close();
</script>
</div></td></tr></table>
</td></tr></table>
</td>
<td width=40% valign=center>
<table border=0 cellpadding=0 cellspacing=0
width=100%>
<tr><td>
<table border=1 cellpadding=1
cellspacing=0 width=100% bgcolor=#eeeecc>
<tr><td><input type=radio name="Red"
checked value="Red: Player"
onClick="javascript:SetOption(0,0)"><b> Red:
Player</b></td></tr>
<tr><td><table noborder width=100%
cellpadding=0 cellspacing=0>
<tr><td><input type=radio
name="Red" value="Red: Computer"
onClick="javascript:SetOption(0,1)"><b> Red:
Computer</b></td></tr>
<tr><td><b> Level:
<input type=radio name="RedLevel"
value="1" onClick="javascript:SetLevel(0,1)">1
<input type=radio name="RedLevel"
checked value="2"
onClick="javascript:SetLevel(0,2)">2
<input type=radio name="RedLevel"
value="3" onClick="javascript:SetLevel(0,3)">3
<input type=radio name="RedLevel"
value="4"
onClick="javascript:SetLevel(0,4)">4</b>
</td></tr></table>
</td></tr></table>
</td></tr>
<tr><td> </td></tr>
<tr><td>
<table border=1 cellpadding=1
cellspacing=0 width=100% bgcolor=#eeeecc>
<tr><td><input type=radio name="Blue"
value="Blue: Player"
onClick="javascript:SetOption(1,0)"><b> Blue:
Player</b></td></tr>
<tr><td><table noborder width=100%
cellpadding=0 cellspacing=0>
<tr><td><input type=radio
name="Blue" checked value="Blue: Computer"
onClick="javascript:SetOption(1,1)"><b> Blue:
Computer</b></td></tr>
<tr><td><b> Level:
<input type=radio name="BlueLevel"
value="1" onClick="javascript:SetLevel(1,1)">1
<input type=radio name="BlueLevel"
value="2" onClick="javascript:SetLevel(1,2)">2
<input type=radio name="BlueLevel"
checked value="3"
onClick="javascript:SetLevel(1,3)">3
<input type=radio name="BlueLevel"
value="4"
onClick="javascript:SetLevel(1,4)">4</b>
</td></tr></table>
</td></tr></table>
</td></tr>
<tr><td> </td></tr>
<tr><td>
<table border=1 cellpadding=1
cellspacing=0 width=100% bgcolor=#eeeecc>
<tr><th colspan=2><b>Who
begins</b></th></tr>
<tr><th width="50%"><input type=radio
name="Start" checked value="Red"
onClick="javascript:SetOption(2,1)"><b>Red</b><
/th>
<th width="50%"><input type=radio
name="Start" value="Blue"
onClick="javascript:SetOption(2,0)"><b>Blue</b>
</th></tr>
</table>
</td></tr>
<tr><td> </td></tr>
<tr><td>
<table border=0 cellpadding=0
cellspacing=0 width=100%><tr>
<td width=20% align=center><input
type=button value=" <- "
style="width:40; background-color:#eeeecc"
onClick="javascript:TurnLeft()" title="turn board
left"></td>
<td width=30% align=center><input
type=button value=" NEW "
style="width:60; background-color:#eeeecc"
onClick="javascript:Init()"></td>
<td width=30% align=center><input
type=button value=" HELP "
style="width:60; background-color:#eeeecc"
onClick="javascript:Help()"
name="HelpButton"></td>
<td width=20% align=center><input
type=button value=" -> "
style="width:40; background-color:#eeeecc"
onClick="javascript:TurnRight()" title="turn board
right"></td>
</tr></table>
</td></tr>
<tr><td> </td></tr>
<tr><td>
<table border=0 cellpadding=0
cellspacing=0 width=100%><tr>
<td width=20% align=center><input
type=button value=" << "
style="width:35; background-color:#eeeecc"
onClick="javascript:Back();Back()" title="two moves
back"></td>
<td width=20% align=center><input
type=button value=" < "
style="width:35; background-color:#eeeecc"
onClick="javascript:Back()" title="one move
back"></td>
<td width=20% align=center><input
type=button
value=" "
style="width:35; background-color:#ffffff;
font-weight:bold" disabled name="Moves"></td>
<td width=20% align=center><input
type=button value=" > "
style="width:35; background-color:#eeeecc"
onClick="javascript:Replay()" title="one move
forward"></td>
<td width=20% align=center><input
type=button value=" >> "
style="width:35; background-color:#eeeecc"
onClick="javascript:Replay();Replay()" title="two
moves forward"></td>
</tr></table>
</td></tr>
</table>
</td>
</tr>
</table>
</DIV>
</form>
<script language="JavaScript">
Init();
setInterval("Timer()",400);
</script>
</BODY>
</HTML>
အဆင္ေျပပါေစေနာ္။ အားရင္ ဆက္တင္ေပးပါဦးမယ္။
Pyae Phyo ဘာညာကြိကြ