Make your own free website on Tripod.com

The Church of Universal Love and Music

 
 
 
 

Tic-Tac-Toe Source Code:

 <html>
<head><link rel="stylesheet" type="text/css" href="xpMenu.css">

<title>Tic-Tac-Toe</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<Style Type="Text/CSS">
Input{}
.blokje{
Height:48px;
Width:48px;
Font-Size:16pt;
Font-Weight:900;
Font-Family:Comic Sans MS,Arial,Verdana;
Text-Align:Center;
}
.knopje{
Width:144px;
}
</Style>
</head>

<body bgcolor="#FFFFFF">
<center>
<TABLE cellSpacing=0 cellPadding=0 width="82%" border=0 align:"center">
<TR>
<TD width="100%" align="center">
<p align="center">
<img border="0" src="images/churchlogo.jpg" width="125" height="125">
</p>
</TD>
</TR>
</TABLE></center>
<p align="center"><FONT face=Ravie color=#ff0000 size=5>The Church of Universal Love and
Music</FONT>
<FONT FACE="Tahoma"><br> </FONT></p>
<table width="700" border="0" cellspacing="0" cellpadding="0" align="center">
<tr> <td valign="top" width="245"> <table width="215" border="0" cellspacing="0" cellpadding="0">
<tr> <td colspan="3" height="28" background="images/menuup.gif"> <div align="center">
&nbsp;</div></td></tr> <tr> <td width="9" height="76" background="images/menuleft.gif">&nbsp;</td><td width="194" height="76">
<FONT FACE="Tahoma"><br><div>
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv">
<div class="topItem">Quick Links</div>
<div class="dropMenu1">
<div class="subMenu1" style="display:none;">
<span class="subItem1"><a href="frontdoor.htm">Home</a></span><br>
<span class="subItem1"><a href="calendar.htm">Goings On</a></span><br>
<span class="subItem1"><a href="churchinfo.htm">Church Info</a></span><br>
<span class="subItem1"><a href="past-events.htm">Past Events</a></span><br>
</div><!-- *******************************End Menu************************** -->
</div><div>
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv">
<div class="topItem">Mission</div>
<div class="dropMenu1">
<div class="subMenu1" style="display:none;">
<span class="subItem1"><a href="mission.htm">Mission Statement</a></span><br>
<span class="subItem1"><a href="comser.htm">Community Service</a></span><br>
<span class="subItem1"><a href="projects.htm">Projects</a></span><br>
</div><!-- *******************************End Menu************************** -->
</div><div>
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv">
<div class="topItem">Support</div>
<div class="dropMenu1">
<div class="subMenu1" style="display:none;">
<span class="subItem1"><a href="donate.htm">Donations</a></span><br>
<span class="subItem1"><a href="support.htm">Support</a></span><br>
<span class="subItem1"><a href="products.htm">Products &amp; Services</a></span><br>
</div><!-- *******************************End Menu************************** -->
</div><div>
<!-- *********************************Start Menu****************************** -->
<div class="mainDiv">
<div class="topItem">Fun Stuff</div>
<div class="dropMenu1">
<div class="subMenu1" style="display:none;">
<span class="subItem1"><a href="fungames.htm">Fun & Games</a></span><br>
<span class="subItem1"><a href="educate.htm">Self Education</a></span><br>
<span class="subItem1"><a href="contact.htm">Contact Us</a></span><br>
</div><!-- *******************************End Menu************************** -->
</div><br>
</div></FONT></td><td width="12" height="76" background="images/menuright.gif">&nbsp;</td></tr>
<tr> <td colspan="3" height="28" background="images/menudown.gif">&nbsp;</td></tr> </table><FONT FACE="Tahoma"><br>
</FONT></td><td width="455" valign="top">
<table width="455" border="0" cellspacing="0" cellpadding="0" background="images/longmenu.gif" height="34">
<tr> <td><b><font face="Arial" size="4">Fun &amp; Games</font></b></td></tr> </table>
<p>&nbsp;</p>
<P>&nbsp;<Center>

<Form>
<Input Type="Button" Title="Click here to play again" Name="beurten" Width="164px" Class="knopje" Value="Player 1" onClick="wie = 'Player 1'; initieer()">
<Table CellPadding="0" CellSpacing="0" Border="0">

<Script Language="JavaScript">
<!--//
for (i = 1; i < 10; i++) {
if (i % 3 == 1) {document.write('<Tr>');}
document.write('<Td><Input Type="Button" Name="' + i + '" Value=" " Class="blokje" onClick="wijzig(this.form,this)"></Td>');
if (i % 3 == 0) {document.write('</Tr>');}
}
//-->
</Script>

</Table>

<Input Type="CheckBox" Title="Click here to change from 2 players or computergame" Name="automaat" Value="2 players" Id="autmat" onClick="if (this.value == 'Computer') {this.value = '2 players'; auto = 0} else {this.value = 'Computer'; auto = 1}; wie = 'Player 1'; initieer();"><Label For="autmat">against the computer</Label>

<Table CellPadding="0" CellSpacing="0" Border="1">
<Tr BgColor="Silver">
<Td Align="Center"> Player 1 </Td>
<Td Align="Center"> Player 2 </Td>
<Td Align="Center"> Remise </Td>
</Tr>
<Tr BgColor="Silver">
<Td Align="Center"><Input Style="BackGround-Color:Transparent;Border:Solid 0px;Text-Align:Center" Type="Text" Size="3" ReadOnly Title="Player 1" Name="speler1" Value="0"></Td>
<Td Align="Center"><Input Style="BackGround-Color:Transparent;Border:Solid 0px;Text-Align:Center" Type="Text" Size="3" ReadOnly Title="Player 2" Name="speler2" Value="0"></Td>
<Td Align="Center"><Input Style="BackGround-Color:Transparent;Border:Solid 0px;Text-Align:Center" Type="Text" Size="3" ReadOnly Title="Remise" Name="remise" Value="0"></Td>
</Tr>
</Table>
</Form>
</Center>

<Script Language="JavaScript">

timerID = xtal = ytal = ztal = auto = 0;
wie = 'Player 1';

function initieer(){
clearTimeout(timerID);
cel = new Array(0,0,0,0,0,0,0,0,0,0);
aanv = new Array(); strat = verd = leeg = aanv;
beurt = wissel = 1; wint = keren = 0;
document.forms[0].speler1.value = xtal;
document.forms[0].speler2.value = ytal;
document.forms[0].remise.value = ztal;
if (wie != 'Start') {
for (i in cel) {
cel[i] = 0; if (i > 0) {document.forms[0].elements[i].value = ''};
}
}
document.forms[0].beurten.value = wie;
}

function zetten() {
clearTimeout(timerID);
if (aanv[0] > 0) {
slag = aanv[Math.floor(Math.random() * 10) % aanv.length]
} else if (verd[0] > 0) {
slag = verd[Math.floor(Math.random() * 10) % verd.length];
} else if (strat[0] > 0) {
slag = strat[Math.floor(Math.random() * 10) % strat.length];
} else {
slag = leeg[Math.floor(Math.random() * 10) % leeg.length];
}

if (beurt == 0 && slag > 0) {document.forms[0].elements[slag].click()};
}


function win() {
if ( cel[1] + cel[2] + cel[3] == 3 ||
cel[4] + cel[5] + cel[6] == 3 ||
cel[7] + cel[8] + cel[9] == 3 ||
cel[1] + cel[4] + cel[7] == 3 ||
cel[2] + cel[5] + cel[8] == 3 ||
cel[3] + cel[6] + cel[9] == 3 ||
cel[1] + cel[5] + cel[9] == 3 ||
cel[3] + cel[5] + cel[7] == 3
) {

if (confirm("Player 1: You win !!!\nDo you want to play again?"))
{
wint = 1;
xtal++; wie = 'Player 1'; timerID = setTimeout('initieer()',800)
} else {
xtal++; wie = 'Start'; timerID = setTimeout('initieer()',800)
};
}
if ( cel[1] + cel[2] + cel[3] == 30 ||
cel[4] + cel[5] + cel[6] == 30 ||
cel[7] + cel[8] + cel[9] == 30 ||
cel[1] + cel[4] + cel[7] == 30 ||
cel[2] + cel[5] + cel[8] == 30 ||
cel[3] + cel[6] + cel[9] == 30 ||
cel[1] + cel[5] + cel[9] == 30 ||
cel[3] + cel[5] + cel[7] == 30
) {
if (confirm(((auto == 1) ? ('Computer wins, sorry') : ('Player 2: You win !!')) + "!\nDo you want to play again?")) {
ytal++; wie = 'Player 1'; timerID = setTimeout('initieer()',800)
} else {
ytal++; wie = 'Start'; timerID = setTimeout('initieer()',800)
};
}
}

function wisselen(beurt){
if (wissel == 1) {
if (beurt == 0) {
beurt = 1;
wie = "Player " + 1
}
else {
if (auto == 0) {beurt = 0;
wie = "Player " + 2} else {beurt = 0; wie = "Computer";}
}
if (keren == 9
) {
if (confirm("Remise!!!\n\nDo you want to play again?")) {
ztal++; wie = 'Player 1'; timerID = setTimeout('initieer()',800)} else
{ztal++; wie = 'Start'; timerID = setTimeout('initieer()',800)};
}

}
else {
beurt = beurt;
}
wissel = 1;
return(beurt);
}

function wijziging(klik) {

plek = cel[klik]; geklikt = klik;

if (plek == 0){
if (beurt == 0){
xo = "O";
plek = 10;
} else {
xo = "X";
plek = 1;
}
cel[klik] = plek; keren++;
}
else {
if (plek == 10){
xo = "O";}
if (plek == 1){
xo = "X";}
wissel = 0
}
return(xo);
}

function verdedig() {leeg = new Array(); verd = new Array();
for (i = 1; i < 10; i++) { oud = cel[i]; cel[i] = 1;
if ( (cel[1] + cel[2] + cel[3] == 3 ||
cel[4] + cel[5] + cel[6] == 3 ||
cel[7] + cel[8] + cel[9] == 3 ||
cel[1] + cel[4] + cel[7] == 3 ||
cel[2] + cel[5] + cel[8] == 3 ||
cel[3] + cel[6] + cel[9] == 3 ||
cel[1] + cel[5] + cel[9] == 3 ||
cel[3] + cel[5] + cel[7] == 3) && oud == 0
) { verd[verd.length] = i}
cel[i] = oud;
if (cel[i] == 0) {
if (keren != 1) {leeg[leeg.length] = i} else
if (cel[5] == 0) {leeg[0] = 5; leeg[1] = 10 - geklikt} else
if (i % 2 != 0) {leeg[leeg.length] = i}
};
}
}

function aanval() {aanv = new Array();
for (i = 1; i < 10; i++) { oud = cel[i]; cel[i] = 10;
if ( (cel[1] + cel[2] + cel[3] == 30 ||
cel[4] + cel[5] + cel[6] == 30 ||
cel[7] + cel[8] + cel[9] == 30 ||
cel[1] + cel[4] + cel[7] == 30 ||
cel[2] + cel[5] + cel[8] == 30 ||
cel[3] + cel[6] + cel[9] == 30 ||
cel[1] + cel[5] + cel[9] == 30 ||
cel[3] + cel[5] + cel[7] == 30) && oud == 0
) { aanv[aanv.length] = i}
cel[i] = oud;
}
}

function strategie() {strat = new Array();
for (i = 1; i < 10; i++) { oud = cel[i]; cel[i] = 10;
if ( (cel[1] + cel[2] + cel[3] == 20 ||
cel[4] + cel[5] + cel[6] == 20 ||
cel[7] + cel[8] + cel[9] == 20 ||
cel[1] + cel[4] + cel[7] == 20 ||
cel[2] + cel[5] + cel[8] == 20 ||
cel[3] + cel[6] + cel[9] == 20 ||
cel[1] + cel[5] + cel[9] == 20 ||
cel[3] + cel[5] + cel[7] == 20) && oud == 0
) {
if (keren != 3) {strat[strat.length] = i} else if (i % 2 != 0) {strat[strat.length] = i}
}
cel[i] = oud;
}
}

function wijzig(form,element){
wijziging(element.name);
element.value = xo;
beurt = wisselen(beurt);
form.beurten.value = wie;
verdedig(); aanval(); strategie(); win();
if (auto == 0 || wint == 1) {return} else {
timerID = setTimeout('zetten()',600)
}
}

initieer();

</Script></P>
<p align="left">&nbsp;</p>
<p align="right"><FONT FACE="Tahoma">&nbsp;</FONT></p><p align="right">&nbsp;</p></td></tr>
<tr> <td valign="top" width="245"> &nbsp;</td><td width="455" valign="top">
&nbsp;</td></tr> </table><FONT FACE="Tahoma"><br> </FONT><table width="700" border="0" cellspacing="0" cellpadding="0" align="center">
<tr> <td> <div align="left"></div><DIV ALIGN="CENTER"><FONT SIZE="2" FACE="Tahoma">Copyright
2006 The Church of Universal Love and Music. All Rights Reserved</FONT></DIV><TABLE WIDTH="700" BORDER="0" CELLSPACING="0" CELLPADDING="0" HEIGHT="20" ALIGN="center">
<TR BGCOLOR="#000000"> <TD BGCOLOR="#336666"><DIV ALIGN="center">&nbsp;</DIV></TD></TR> </TABLE></td></tr>
</table><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-676573-1";
urchinTracker();
</script><script type="text/javascript" src="xpMenu.js"></script>
</body>
</html><center>
<span style="width: 100%; font-family: helvetica; font-size: 6px; Filter: Alpha(Opacity=0,FinishOpacity=0, Style=1);">
&nbsp;</span></center><br><br>


 


Copyright 2006 The Church of Universal Love and Music. All Rights Reserved