Click to see a tutorial on how to play the game of ISOLATION Tutorial v5
Programming example : Play Isolation below (if you play, please fill out the opinion survey)
Note: Isolation v1.019s is a special SCHOOL version that runs from my website. It disables the New Game & Exit buttons. They will not run correctly when running on the webpage over the internet. Works when the code is installed on your computer. If you want a copy, ask Mr. Y.
View source code below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" >
<!-- .scorearea score area (upper right corner -->
<!-- .resultsarea is textarea where results go. right above input area -->
<!-- .inputBoard is textarea input for -->
<!-- .inputBoard is textarea input area -->
<style type="text/css">
textarea#tasa {
color: white;
font-size:115%;
font-size:80%;
font-weight:bold;
border-style:solid;
border-width:3px;
border-color: darkblue;
background-color: darkblue;
}
.textareaOut {
color: darkblue;
font-size:125% ;
font-weight:normal;
border-style:inset;
border-width:4px;
background-color:silver;
}
.pcsForm{
color:darkgreen;
color:blue;
font-weight: bold;
font-style:italic;
background-color: silver;
background-color: #AAD4AA;
background-color: #A0C0A0;
}
.inputName {
color: blue;
line-height: normal;
font-size:75%;
font-weight:normal;
border-style:inset;
border-width:2px;
width: 70px;
width: 50px;
height:18px;
resize:none;
background-color: lightgray;
background-color:silver;
}
.scorearea {
color: black;
line-height: normal;
font-size:115%;
font-weight:normal;
font-weight:bold;
border-style:inset;
border-width:3px;
width: 55px;
height:15px;
resize:none;
background-color:darkblue;
background-color:silver;
}
.scoreareaLong {
color: white;
line-height: normal;
font-size:115%;
font-weight:bold;
font-weight:normal;
border-style:inset;
border-width:3px;
border-color:white;
width: 120px;
height:15px;
resize:none;
background-color:darkblue;
background-color:silver;
}
.scoreareaMedium {
color: green;
line-height: normal;
font-size:115%;
font-weight:bold;
border-style:inset;
border-width:2px;
width: 50px;
height:14px;
resize:none;
background-color:darkblue;
background-color:silver;
}
.scoreareaShort {
color: green;
line-height: normal;
font-size:115%;
font-weight:normal;
border-style:inset;
border-width:2px;
width: 30px;
height:14px;
resize:none;
background-color:darkblue;
background-color:silver;
}
.scoreareaVeryShort {
color: green;
line-height: normal;
font-weight:normal;
border-style:inset;
border-width:2px;
width: 22px;
height:15px;
resize:none;
background-color:darkblue;
background-color:silver;
}
.resultsarea {
color: darkblue;
font-size:125% ;
/* font-size:75% ;*/
font-weight:normal;
border-style:inset;
border-width:4px;
background-color: silver;
}
.resultsareaRed {
color: red;
/* font-size:75% ;*/
font-weight:bold;
border-width: 2px;
background-color: silver;
}
.inputBoard {
color:white;
font-size:200% ;
font-size:175% ;
font-weight:bold;
background-color: #AAD4AA;
background-color: #A0C0A0;
background-color: #8eb5a7; /* @066 */
background-image: none;
border-style:inset;
border-width:2px;
margin:2px 0px 2px 0px; /* top,Right,Bottom,Left
width: 75px;
height:75px;
width: 65px;
height:65px;
width: 14px;
height:18px;
}
h2 { color:navy;
text-decoration:underline;
}
imh { color:navy;
text-decoration:underline;
font-size:120% ;
font-weight:bold;
color: darkgreen;
font-style: italic;
}
.fieldset {
display: block;
margin-left: 2px;
margin-right: 2px;
padding-top: 0.35em;
padding-bottom: 0.625em;
padding-left: 0.75em;
padding-right: 0.75em;
border-style: double;
border-color:darkgreen;
border-width:3px;
width: 750px;
width:300px;
font-size: 125%;
}
</style>
</head>
<BODY BGCOLOR="#A0C0A0"
STYLE=' font-family:"Space Mono","Sans Mono",monospace,Bitstream, Vera,Monaco, Lucida, Consolas,"DejaVu Sans Mono","Courier New" '; OnLoad="init()" >
</Body>
<title> ISO Version 1.018 06-30-2021 </title>
<script type="text/javascript" >
/* darkseagreen like original color in VB
lightGreen
FF66FF pink
lightblue original Javascript
silver
AAD4DD light green (a little lighter than darkseagreen
A0C0A0
FAD8D8 pink for squares
*/
/* <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> */
/********************************************************************/
/* */
/* BGCOLOR */
/* #A0C0A0 Spring Rain - like seafoam green */
/* #72A4D2 Jody Blue - darker baby blue */
/* #8EB5A7 Sea Nymph - used as dot color in radio buttons */
/* */
/********************************************************************/
/*****************************************************/
/* form body stmt */
/* use class="" in HTML tag for .name */
/* */
/* use id="" in HTML tag for #name */
/* */
/*****************************************************/
/*****************************************************************************/
/* */
/* INIT */
/* - getComputersMove() */
/* */
/* = ckHaveMove */
/* = ckAround */
/* */
/* foc (invoked whan a square is clicked) */
/* -ckIfUnoccupied() (return 1-legal 0 illegal) */
/* -ckIfValidMove() (return 1-legal 0 illegal) */
/* -ckMove2 (within 1 square) */
/* -ckHaveMove() return y or n */
/* -ckIfGameOver() */
/* -putFormFields() */
/* */
/* */
/*****************************************************************************/
/*******************************************************************************/
/* */
/* Author: Tom Yurkovic tomyy@optonline.net */
/* */
/* 1979 start on TRS-80 TRS DOS */
/* 1982 convert to run on IBM DOSstart on TRS-80 */
/* 1990 rewrite in Visual Basic 6 but only 2 players not play against */
/* computer start on TRS-80 */
/* 20nn rewirite in Javascript & HTML 2 player only */
/* 10/2011 v0.053c first beta release */
/* */
/* High level overview of the logic the program uses to calculate moves/ */
/* removes, and determines if squares are empty or occupied. */
/* Key to how the game works programatically is: */
/* you have a 2 dimensional array board(row,col) whose valuse can be: */
/* */
/* -2 if the square is removed & was removed bt player2 */
/* -1 - if the square is removed & was removed by player1 */
/* 0 - in which case the square is empty */
/* 1 - if the square is occupied by player1 (x) */
/* 2 - if the square is occupied by player2 (o) */
/* */
/* The program uses this info to know if the sq you click on is empty or not */
/* The program uses this info to decide what sq to move/remove */
/* */
/* */
/* */
/* change history: */
/* */
/* chng date version change description */
/* ---- -------- -------- -------------------------------------------------- */
/* @002 mm/dd/yy v0.018as */
/* @003 01/27/20 v0.019as First pass to get to play against the computer. */
/* Also added valuWy & valuWn arrays. valu[][] will */
/* set to eith valuWy or valuWn. This is another */
/* way for the computer to determine a move based */
/* on the valu[][] of adjacent squares. If wrap=y, */
/* then the corners are the best/highest valu if */
/* wrap=n then the middle is better and avoid */
/* edges & corners with low values */
/* */
/* @004 02/27/20 v0.021 Pass 2 Iteration 1 to play against the computer. */
/* Added code to the following functions */
/* - ckIfUnOccupied */
/* - ckValidMove */
/* added if stmt replace en = entered.name to */
/* en = compsMove (format is r## ex r32) if */
/* pac == Y && whoseTurn=comp */
/* compsMove is a Global Variable */
/* @005 2/28/20 v0.022 Pass 2 Iteration 2 added retMoveG as global */
/* */
/* @006 3/4/20 v0.031 Pass 3 Iteration 1 Change in way board is changed */
/* when computer moves then blanks out a sq. */
/* Used to go through foc, now will get called to */
/* do the work in its own function that gets called */
/* after the human */
/* @007 3/9/20 v0.032 Pass 3 Iteration 2 Change in way board is changed */
/* 3/14/20 v0.033 Pass 3 Iteration 3 Added lookahead levels */
/* known by levelDif call 1-countAround1, */
/* 2-countAround2, 3-countAround3 */
/* 3/21/20 v0.034 Pass 3 Iteration 4 if board[][] =0 skip it when */
/* wrap = y . Works for levelDif=1 */
/* 3/22/20 v0.035 Pass 3 Iteration 5. wok on getting levelDif2-4 */
/* 3/31/20 Iteration 6 last iteration for pass 3 */
/* 4/01/20 v0.036 Pass 1 */
/* 4/02/20 v0.037 Pass 1 start gameLog */
/* 4/01/20 v0.038 made moveFromSqName global */
/* added saveRemoved & saveFrom global */
/* 4/05/20 v0.040 added gameLog & button */
/* 4/08/20 v0.041 start to allow scoring pts for removig a sq */
/* 4/09/20 v0.042 start to allow scoring pts for removig a sq */
/* 4/11/20 v0.043 fixed error in countAround1,2,3,4 */
/* 4/12/20 v0.044 plas as base code for beta1 release. Will test */
/* & fix, no new function planned. */
/* 4/14/20 v0.045 add tot/ave of sq of valu[][] array,start init2 */
/* 4/15/20 v0.046 @010 added availSqCount is decreased by 1 */
/* remSqCount increase by 1 when computer removes sq */
/* 4/20/20 v0.047 move availSqCount/remSqCount to the routine */
/* that removes sq from board. set2Removed() */
/* Added console.log msg when hum turnNumber ends & */
/* when computers turn ends says nbc= nnn where */
/* nbc=Number Board Checks */
/* 4/20/20 v0.048 remove Prompts from init , play against comp or */
/* human go first or enter human name @011 */
/* 4/24/20 v0.049 add whoe goes first to initform @012 */
/* */
/* m/dd/yy v0.050 some cleanup-bigger font size on dashboard& sgOS */
/* */
/* 5/05/20 v0.051 Form n1 changed onBlur to onChange() */
/* */
/* m/dd/yy v0.052 color options for x o withing javascript code */
/* */
/* 12/21/20 v0.054 first beta release */
/* 12/21/20 v0.054 Font slightly bigger on status lod turn# @014 */
/* wrap,#players this version on school mypage */
/* changed height:20px; to 22 to get rid of arrrows */
/* Also made important msg below are 2 lines since */
/* we added a msg ther saying save game options */
/* updated successfully */
/* */
/* m/dd/yy v0.054 color options for x o withing javascript code */
/* */
/* 12/24/20 v0.060 isol360-88 8 rows 8 cols */
/* 12/26/20 v0.061 isol360-88 chaged size=1 to 0 in board def */
/* class inputBoard */
/* from */
/* 12/31/20 v0.062 commented out in loadValuArray 1st 2 console.log */
/* statements & fiexd typi ij instead of ii */
/* Removed alert for invalid move. Need to add */
/* sound */
/* from */
/* 01/02/21 v0.063 commented out images bcirc2 & rcirc2 */
/* */
/* 01/02/21 v0.064 tried to add sound...coundnt get to work */
/* */
/* 01/04/21 v0.065 Change color of errmsg in document.Form.out */
/* 2 new functions redBorder() blueBorder */
/* use getElementsById(resultsarea) */
/* 01/05/21 v0.066 Commented out alert that cause a popup for */
/* illegal move during game. Instead have msg */
/* appear in resultsarea in w/red bkground/border */
/* Also some minor fixes and changed */
/* inputForm background-color to #8eb5af from A0C0A0 */
/* Always change inputForm background-color and */
/* javaScript blankColor to be the same */
/* 01/06/21 v0.067 minor fixes */
/* 01/07/21 v0.068 added code to sgOS & gamesoPtionsForm to allow */
/* the user to change the color or removed square */
/* var colorRemove to any color usig a color picker */
/* Also added */
/* <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" */
/* "http://www.w3.org/TR/html4/strict.dtd"> */
/* Also added after <head> a meta tag : */
/* <meta http-equiv="content-type" content="text/html;*/
/* charset=utf-8" /> */
/* 01/08/21 v0.069 created color picker element chngbgcolor */
/* removed function vv(entered) not used */
/* 01/08/21 v0.070 created color picker element chngboardcolor */
/* 01/11/21 v0.071 allow user to change the color of X & O & change */
/* that represents player1 (x) & player2 (o) */
/* 01/12/21 v0.072 only allow user to change player1/2 and board colo */
/* if the game hasn't started yet. ie turnNumber=1 */
/* 01/12/21 v0.073 changed class of textarea.out from resultsarea to */
/* textareaOut. Ther CSS change to scorearea, */
/* scoreareashort & scorearealong font-size & height */
/* 01/12/21 v0.074 When game is over , put game over message in */
/* textareaOut in big font & bold */
/* 01/13/21 v0.075 Put msg to textarea.out when player name or */
/* character changes. Call pCharNameChanged("","") */
/* from onChange in the input definition on Form for */
/* name & character . 1st parm 1 or 2 (player#) */
/* 2nd parm C or N (char or Name */
/* ex: pCharNameChanged("N",1) set Name for player 1 */
/* 01/21/21 v0.076 beta2 Move the spot where you can change the char */
/* & name from on top in Dashbord, to below in */
/* setGameOptions */
/* 01/22/21 v0.077 Added ability to change the board size to */
/* 1 of 5 pre determined sizes in an array */
/* ibHeight[] ibwidth[] with the default valu */
/* in array element 1. Also added .fieldset css */
/* 01/24/21 v0.078 fieldset changed margins for .inputBoard */
/* From: margin:3px 0px 3px 0px; */
/* To: margin:2px 0px 2px 0px; */
/* font-size from 200% to 175% */
/* Move Importand Message box - textarea up */
/* just below the gameboard, and the buttons to below */
/* this important message box. */
/* 01/25/21 v0.079a Major dashboard change, streamlined it. */
/* removed redundent items & shortened & changes */
/* CSS scorearea, scoreareaShort, scoreareaLOng & */
/* inputName to have a silver background & shorter */
/* length. Added nbc(number of board checks to */
/* to dashboard. */
/* 01/28/21 v0.080m Make board sizes smaller for 4" screens */
/* Also, try to make nbc (Number of Board Checks) */
/* more accurate. */
/* 02/24/21 v0.082m fix case valuWn1a to valuwy1a */
/* 02/24/21 v0.083m fixed helpem */
/* 02/25/21 v0.084 changed ibHeight ibWidth array, removed initform */
/* changed x o char back to x & o instead of char(n) */
/* 02/26/21 v0.085 added call to initValuArray from sgOs() */
/* 03/01/21 v0.086 corrected spacing when showing a hint so things */
/* line up nicely. in showAround() */
/* 03/04/21 v0.087 changed pto use the entire sq as the player char */
/* if the 1st 3 char of playerChar[whoseturn] is' ' */
/* 03/04/21 v0.088 added pcsForm & corresponding css .pcsForm */
/* changed char selection fron inputbox to a sel box */
/* added about 17 items to selection list. */
/* The selections are the numbers for use in the */
/* string.fromCharCode(n) which results in a graphic */
/* Fixed bu in redBorder. Changed */
/* document.getElementsByClassName(resultsarea) to */
/* document.getElementsByClassName(textareaOut) */
/* 03/11/21 v0.089 added code to place a dot the color of x in the */
/* squares that are a valid move to. */
/* hint puts therm there. They are removed in foc */
/* when a player clicks a sq to move to. */
/* An Global array surroundingEmpytSq[] Global */
/* noess Num Of Empty Surrounding Squares. 0th */
/* element gives no of elements in array. Each elem */
/* contains r## wher ## is row, col of empty square */
/* 03/15/21 v0.090 added code to place score on dashboard. Added */
/* pt1 & pr2 on dashboard, value comes from */
/* ptsTotal[1] & ptsTotal[2] respectively */
/* 03/17/21 v0.091 attempting to fix not removing x or o after a move */
/* in blankMoveFromSq() added getelementById & set */
/* enterd.value = "" */
/* 03/18/21 v0.092 fix change char/char color to not just change */
/* positions 3,1 or 4,8 but find out where they are */
/* and change that position */
/* 03/24/21 v0.093 added levelDiff=5 cleanup of many console.log */
/* writes as thei level goes deep. */
/* 03/26/21 v0.094 added bonus pts to ptsTotal[winnningPlayer for */
/* isolating his opponent. Pts depend on levelDif */
/* Award 10^(level) or 10 100 1,000 10,000 100,000 */
/* 04/05/21 v0.095 Play Again or New Game */
/* without clicking it again on the desktop to start. */
/* set document.location.href = ""; to nulls */
/* */
/* Also changed Quit button to Exit which now issues */
/* window.close() which closes game & tab */
/* 04/08/21 v0.096 added sm & ml more board sizesso choices are now: */
/* xs s sm m ml l xl */
/* set document.location.href = ""; to nulls */
/* 04/12/21 v0.097 new board 8 rows 9 cols */
/* if row or col > 9 then muct change addiitional */
/* logic in getRC(). Quite a few changes in ckMove2() */
/* Also changed hardcoded 63 to totSq-1 for 8x9 board */
/* 04/14/21 v0.098 fix in ckAround & showAround when wrap=n */
/* Its not checking col 9 (cking if <9 & should be */
/* <= 9 or <= numCols */
/* 04/20/21 v0.098f1 fix in ckAround.When maxValue=0(meaning no */
/* empty sq around to remove). This cause a hang. */
/* Fix is when maxValu=0 to list all empty sq in */
/* the pcc[] ar randomly pic one between 1 & noTies */
/* 04/29/21 v0.098f2 fix in game over. set playerName[] to len 1 */
/* */
/* 04/30/21 v1.001-AR AutoRemove the square you moved from for Computer */
/* 05/05/21 v1.002-AR AutoRemove the square you moved from for Human */
/* 05/06/21 v1.003-AR added autoRemove status to dashboard, */
/* removed Form.np #players */
/* 05/07/21 v1.004-AR added option to set Start Position for x & o */
/* created function setStrtPos */
/* 05/10/21 v1.005-AR continuation to get tis new function in */
/* 05/12/21 v1.006-ar add eleays to computer move. It moves too fast */
/* at lower levelDif */
/* v1.006f changed documentForm.r41.style.color = colorX to */
/* documeny.getElementById(moveFrom[1]).style.color */
/* Also did for moveFrom[2] for colorO */
/* 05/13/21 v1.007-ar html changes at botton of screen. Reduced from */
/* on menu instead of 2. moved /selection from */
/* form=pcsForm to gameOptionsForm */
/* 05/14/21 v1.008 removed -ar from version as autoRemove is now */
/* an option instead of a special version. */
/* 05/17/21 v1.009 fix , computer going first didn't work. */
/* */
/* 05/18/21 v1.010 change game over alert box to window . */
/* 05/19/21 v1.011 added elapsed time & #moves to gameOverWindow. */
/* 05/20/21 v1.011.f1 found problem, for x at 41 hint shows * in . */
/* 31,32,32,42,52,38,,48,58 */
/* 05/20/21 v1.011.f2 If a special name is entered color & char are */
/* automatically set and dashboard updated but the */
/* char/symbol on gameOptionsForm wasnt upated. */
/* This code fixes that error situation. */
/* 05/26/21 v1.012 removed et.toFixed(2) fix to gamesummary being */
/* cutoff after endTie. */
/* 06/10/21 v1.013 the help button was not appearing under the game */
/* board. Input was missing "<". */
/* Also changed width of Important Message Below box */
/* by changing <textarea name=out rows=4 cols=80 */
/* to: <textarea name=out rows=4 cols=84 */
/* 06/15/21 v1.014 added id=ibm to textareaOut in case I need to */
/* getElementById. */
/* - Also, when game is over, put that into the */
/* put that into the important mg box too. */
/* - Removed font-size=75 from resultsAreaRed/Blue */
/* because it shortened the with of the area when */
/* in redBorder() or blueBorder(). */
/* - In getComputersMove changed hasAMove to hasMove */
/* - Made the font color the same as the player color*/
/* when we put the Game Over msg into the */
/* Important Msg Box showing the winning player */
/* name/character & color. */
/* 06/16/21 v1.015 made the help button larger and green letters on */
/* a white background so it stands out better. */
/* 06/23/21 v1.016 move the call to gameOverWindow from before */
/* we write Game OVer in Important Msg Box to after. */
/* 06/24/21 v1.017 fix in ckMove2 It allowed a move fro 18 to 67 */
/* because of case 5 ib ckMove2. Removed it. */
/* 06/30/21 v1.018 added more checking on user input for set a new */
/* starting position. Put additional error msgs */
/* into console log and Importnt Msg Area */
/* v1.019 */
/* */
/* */
/*******************************************************************************/
var ver = "1.019"; /* Version */
var trace = "N";
if(trace == "Y")
alert("is declares ISOL ver:" +ver);
dte = new Date();
mm = dte.getMonth();
mm = mm-0;
mm = mm+1;
dd = dte.getDate();
yyyy = dte.getFullYear();
todays_date = mm +'/' + dd + '/' + yyyy;
var startDte = new Date();
var startTime = startDte.getHours() + ":" + startDte.getMinutes() + ":" + startDte.getSeconds();
var strtTime = new Date().getTime();
var elapsedTime = 0; /* @1.003 */
var et = 0; /* @1.003 */
var temp = 0; /* @1.003 */
var endDte = new Date();
var endTime = endDte.getHours() + ":" + endDte.getMinutes() + ":" + endDte.getSeconds();
/************************************************************************/
/* */
/* */
/* GLOBAL Variables */
/* variables defined here are global */
/* */
/************************************************************************/
var hdr1="";
var hdr2="";
var trail1="";
var trail2="";
var outputLine = new Array();
var bvTotal = 0; /* board Valu sum all 48 to 64 for 8x8 sq of valu[][] */
var bvAverage = 0; /* board Valu Average value of a sq */
var nbc = 0; /* Number Board Checks */
/************************************************************************/
/* */
/* Board is 6 row 8 col array (0-47) */
/* 8 8 0-63 @0.060 */
/* 8 9 0-71 @0.097 */
/* */
/* -2 - removed square (by player 2) */
/* -1 - removed square (by player 1) */
/* 0 - unoccupied space */
/* 1 - occupied by player 1 */
/* 2 - occupied by player 2 */
/* */
/* */
/************************************************************************/
var entrd; /* like entered passed to foc, this is for computers move @006a */
var numRows = 8; /* @0.060 */
var numCols = 9; /* @0.097 */
var totSq = numRows * numCols; /* @0.060 */
var row = 0;
var col = 0;
var rowG = 0;
var colG = 0;
glc = 1; /* Game Log Count written from write2gameLog() */
/* cols 1 2 3 4 5 6 7,8,9 10 */
/* turn# whoseTurn playerChar moveFrom moveTo RemSq ? ? ? msg */
gameLog = new Array();
for (i=0; i<2; i++)
{ gameLog[i] = new Array(10); }
var retVal = ""; /* used in GetRC, this var is populated & returned @005a */
var board = new Array(); /* board[][] array */
for (i=0; i <numRows+1; i++) /* @0.060 */
{ board[i]=new Array(9);
}
for (i=1;i<=numRows; i++)
{ for(j=1; j<=numCols; j++)
{ board[i][j] = 0;
}
}
board[4][1]=1; /* player 1 starts here @0.060 */
board[5][9]=2; /* player 2 starts here @0.060 & 0.097 */
/***************************************************************************************/
/* values for valu array gets set to either valuWy or valuWn initialized to all 1's */
/***************************************************************************************/
var valu = new Array(); /* this array gets set to either val valuWn */
for (i=0; i < numRows+1; i++) /* removed +1 from this loop */
{ valu[i]=new Array(numCols+1); /* @0.097c was new Array(9) changed to numCols+1 */
}
for (i=1;i <= numRows; i++) /* numRows or nusRows + 1 */
{ for(j=1; j<=numCols; j++)
{ valu[i][j] = 0; /* init all values to 1 */
}
}
/***************************************************************************/
/* */
/* This creates the valu[][] board array for Wrap=Yes */
/* */
/* It will be initialized later, as the last one listed here is used */
/* */
/***************************************************************************/
/* values for Wrap Allowed valuWy1a some error here*/
var valuWy = new Array(); /* this array gets set to either valuWy or valuWn */
for (i=0; i < numRows+1; i++) /* @0.060 */
{ valuWy[i]=new Array(9);
}
/* Level 1a - Beginner No Wrap yields same as count */
/* values for No Wrap Allowed valuWn1a */
var valuWn = new Array(); /* this array gets set to either valuWy or valuWn */
for (i=0; i < numRows+1; i++) /* @0.060 */
{ valuWn[i]=new Array(9);
}
/* Level 1b - Beginner No Wrap looses on 9th move */
/* values for No Wrap Allowed valuWn1c */
/* Level 1c - Intermediate No Wrap */
/* values for No Wrap Allowed valuWn1b */
var timesCalledlvv = 0;/* track how mant Times Called logValuVars */
var pcc = new Array(); /* Possible Computer Choice */
var noTies = 0; /* Number Of Ties -> 0th elem */
var playerOptions;
var comp = 2 ; /* computer turn#,human is 1 */
var human;
var pac = "Y" ; /* Play Against Computer ( Y or N ) */
var goesFirst = 1; /* Player 1 goes first by default */
var goesSecond = 2;
var whoseTurn = goesFirst;
var otherTurn = "";
var compsMove; /* holds r## ex r32, for sq to move to or remove if pac==Y */
var compsRemove; /* holds r## ex r33, for sq to Remove */
var retMoveG; /* holds retMove from ckAround as sq to remove @005a */
var moveIs; /* Moved from getComputersMove was local there made global @004 */
/* Level of Difficulty */
/* 1=beginner (use board values for valu[][] 1 level out */
/* 2=easy (use board valu[][] 2 levels out */
/* 3=Intermediate count squares 1 level out */
var levelDif = 1; /* 4 Advanced count squares 2 levels out */
var numberOfPlayers = 1; /* Number of Players , if 1, play against computer */
var turnNumber = 1; /* turn number in game - probably max is 46 */
var reqAction = "M"; /* Default to M-Move To a Sq after we move we set it to R */
var wrapAllowed = "Y"; /* Allow wrap around */
var rDif;
var cDif;
var rowDif;
var colDif;
var savei;
var savej;
var maxValu =-1; /* max value found of all adjacent squares */
var cp = 0; /* Computer Picks a random number between 1 & noTies */
var gameOver = "N"; /* @003a */
var hasMove = ""; /* need this so we can corectly say who wins when its suicide*/
var whoDoesntHaveMove = "";/* the player number of plaer you cked if they had a move */
var winningPlayer; /* need to see if loosing player is = whoseTurn or otherTurn */
var moveFrom = new Array();
moveFrom[0]= 2;
moveFrom[1]= "r41"; /* @0.060 */
moveFrom[2]= "r59"; /* @0.060 r58 to r59 @0.097c */
var newFrom;
var moveTo = new Array();
moveTo[0]= 2;
moveTo[1]= "";
moveTo[2]= "";
var moveFromSqName = " "; /* Added to remember this for gamelog @008 */
var saveTo = new Array(); /* Added new global var @008 */
var saveFrom = new Array(); /* Added new global var @008 */
var saveRemoved = new Array(); /* Added new global var @008 */
var nsc = 0; /* Number of sq cks */
var compPtsThisTurn = 0 ;
var compPtsTot = 0 /* Computer Points Total */
var ptsTotalPrevious = 0;
var ptsThisTurn = new Array();
var ptsTotal = new Array();
for(i=0; i <=2; i++)
{ ptsThisTurn[i] = 0; /* init all values to */
ptsTotal[i] = 0;
}
var compPts = 0 ;
/******************************************************/
/* 2-dimensonal array pts[turnNumber][playerNumber] */
/* 1-72 1-2] */
/******************************************************/
var pts = new Array();
for (i=0; i <= totSq; i++) /* @0.060 @097c 64-80 */
{ pts[i]=new Array(2);
}
for(i=0;i<= totSq;i++) /* @0.060 cound mak numRows*numRows & @097c 64-80*/
{for (j=0;j<=2; j++)
pts[i][j]=0;
}
var turnCount = new Array(); /* count turn for each player */
turnCount[0] = 2;
turnCount[1] = 0;
turnCount[2] = 0;
var turnName = new Array();
turnName[0]= 2;
turnName[1]= "player1";
turnName[2]= "player2";
var playerName = new Array();
playerName[0]= 2;
playerName[1]= "player1"; /* ptn = Player Turn Name form field name */
playerName[2]= "player2";
var xChar = " X";
var oChar = " O";
/* @084d
xChar = " " + String.fromCharCode(8718);
oChar = "" + String.fromCharCode(10084);
*/
/* var ptc = printChar var for Player Turn Char- char of player whose turn it is */
var playerChar = new Array();
playerChar[0]= 2;
playerChar[1]= xChar; /* ptc = Player Turn Character form field name */
playerChar[2]= oChar;
var blankChar = " ";
var removeChar = " ";
var printChar = xChar; /* Default is player1 is X & goes first */
var colorX = "blue"; /* Default color for X */
var colorO = "red"; /* Default color for O */
colorRemove = "white";
colorBlank = "#A0C0A0"; /* should be same as inputForm backgroundColor @ 066 */
colorBlank = "#8eb5a7"; /* @ 066 */
var color = new Array();
color[0]= 2;
color[1]= colorX;
color[2]= colorO;
var image = new Array();
image[0]= "none";
image[1]= "Y"; /* "url(bcirc2.gif)" Player 1 gif @063 */
image[2]= "Z"; /* "url(rcirc2.gif)" Player 2 gif @063*/
image[1]= "Y"; /* "url(Rhys.gif)" Player 1 gif @063 */
image[2]= "Z"; /* "url(Aiden.gif)" Player 2 gif @063*/
var foundRBN = 99; /* found Radio Button Number 0=x, 1=O, 2=blank 3=remove */
var remSqCount = 0; /* rs = form field name for # removed squares */
var availSqCount= totSq-2; /* as = form field name for # available squares @0.060 */
var p1TurnCount = 0;
var p2TurnCount = 0;
var p1Name = ""; /* n1 form field name for player name1 */
var p2Name = ""; /* n2 form field name for player2 name */
var c1 = ""; /* form field name for player1 character */
var c2 = ""; /* form field name for player2 character */
var i = 1; /* row */
var j = 1; /* col */
var k = 1;
var l = 1;
var len = 0;
var temp;
var errmsg = "";
var warnmsg = "";
var warning = "N";
var winMsg="";
var cssEvNum = 1;
var loopCtr;
var temp;
var nlo; /* Numberof Linesof Output */
var ol=1; /* Output Line */
var rc = 0;
var tempvar = 0;
var tempvar2 = 0;
var errfnd;
var tr=0;
var timesCalled = new Array(); /* ele1- for countaround1...5-for counAround5 */
timesCalled[1]=0;
timesCalled[2]=0;
timesCalled[3]=0;
timesCalled[4]=0;
timesCalled[5]=0;
/********************************************************************************/
/* */
/* create an arry to hold Height & Width valus for inputBoard Size */
/* */
/* ibHeight inputBoard Height */
/* ibWidth inutboardWidth */
/* */
/* get the user input from gameOpionsFor & put into array . */
/* The user has 5 choices to pick from @077 */
/* The user has 7 choices to pick from @096 */
/* */
/********************************************************************************/
var ibHeight = new Array();
ibHeight[0]= 5;
ibHeight[1]= "5px"; /* xs */
ibHeight[2]= "10px"; /* s */
ibHeight[3]= "15px"; /* sm */
ibHeight[4]= "20px"; /* M */
ibHeight[5]= "27px"; /* mL - default */
ibHeight[6]= "27px"; /* L */
ibHeight[7]= "45px"; /* xL */
var ibWidth = new Array();/* @097c make smaller width for additional column */
ibWidth[0]= 5;
ibWidth[1]= "8px"; /*was 10 xs */
ibWidth[2]= "16px"; /*was 20 s */
ibWidth[3]= "22px"; /* was 27 sm */
ibWidth[4]= "27px"; /* was 34 M */
ibWidth[5]= "39px"; /* was 45 mL - default */
ibWidth[6]= "49px"; /* was 61 L */
ibWidth[7]= "53px"; /* was 66 xL */
var numGames; /* @0.099a */
var audio = new Audio('https://media.geeksforgeeks.org/wp-content/uploads/20190531135120/beep.mp3'); /* 067 */
var surroundingEmptySq = new Array; /* List of empty surrounding squares r## format@0.089a */
var noess = 0 ; /* Number Of Empty Surrounding Squares 089a */
var autoRemove = "N"; /* @1.002-AR */
var arValue = ""; /* @1.002-AR */
/************************************************************************/
/* */
/* Function: main() */
/* */
/* calls: */
/* */
/* helpem() */
/* returns nothing but opens az new window with help. */
/* */
/* */
/* Functions coded in here: */
/* ======================= */
/* */
/* when a sq is clicked foc() is called */
/* - calls ckIfUnoccupied(entered) ptr to clicked square */
/* - if reqAction = "M" calls ckIfValidMove() - move only 1 space */
/* -call ckMove2() to ck that they only moved 1 space. */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/************************************************************************/
function main() {
if (trace == "Y")
{ alert("In Main"); }
alert("IN Main");
tr = "";
temp = init();
/* Get the info entered off the screen */
/* n1 = document.forms[0].elements[0].value team 1 school name */
/* c1 = document.forms[0].elements[1].value team 1 Lane assignments */
if (trace == "Y")
{ alert("Leaving Main"); }
} /* end of Main */
/************************************************************************/
/* */
/* Function: init() called by onLoad() */
/* */
/************************************************************************/
function init() {
if (trace == "Y")
{ alert("Entering IINT");
}
console.log("Entering INIT ver: "+ver );
numGames = getCookie("numGames") /*@0.099a */
getCookie("winningPlayer",winningPlayer,0) /*@0.099a */
if (typeof(numGames) === 'undefined'){
console.log('no cookie for numGames');
numGames=0;
} else {
console.log(' cookie exists .... numGames=(' +numGames+')');
}
if (typeof(winningPlayer) === 'undefined'){
console.log('no cookie for winningPlayer');
}
else {
console.log(' cookie exist for winningPlayer ='+winningPlayer);
}
/*
alert("numGames=" +numGames);
alert("winningPlayer=" +winningPlayer)
*/
var junk;
if(wrapAllowed =="Y") /* @083a */
{ junk = initValuArray("valuWy1a"); }
else
{junk = initValuArray("valuWn1a"); }
document.Form.lod.value = levelDif;
document.Form.r41.style.color = colorX; /* set x/o starting positions to proper colors @0.060 */
document.Form.r59.style.color = colorO; /* @0.060 @097 */
document.getElementById(moveFrom[1]).style.color = colorX; /* 1.009 */
document.getElementById(moveFrom[2]).style.color = colorO; /* 1.009 */
/* document.Form.r41.style.backgroundImage=image[1]; @0.060 @063 */
/* document.Form.r58.style.backgroundImage=image[2]; @0.060 063*/
document.Form.n1.focus() /* Put curson in name field */
/* @011d
var resp = confirm("Click on 'OK' to play against the computer, 'Cancel' to play another person");
*/
/* new code since resp - is commented out @011a */
if (document.gameOptionsForm.ar.value == "N" )/* @1.001-AR */
autoRemove = "N";
else
autoRemove = "Y";
var resp="";
pac = "Y";
comp = 2;
goesFirst=1;
human=Math.ceil(2-(comp/2));
whoseTurn = goesFirst;
saveFrom[1] = moveFrom[1]; /* @008 ititial positions */
saveFrom[2] = moveFrom[2]; /* @008 initial positions */
playerName[comp] = "Computer";
playerName[human]= "Human";
document.Form.n1.value = playerName[1];
document.Form.n2.value = playerName[2];
msg = playerName[whoseTurn]+ "(" +playerChar[whoseTurn] +" )- Now click on a square to Move to. ";
document.Form.out.value = msg;
document.Form.ptn.value = playerName[whoseTurn]; /* show name of whose turn it is */
document.Form.ptc.value = playerChar[whoseTurn]; /* show name of whose turn it is @003a */
document.Form.tn.value = turnNumber; /* show name of whose turn it is @003a */
document.Form.rb2[0].checked = true; /* radio button MoveTo(0)/Reomue(1)003a */
tmp2 = putFormFields(); /* update screen to show rem sq, avail sq, turn, etc */
loadValuArray() ;/* set valu array to valuWn since the default is No Wrap Allowed @004 */
/* called from both INIT & sgOS if wrapAllowed changes */
/* sgOS - Save Game Options Settings */
if (goesFirst == 1) /* player 1 goes first rb1[0] else player2 rb1[1] */
document.Form.rb1[0].checked = true;
else
document.Form.rb1[1].checked = true; /* goesFirst = 2 so player 2 goes first */
if (pac == "Y" && goesFirst == comp )
{alert("Here where pac=y & turn=comp");
row=getRC("R",moveFrom[goesFirst]);
col=getRC("C",moveFrom[goesFirst]);
/***********************************************/
/* what to do here if computergoes first "); */
/***********************************************/
getComputersMove(); /* get computers move */
}
var testResult;
/*
testResult = init2();
*/
console.log("Exiting INIT");
if (trace == "Y")
{ alert("Leaving IINT");
}
}
/************************************************************************/
/* spAlert (special alert) */
/************************************************************************/
function spAlert(loc)
{/*
alert( " in " +loc +" turnNumber =" +turnNumber +"\n"
+ " whoseTurn="+whoseTurn +"\n"
+ " moveFrom[whoseTurn]=" +moveFrom[whoseTurn] +"\n"
+ " moveTo[whoseTurn]=" +moveTo[whoseTurn] +"\n"
+" saveTo[whoseTurn]= " + saveTo[whoseTurn] +"\n"
+" saveFrom[whoseTurn]= " + saveFrom[whoseTurn] +"\n"
+" saveRemoved[whoseTurn]= " + saveRemoved[whoseTurn] +"\n"
+" reqAction=" +reqAction );
*/
}
/************************************************************************/
/* */
/* foc Focus - they clicked on a square , process it */
/* */
/* - put printChar in new pos if its open & legal */
/* - put blank in old position (one they moved from) */
/* */
/* reqAction - requested Action M=move to a sq or R-remove a sq */
/* */
/* Calls: */
/* ckIfUnoccupied */
/* ckIfValidMove */
/* ckHaveMove */
/* ckIfGameOver */
/* PutFormFields */
/* */
/************************************************************************/
function foc(entered)
{
var tmp = ""; /* temp var to hold contents of errmsg prior to an eror */
var tmp2=""; /* tmp for result from putForm */
if (surroundingEmptySq[0] > 0) /go thru list of surrounfing empty sq in format r## */
{ var count=0 ; /* *0.089a */
for (count=1; count <= surroundingEmptySq[0]; count++ )
{
entrd = document.getElementById(surroundingEmptySq[count]);
entrd.value = " " ;
entrd.style.color = color[whoseTurn] ;
}
surroundingEmptySq[0] = 0; /* @0.089a */
}
if (turnNumber ==1)
{
recalValuArray(); /* need to do here so get correct human score for move 1 */
}
console.log(" **** Entering foc for playerName: " +playerName[whoseTurn] +" with whoseTurn=" +whoseTurn +" entered.name = "
+entered.name +" reqAction=" +reqAction + " ****");
if (trace == "Y")
{ alert("In foc with entered.name=" +entered.name +"\n"
+ "whoseTurn=" +whoseTurn +"\n"
+ "moveTo[whoseTurn]=" +moveTo[whoseTurn]);
}
var entered; /* pointer to element that was clicked on, ref it as this */
entered.out = ""; /* blank out any old error/msgs */
moveTo[whoseTurn] = entered.name;
if (trace == "Y")
{alert("in foc. foc is passed entered which is: " +moveTo[whoseTurn]);
}
tmp = ckIfUnoccupied(entered); /* return 1=legal, 0=illegal(occupied) */
if (tmp==0)
{if (reqAction=="M")
{errmsg = "*** ERROR *** - Cannot move there. That's an illegal move: Already Occupied! ("
+moveTo[whoseTurn] +")" +"\n";
console.log("Error Ilegal move..Already occupied"); /* @003a */
document.Form.rb2[0].checked = true; /* ck MoveTo radio Button @003a */
}
else
{errmsg = "*** ERROR *** - Cannot remove an occupied or already removed square ("
+moveTo[whoseTurn] +")" +"\n";
console.log("Error Cant remove occupied/already removed sq"); /* @003a */
document.Form.rb2[0].checked = true; /* ck MoveTo radio Button @003a */
}
result = 0;
/* alert(errmsg); @066 removed popup illegal move -> moved to textareaOUT*/
tmp = document.Form.out.value; /* @064 */
document.Form.out.value = "";
document.Form.out.value = errmsg + "\n" + tmp; /* @064 */
redBorder(); /* @065 */
document.Form.n1.focus(); /* @063 */
if(errmsg != "" || errmsg == " ")
write2gameLog(errmsg);
return result;
}
if (reqAction == "M")
{
tmp = ckIfValidMove(entered); /* Ensure only move 1 space horizon.,vert or diag */
/* returns 1- egal 0-illegal move or > 1 space */
}
if (trace == "Y")
{alert("returned to foc.... tmp="+tmp +" reqAction="+reqAction)};
if(tmp==0)
{
errmsg = "*** ERROR *** Illegal move - Can only move 1 square horiaontally, vertically,"
+" or diagonally.(" +moveTo[whoseTurn] +")" + "\n";
console.log("Error Can only move 1 square horiz/vert/diag"); /* @003a */
result = 0;
/* alert(errmsg); @066 */
tmp = document.Form.out.value; /* @064 */
document.Form.out.value = "";
document.Form.out.value = errmsg + "\n" + tmp; /* @064 */
var audio = new Audio('https://media.geeksforgeeks.org/wp-content/uploads/20190531135120/beep.mp3');
audio.play();
redBorder(); /* @065 */
document.Form.n1,focus(); /* @063 */
if(errmsg != "" || errmsg == " ")
write2gameLog(errmsg);
}
else
{
if (reqAction == "M")
moveTo[whoseTurn] = entered.name; /* save the r## where ##=row col ex r32 */
if (pac=="Y" && reqAction == "M")
saveFrom[whoseTurn] = moveFrom[whoseTurn]; /* @008 */
switch(reqAction)
{ /****************************************/
case "M": /* */
blueBorder(); /* @065 */
/* Process MoveTo draw char in new pos */
entered.style.backgroundColor = colorBlank; /* set background color to unoccupied */
entered.style.color = color[whoseTurn]; /* set font color to color of whoseTurn */
entered.value = playerChar[whoseTurn]; /* print appropriate char of whoseTurn */
entered.style.backgroundColor = colorBlank; /* */
entered.style.backgroundImage=image[whoseTurn]; /* */
if (playerChar[whoseTurn] == "") /* @087a */
entered.style.backgroundColor = color[whoseTurn]; /* @087a */
turnCount[whoseTurn]= turnCount[whoseTurn]+1;/* p1TurnCount = p1TurnCount + 1; */
blankMoveFromSq() ; /* */
saveTo[whoseTurn]=moveTo[whoseTurn]; /* */
set2Occupied(entered); /* set board[][]=whoseTurn */
reqAction = "R"; /* switch to next action needed */
document.Form.rb2[1].checked = true; /* ck Remove radio Button */
document.Form.out.value = "" ; /* update message area */
document.Form.rs.value = remSqCount; /* */
document.Form.as.value = availSqCount; /* */
/****************************************/
document.Form.out.value = playerName[whoseTurn]+ "(" +playerChar[whoseTurn]
+" )- Now click on a square to Remove";
spAlert("foc m");
msg = " " + turnNumber +" ....... " +playerChar[whoseTurn] + " ........ " +saveFrom[whoseTurn] + " ........ "+moveTo[whoseTurn] ;
/* write2gameLog(msg); after remove */
if (autoRemove == "Y"&& whoseTurn== human) /* @1.002-AR add */
{
en = saveFrom[human]; /* @1.002-AR add */
doTheHumansRemove(); /* @1.002-AR add */
}
break;
case "R":
blueBorder(); /* @065 */
en=entered.name;
row=getRC("R",en); /* Get humans remove sq */
col=getRC("C",en);
ptsTotalPrevious = ptsTotal[whoseTurn] ; /* tot pts prior to this turn */
ptsThisTurn[whoseTurn] = ckAdjSq(row,col);
ptsTotal[whoseTurn] = ptsTotal[whoseTurn] + ptsThisTurn[whoseTurn];
if(whoseTurn == 1) /* @0.090@ */
document.Form.pt1.value = ptsTotal[1];
else
document.Form.pt2.value = ptsTotal[2];
smsg = "............score: " +ptsTotal[whoseTurn];
/* write2gameLog(smsg); */
/******************************************/
entered.style.backgroundColor= colorRemove; /* Process Remove Square */
entered.style.color = colorRemove; /* */
entered.value = ""; /* @0.091c was =plyChar[] */
/* var ret=delayBtwMoves(400); @1.006a */
entered.style.backgroundImage=image[0]; /* */
set2Removed(entered); /* set board[][]=-1 removed */
/* Human or Player 1 */
msg = msg + "... ... " +saveRemoved[whoseTurn] +" " + smsg;
write2gameLog(msg); /* */
turnNumber= turnNumber + 1; /* */
turnCount[whoseTurn]=turnCount[whoseTurn]+1;/* track #turns for each player */
reqAction = "M"; /* change actionRequired to MveTo */
whoseTurn=Math.ceil(2-(whoseTurn/2)) ; /* switch whoseTurn: if 1 thn2,if 2 thn 1 */
document.Form.rb2[0].checked = true; /* ck MoveTo radio Button @003a */
document.Form.rb1[whoseTurn-1].checked = true; /* set radio button to say Mov e */
document.Form.ptn.value = playerName[whoseTurn]; /* show name of whose turn it is */
document.Form.ptc.value = playerChar[whoseTurn]; /* show char of whose turn it is */
document.Form.tn.value = turnNumber; /* show name of whose turn it is */
document.Form.rs.value = remSqCount; /* */
document.Form.as.value = availSqCount; /* */
/******************************************/
otherTurn=Math.ceil(2-(whoseTurn/2));
tmp = ckHaveMove(whoseTurn); /* was tmp= 1.014 */
hasMove = ckIfGameOver();/* was tmp= 1.014 */
putFormFields(); /* update screen to show rem sq, avail sq, turn, etc */
/* if(tmp == "Y")
alert("Game Over! "+playerName[otherTurn] +" "+playerChar[otherTurn] +" Wins."+"\n" )*/
/************ does this work....new just added */
if( gameOver == "Y" )
{ /* alert(" ++++ " +errmsg); @066 del */
winMsg = msg +"\n" + winMsg; /* @1.014 */
return /* ?????????????????????????????????????????????????????????????????????*/
}
else
{ document.Form.out.value = msg + playerName[whoseTurn]+ "(" +playerChar[whoseTurn]
+" )- Now click on a square to Move to.";
}
/* @008
if(tmp != "GameOver")
document.Form.out.value = playerName[whoseTurn]+ "(" +playerChar[whoseTurn]
+" )- Now click on a square to Move to.";
*/
break;
default:
errmsg = errmsg +"Should never get here Report Errcode 22" +"\n";
/**********************/
} /* end of Switch/Case */
/**********************/
} /* end of else for if tmp==0 */
console.log( " ==>> Human just completed his turnNumber " +turnNumber );
/********************************************************************/
/* */
/* Human just finished his move/remove, now computers turn */
/* */
/********************************************************************/
computersTurn(); /* @v1.009c */
console.log(" ****Exiting foc... awaiting next Humans Turn click...");
console.log(". ");
if (trace == "Y")
{ alert("Exiting foc");
}
}
/********************************************************************/
/* */
/* Human just finished his move/remove, now computers turn */
/* */
/********************************************************************/
function computersTurn()
{
if (pac == "Y" && whoseTurn == comp )
{ /* alert("Starting computers turn"); */
/* var ret=delayBtwMoves(600); @1.006a */
console.log(" ===> Start computers Turn");
console.log(" ===> Start computers Turn --in foc -----reqAction= " +reqAction +"-----turnNumber=" +turnNumber +" -----");
/* if (reqAction == "M" )
{
row=getRC("R",moveFrom[comp]);
col=getRC("C",moveFrom[comp]);
}
else
{
row=getRC("R",moveFrom[human]);
col=getRC("C",moveFrom[human]);
}
*/
getComputersMove(); /* Finds sq to moveTo globalvar compsMove */
/* and sq to Remove globalvar compsRemov */
console.log("Computer Move To Square calculation checked " +nbc +" squares");
console.log(" --->> End computers Turn " +turnNumber +" For last move To computerchecked " +nbc +" squares");
document.Form.nbc.value = nbc;
} /* end if */
} /* end function */
/************************************************************************/
/* @065 */
/* Put a red border around .resultsarea name=out in documant.Form */
/* */
/* */
/************************************************************************/
function redBorder()
{
var el = document.getElementsByClassName("textareaOut");
el[0].style.color="red";
el[0].style.borderColor="red";
el[0].style.backgroundColor="lightpink";
el[0].style.fontWeight="bold";
el[0].style.fontSize="125%";
/* var el = document.getElementsById("imb").cols = "87"; @1.014a */
}
/************************************************************************/
/* @065 */
/* Put a blue border around .resultsarea name=out in documant.Form */
/* */
/* */
/************************************************************************/
function blueBorder()
{
var el = document.getElementsByClassName("textareaOut");
el[0].style.color="darkblue";
el[0].style.borderColor="darkblue";
el[0].style.backgroundColor="lightblue";
el[0].style.fontWeight="bold";
el[0].style.fontSize="125%";
/* var el = document.getElementsById("imb").cols = "87"; @1.014a */
}
/************************************************************************/
/* @1.014a */
/* Put a border the color of the winning player around .resultsarea */
/* name=out in documant.Form. Also the font color is the color of the */
/* winning player, all on a white background */
/* */
/************************************************************************/
function gameoverBorder()
{
var el = document.getElementsByClassName("textareaOut");
el[0].style.color = color[winningPlayer];
el[0].style.borderColor = color[winningPlayer];
el[0].style.backgroundColor = "white";
el[0].style.fontWeight = "bold";
el[0].style.fontSize = "175%";
el[0].style.fontSize = "140%";
/* var el = document.getElementsById("imb").cols = "87"; @1.014a */
/* alert("winningPlayer=" +winningPlayer +" color of winningPlayer is " +color[winningPlayer]);*/
}
/************************************************************************/
/* */
/* 5 Levels(methods) for determining computers move/remove */
/* */
/* */
/* compSkillLevel or (csl) (1-5) */
/* */
/* 1 - Novice Just pick an adjacant sq by looking at the velue of */
/* all adjacant squares & pick the highest */
/* (this is accoplished by not calling recalcValuArray */
/* */
/* 2 - Easy Look at each adjacant square. Then for each of */
/* those squares count how many (1-9) empty squares */
/* are around it and assign that value to that sq. */
/* Do for all 48 squares */
/* (this is accoplished by calling recalcValuArray) */
/* recalcValuArray looks at compSkillLevel =1 */
/* */
/* 3 - Fair Look at each adjacant square. Then for each of */
/* those squares sum the valu[][] of the (1-9) */
/* surrounding squares and assign that value to that sq.*/
/* Do for all 48 squares */
/* (this is accoplished by calling recalcValuArray) */
/* recalcValuArray looks at compSkillLevel =3 */
/* */
/* 4 - Good Look at each adjacant square. Then for each of */
/* those squares , look at the 1-9 sq around that & */
/* count how many are empty, and assign that valu to */
/* all 48 squares */
/* */
/* */
/* 5 - Advanced Look at each adjacant square. Then for each of */
/* those squares , look at the 1-9 sq around that & */
/* sum the values from all the surrounding */
/* squares and assign that value to valu[][]. */
/* Do thsi for all 64 squares. */
/* */
/* */
/************************************************************************/
/************************************************************************/
/* */
/* Function: getComputersMove() called by foc */
/* */
/* calls ckHaveMove(computer) if N game is over */
/* if computer has at least 1 move go */
/* find the best move */
/* */
/* ckAround() Level 1 Figures out what sq to move to or remove */
/* */
/* */
/* */
/* doTheComputersMove() */
/* */
/* */
/* */
/* doTheComputersRemove */
/* */
/* */
/* */
/* return compsMove - a Global Variable */
/* */
/************************************************************************/
function getComputersMove() {
console.log("--- In getComputersMove reqAction= " +reqAction +"-----");
/* var ret=delayBtwMoves(500); @1.006a */
if (trace == "Y")
{ alert("In getComputersMove. Computer is at " +moveTo[comp] ); }
var hasMove="";
hasMove = ckHaveMove(comp); /* ck if playernum(comp) hs a move (Y/N) */
ckIfGameOver(); /* do i want a cgIfGameOver() here */
if (pac == "Y" && whoseTurn == comp && hasMove == "Y")
{ if (reqAction == "M")
{
row=getRC("R",moveFrom[comp]);
col=getRC("C",moveFrom[comp]);
console.log("Get computers MoveTo Sq.");
console.log("Before re-calculating valu[][] array for Computer moveTo sq ");
logValuVars(); /* write valu[][] array to the console log */
recalValuArray(); /* recalculate the valu[][] array */
console.log("After re-calculating valu[][] array for Computer MoveTo sq ");
logValuVars(); /* write valu[][] array to the console log */
console.log("Get computers MoveTo Sq.");
moveIs = ckAround(); /* *** Get Computers Move *** */
compsMove = moveIs;
console.log("Computers choice of sq to moveTo: moveIs=" +moveIs +" compsMove=" +compsMove);
console.log("*************************************************");
console.log("Computers move calculations:" +"\n"
+ " countArround1: " +timesCalled[1] +"\n"
+ " countArround2: " +timesCalled[2] +"\n"
+ " countArround3: " +timesCalled[3] +"\n"
+ " countArround4: " +timesCalled[4] +"\n"
+ " countArround5: " +timesCalled[5] +"\n");
console.log("*************************************************");
timesCalled[1]=0;
timesCalled[2]=0;
timesCalled[3]=0;
timesCalled[4]=0;
timesCalled[5]=0;
doTheComputersMove(); /* M-move the computers char to new sq */
}
/******************************************************************/
/* to find sq to remove: pretend you at uour opponents position */
/* then determine what sq you would move to if comp was he, */
/* then remove that sq */
/******************************************************************/
if (reqAction =="R") /* remove sq for computers move. */
{
row=getRC("R",moveFrom[human]);
col=getRC("C",moveFrom[human]);
console.log("Get computersMove reqAction=R");
/* recalValuArray(); recalculate the valu[][] array @0.093c */
console.log("After re-calculating valu[][] array for Computer Removes sq ");
logValuVars(); /* write valu[][] array to the console log */
console.log("Get computers Remove Sq.");
moveIs = ckAround(); /* *** Get Computers Remove *** */
compsRemove = moveIs;
if (autoRemove == "Y") /* @1.001-AR add */
{ compsRemove = "r" + getRC("R",moveFrom[comp]) + getRC("C",moveFrom[comp]); }
console.log("Computer Remove Square calculation checked " +nbc +" squares");
console.log("computrs choice of sq to REMOVE: moveIs=" +moveIs +"compsRemove=" +compsRemove);
/* computer move to gameLog dont do it her do it fter we cal the remove score*/
row=getRC("R",compsRemove);
col=getRC("C",compsRemove);
ptsTotalPrevious = ptsTotal[whoseTurn] ; /* tot pts prior to this turn */
ptsThisTurn[whoseTurn] = ckAdjSq(row,col);
ptsTotal[whoseTurn] = ptsTotal[whoseTurn] + ptsThisTurn[whoseTurn];
if(whoseTurn == 1) /* @0.090@ */
document.Form.pt1.value = ptsTotal[1];
else
document.Form.pt2.value = ptsTotal[2];
msg = " " +turnNumber +" -------" +playerChar[whoseTurn] +" ........ "+ saveFrom[whoseTurn] +" ........." +compsMove
+" ......." + compsRemove + "-------------score: " +ptsTotal[whoseTurn] ;
write2gameLog(msg);
doTheComputersRemove(); /* R - Remove a Sq. */
}
} /* end if play against computer */
if (trace == "Y")
{ alert("--- Leaving getComputersMove with moveTo & Remove complete ---"); }
console.log("--- Leaving getComputersMove to compsMove=" +compsMove
+" Removed Sq=" + compsRemove +" ---");
return compsMove
} /* End of function */
/************************************************************************/
/* */
/* ck squares around: */
/* - cks adjacant squares & sets a value to each */
/* - find greatest valu[][] (if >1 randomally pick one of the ties */
/* */
/* */
/************************************************************************/
function ckAround()
{
var rCk = 0;
var cCk = 0;
if (trace == "Y")
{alert("--------In ckAround wrapAllowed="+wrapAllowed +"------" +"\n"
+"row=" +row +" col="+col); }
console.log("In ckAround: reqAction=" +reqAction +" wrapAllowed=" +wrapAllowed +" levelDif="+levelDif +" row="+row +" col="+col );
var retMove = "";
noTies = 0;
pcc[0] = 0;
pcc.length = 0;
maxValu = 0;
/* nbc = 0 add to count board cks @080 del*/
var ro = parseInt(row); /* without this the numbers are actually strings */
var co = parseInt(col); /* and ro+1 concatenates instead of adding */
for(i= ro-1;i<= ro+1;i++)
{
for(j= co-1;j <= co+1; j++)
{
if(wrapAllowed == "Y")
{
rCk = i;
cCk = j;
if(i==0 && wrapAllowed == "Y") rCk=8; /* @0.060 0.097c */
if(i==9 && wrapAllowed == "Y") rCk=1;
if(j==0 && wrapAllowed == "Y") cCk=9; /* @0.060 0.097c */
if(j==10 && wrapAllowed == "Y") cCk=1; /* @0.060 0.097c */
savei = rCk;
savej = cCk;
/* console.log("compare "+"valu[" +rCk +"][" +cCk +"] which is: "+valu[rCk][cCk] +" with maxValu="+maxValu); */
if ( rCk<1 || rCk >9 || cCk<1 || cCk>9 ) /* @0.060 0.097c */
{ console.log(" this shouldnt be! i="+1 +" j=" +j );
alert("should never get here... rCk=" +rCk +" cCk=" +cCk);
break;
}
if(board[rCk][cCk] == 0)
{
nbc = nbc + 1; /* @080m add */
if(valu[rCk][cCk] > maxValu)
{maxValu = valu[rCk][cCk];
noTies = 1;
pcc[noTies] = "r" +rCk +cCk
/* console.log(" its > so new maxValu is "+maxValu +" "); */
}
else
if(valu[rCk][cCk] == maxValu)
{ noTies = noTies+1;
pcc[noTies] = "r"+rCk+cCk+"";
/* console.log(" They are = so noTies is now "+ noTies + " pcc["+noTies +"]=" +pcc[noTies] ); */
}
} /* end of if board[][] = 0 */
} /* end if wrapAllowed=Y */
else /* else for if wrapAllowed = Y */
{
rCk = i; /* @063 */
cCk = j; /* @063 */
if( (j<= numCols && j>0) && (i< 9 && i>0) ) /* @0.060 @0.098c */
{
console.log(" Checking: i="+i +" j="+j +" board["+i +"][" +j +"]="
+board[i][j] +" valu[" +i +"][" +j +"]=" +valu[i][j] +" maxValu=" +maxValu);
if(board[i][j] == 0)
{
nbc = nbc + 1; /* @080m add */
if(valu[i][j] > maxValu)
{savei = i;
savej = j;
maxValu = valu[i][j];
noTies = 1;
pcc[noTies] = "r" +i +j
/* console.log("Got a new maxValu = " +maxValu ); */
}
else /* @005@ */
if(valu[i][j] == maxValu ) /* found a tie */
{ noTies = noTies+1;
pcc[noTies] = "r"+i+j+"";
/* console.log(" Found a tie for the maxvalu. They are = valu[" +i +"][" +j +"]=" +valu[i][j] +" maxValu is "+maxValu +" so noTies is now "+ noTies); */
} /* end of else claue for if valu[i][j] = maxValu */
} /* end if board[][] */
else
console.log(" Sq Occupied/Removed. i="+i +" j="+j +" board["+i +"][" +j +"]="
+board[i][j] );
} /* else if j<9 */
} /* end else if wrapAllowed=Y */
}/* for j = col */
}/* for i= */
/******************************** Start @0.098 f1 fix1 ********************************/
if (maxValu == 0)
{ console.log("maxvalu = 0, indicating no surrounding sq to remove");
msg = "maxValu=0 There is no empty adjacant square next to computers opponent to remove, so randomly select one."
alert(msg);
console.log(msg);
write2gameLog(msg);
}
if (pcc[0] == 0)
{ console.log("pcc[0] = 0, indicating no surrounding sq to remove"); }
if (maxValu == 0 )
{/* randomally pick any empty sq to remove */
console.log("Computer will put all empty sq r## into pcc[] array and randoly pick one");
var loopi = 0;
var loopj = 0;
for(loopi = 1 ; loopi <=numRows; loopi++)
{
for(loopj = 1 ; loopj <=numCols; loopj++)
{
if(board[loopi][loopj] == 0)
{noTies = noTies + 1;
pcc[noTies] = "r"+loopi +loopj+"";
/* console.log("pcc[" +noTies +"]=" +pcc[noTies]); */
}
}
}
console.log("noTies=" +noTies );
pcc[0] = noTies;
console.log("pcc[0]=" +pcc[0]);
console.log("pcc[" +noTies +"]=" +pcc[noTies]);
}
/**************************************** End @0.098 fix 1 ***********************************/
if(noTies>0)
pcc[0]=noTies;
cp =randNoBtw(1,noTies);
/*
alert("In ckAround() " +"\n"
+"maxValu= " +maxValu +"\n"
+"found max value at savei= " +savei +" savej="+savej +"\n"
+"noTies= " +noTies +"\n"
+"rnd# btw 1 & noTies is " +cp );
*/
console.log("--" );
console.log("pic rnd no btw 1 & " +noTies);
cp =randNoBtw(1,noTies);
console.log("random number is cp=" +cp);
retMoveG = pcc[cp];
console.log("Computer randomly picked sq " +pcc[cp] +" to remove.");
logValuVars();
console.log(" ****** maxValu="+maxValu +" found maxValu at i= "+savei +" j= "+savej + " rnd# btw 1 & " +noTies +" is:" +cp ) ;
console.log("list of ties in ckAround");
for(k=0;k<=noTies;k++)
{
console.log("pcc["+k+"]="+pcc[k] ) ;
}
if (trace == "Y")
{alert("Leaving ckAround"); }
retMove = "r"+ rCk + cCk;
retMoveG = retMove; /* @005a */
retMove = pcc[cp];
retMoveG = retMove;
logBoardVars();
document.Form.nbc.value = nbc; /* @008m */
console.log("Leaving ckAround with retMove=" +retMove +" retMoveG="+retMoveG);
return retMove
}
/************************************************************************/
/* */
/* ck squares around: */
/* - show valu[][] of adj squares */
/* */
/* @081 */
/************************************************************************/
function showAround(II,JJ)
{
console.log("Entering showAround");
var rCk = 0;
var cCk = 0;
ctr = 0;
retList = "";
var ro = parseInt(II); /* without this the numbers are actually strings */
var co = parseInt(JJ); /* and ro+1 concatenates instead of adding */
for(i= ro-1;i<= ro+1;i++)
{
for(j= co-1;j <= co+1; j++)
{
if(wrapAllowed == "Y")
{ rCk = i;
cCk = j;
if(i==0 && wrapAllowed == "Y") rCk=8;
if(i==9 && wrapAllowed == "Y") rCk=1;
if(j==0 && wrapAllowed == "Y") cCk=9; /* @1.011.f1 chng rCk=8 to rCk=9 */
if(j==10 && wrapAllowed == "Y") cCk=1; /* @1.011.f1 chng j==9 to j==10 */
ctr = ctr + 1;
if(board[rCk][cCk] == 0)
{if (ctr == 3 || ctr == 6)
{retList = retList + valu[rCk][cCk]+ " " +" \n" ; }
else
{retList = retList +valu[rCk][cCk] + " "; }
}
else
{if (ctr == 3 || ctr == 6)
retList = retList + "x " +" " +"\n"; /* @086c */
else
retList = retList + "X "; /* @086c */
}
} /* end if wrapAllowed=Y */
else /* else for if wrapAllowed = Y */
{
rCk = i;
cCk = j;
if( (j<= numCols && j>0) && ( i<9 && i>0) ) /* @0.098c */
{ ctr = ctr + 1;
if(board[i][j] == 0)
{if (ctr == 3 || ctr == 6)
{ retList = retList + valu[rCk][cCk] +" \n" ;}
else
{retList = retList +valu[rCk][cCk] +" "; }
}
else
if (ctr == 3 || ctr == 6)
retList = retList + "x " +"\n"; /* @086c */
else
retList = retList + "X "; /* @086c */
} /* else if j<9 */
} /* end else if wrapAllowed=Y */
} /* for j = col */
} /* for i= */
console.log("Exiting showAround");
return retList
}
/************************************************************************/
/* */
/* doTheComputersMove */
/* */
/* - Draw the computers char in the sq he want to moveTo. */
/* blank out the square he movedFrom. */
/* @006a */
/************************************************************************/
function doTheComputersMove()
{
entrd = document.getElementById(moveIs);
entrd.out = "";
moveTo[whoseTurn] = entrd.name;
console.log("Entering doTheComputersMove with entrd=" +entrd
+" moveIs="+moveIs +" compsMove=" +compsMove); /* @0.093a */
/****************************************/
entrd.style.backgroundColor = colorBlank; /* set background color to unoccupied */
entrd.style.color = color[whoseTurn]; /* set font color to color of whoseTurn */
entrd.value = playerChar[whoseTurn]; /* @0.091c was= playerChar[whoseTurn] */
console.log("one 1111-----------------------------------------------------------------------------------------");
var ret=delayBtwMoves(999); /* @1.006a */
console.log("three 333333-----------------------------------------------------------------------------------------");
entrd.style.backgroundColor = colorBlank; /* */
entrd.style.backgroundImage=image[whoseTurn]; /* */
if (playerChar[whoseTurn] == "") /* @087a */
entrd.style.backgroundColor = color[whoseTurn]; /* @087a */
turnCount[whoseTurn]= turnCount[whoseTurn]+1;/* p1TurnCount = p1TurnCount + 1; */
blankMoveFromSq() ; /* */
set2Occupied(entrd); /* set board[][]=whoseTurn */
reqAction = "R"; /* switch to next action needed */
document.Form.rb2[1].checked = true; /* ck Remove radio Button */
document.Form.out.value = "" ; /* update message area */
document.Form.rs.value=remSqCount; /* */
document.Form.as.value = availSqCount; /* */
/****************************************/
document.Form.out.value = " Computer moves to: " +compsMove; /* @007a */
document.Form.out.value = playerName[whoseTurn]+ "(" +playerChar[whoseTurn] +")"
+" - Computer moved to: " +moveIs +" - Will now pick a square to Remove"
console.log("doTheComputersMove completed with entrd=" +entrd
+" moveIs="+moveIs +" compsMove=" +compsMove);
}
/************************************************************************/
/* */
/* doTheComputersRemove */
/* */
/* - Remove from play the sq the computerchose to remove */
/* blan out the square he movedFrom. */
/* @006a */
/************************************************************************/
function doTheComputersRemove()
{
console.log("Entering doTheComputersRemove");
if (autoRemove == "Y") /* @1.002-AR add */
{
moveIs = saveFrom[comp];
}
entrd = document.getElementById(moveIs);
/*
en=entrd.name;
row=getRC("R",en);
col=getRC("C",en);
ptsTotalPrevious = ptsTotal[whoseTurn] ;
ptsThisTurn[whoseTurn] = ckAdjSq(row,col);
ptsTotal[whoseTurn] = ptsTotal[whoseTurn] + ptsThisTurn[whoseTurn];
cmsg = msg + "..dtcr.... score: " +ptsTotal[whoseTurn];
console.log(cmsg);
write2gameLog(cmsg);
*/
/****************************************/
entrd.style.backgroundColor= colorRemove; /* Process Remove Square */
entrd.style.color = colorRemove; /* */
entrd.value = ""; /* was playerChar[whoseTurn] @0.091c */
entrd.style.backgroundImage=image[0]; /* */
set2Removed(entrd); /* set board[][]=-1 or -2 removed */
turnNumber= turnNumber + 1; /* keep count of #turns in game */
turnCount[whoseTurn]=turnCount[whoseTurn]+1;/* track #turns for each player */
reqAction = "M"; /* change actionRequired to MveTo */
whoseTurn=Math.ceil(2-(whoseTurn/2)) ; /* switch whoseTurn: if 1 thn2,if 2 thn 1 */
document.Form.rb2[0].checked = true; /* ck MoveTo radio Button @003a */
document.Form.rb1[whoseTurn-1].checked = true; /* set radio button to say Mov e */
document.Form.ptn.value = playerName[whoseTurn]; /* show name of whose turn it is */
document.Form.ptc.value = playerChar[whoseTurn]; /* show char of whose turn it is */
document.Form.tn.value = turnNumber; /* show name of whose turn it is */
document.Form.rs.value = remSqCount; /* */
document.Form.as.value = availSqCount; /* */
/******************************************/
otherTurn=Math.ceil(2-(whoseTurn/2));
hasMove = ckHaveMove(whoseTurn); /* was tmp= 1.014 */
ckIfGameOver();
tmp2 = putFormFields(); /* update screen to show rem sq, avail sq, turn, etc */
if (gameOver != "Y")
document.Form.out.value = " Computer REMOVED Sq: " +compsMove + "\n"; /* @066*/
else
document.Form.out.value = " Computer REMOVED Sq: " +compsMove + "\n" + winMsg ;/* @066*/
if(tmp != "GameOver" && gameOver != "Y") /* @066 added && gameOver ck */
document.Form.out.value = playerName[whoseTurn]+ "("+playerChar[whoseTurn] +" ) "
+"Computer MovedTo:" +compsMove+",Removed:" +compsRemove +" -Now click a square to Move to.";
else
/* document.Form.out.value = "Computer Wins"; /@ @066 do nothing , msg already displayed out textarea .out */
console.log("Completed doTheComputersRemove with entrd=" +entrd
+" moveIs="+moveIs +" compsRemove=" +compsRemove);
/*
msg = " " +turnNumber +" dtcr " +playerChar[whoseTurn] +" ==== "+ saveFrom[whoseTurn] +" === " +compsMove
+" === " + compsRemove;
write2gameLog(msg);
*/
}
/************************************************************************/
/* */
/* doTheHumansRemove */
/* */
/* - Remove from play the sq the computerchose to remove */
/* blank out the square he movedFrom. */
/* @1.002-AR */
/************************************************************************/
function doTheHumansRemove()
{
console.log("Entering doTheHumansRemove");
if (autoRemove == "Y") /* @1.002-AR add */
moveIs = saveFrom[human];
entrd = document.getElementById(moveIs);
/******************************************/
entrd.style.backgroundColor= colorRemove; /* Process Remove Square */
entrd.style.color = colorRemove; /* */
entrd.value = ""; /* was playerChar[whoseTurn] @0.091c */
entrd.style.backgroundImage=image[0]; /* */
set2Removed(entrd); /* set board[][]=-1 or -2 removed */
turnNumber= turnNumber + 1; /* keep count of #turns in game */
turnCount[whoseTurn]=turnCount[whoseTurn]+1;/* track #turns for each player */
reqAction = "M"; /* change actionRequired to MveTo */
whoseTurn=Math.ceil(2-(whoseTurn/2)) ; /* switch whoseTurn: if 1 thn2,if 2 thn 1 */
document.Form.rb2[0].checked = true; /* ck MoveTo radio Button @003a */
document.Form.rb1[whoseTurn-1].checked = true; /* set radio button to say Mov e */
document.Form.ptn.value = playerName[whoseTurn]; /* show name of whose turn it is */
document.Form.ptc.value = playerChar[whoseTurn]; /* show char of whose turn it is */
document.Form.tn.value = turnNumber; /* show name of whose turn it is */
document.Form.rs.value = remSqCount; /* */
document.Form.as.value = availSqCount; /* */
/******************************************/
otherTurn=Math.ceil(2-(whoseTurn/2));
hasMove = ckHaveMove(whoseTurn); /* was tmp= 1.014 */
ckIfGameOver();
tmp2 = putFormFields(); /* update screen to show rem sq, avail sq, turn, etc */
if (gameOver != "Y")
document.Form.out.value = " autoRemoved Sq: " +moveIs + "\n"; /* @066*/
else
document.Form.out.value = " autoRemoved Sq: " +moveIs + "\n" + winMsg ;/* @066*/
if(tmp != "GameOver" && gameOver != "Y") /* @066 added && gameOver ck */
document.Form.out.value = playerName[whoseTurn]+ "("+playerChar[whoseTurn] +" ) "
+"Computer MovedTo:" +compsMove+",Removed:" +compsRemove +" -Now click a square to Move to.";
else
/* document.Form.out.value = "Computer Wins"; /@ @066 do nothing , msg already displayed out textarea .out */
/***************************************************/
/* copied from foc() caseM @1.002-AR */
/***************************************************/
blueBorder(); /* @065 */
/* en=entrd.name; */
en=moveIs;
row=getRC("R",en); /* Get humans remove sq */
col=getRC("C",en);
ptsTotalPrevious = ptsTotal[otherTurn] ; /* tot pts prior to this turn */
ptsThisTurn[otherTurn] = ckAdjSq(row,col);
ptsTotal[otherTurn] = ptsTotal[otherTurn] + ptsThisTurn[otherTurn];
if(otherTurn == 1) /* @0.090@ */
document.Form.pt1.value = ptsTotal[1];
else
document.Form.pt2.value = ptsTotal[2];
smsg = "............score: " +ptsTotal[otherTurn];
console.log("Completed doTheHumansRemove. Comuter removed " +moveIs +" for human");
}
/************************************************************************/
/* */
/* ckIfUnoccupied -> was ckIfMoveLegal */
/* */
/* - board[i][j]=0 0 meas ok to move to or remove, its unoccupied */
/* convert [i][j] to r## so can use getElementById */
/* */
/* - return result result=1 Unoccupied (Legal) */
/* result=2 OCCUPIED (Illegal=0) */
/* */
/* ck wrapAllowed = Y or N (no is default) */
/* */
/************************************************************************/
function ckIfUnoccupied(entered)
{
if (trace == "Y")
{ alert("In ckIfUnoccupied entered.name =" +entered.name); }
var entered;
var result;
var en;
var i;
var j;
if(pac=="Y" && whoseTurn == comp ) /* @004a */
{ en = moveIs ; /* *004a */
}
else /* @004a */
{ en = entered.name;
}
console.log("Entering ckIfUnoccupied cking en=" +en +" ****");
i=en.substring(1,2);
j=Right(en,1);
/* alert("in ckIfUnoccupied entered.mame=" +en +" row="+i +" col="+j) */
/* alert("board["+i+"]["+j+"[="+board[i][j]) */
if(board[i][j] == 0)
{result = 1;
newFrom = entered.name; /* Change move from to the sq we will move to */
}
else
{result = 0;
errmsg = playerName[whoseTurn] +playerChar[whoseTurn] +" Illegal move - that is not an empty square! (" +i +"," +j +")";
/* alert(errmsg) @066 */
}
document.Form.out.value = errmsg;
document.Form.n1.focus(); /* @063 */
if (trace == "Y")
{ alert("Leaving ckIfUnoccupied withe result="+result); }
console.log("Exiting ckIfUnoccupied with result=" +result +" ****");
return result
}
/************************************************************************/
/* */
/* ckIfValidMove 1 space horizontally,vertically or Diagnolayy if */
/* wrapAllowed = N */
/* */
/* Return 0 - Not a legal move */
/* 1 - Legal Move */
/* */
/* */
/************************************************************************/
function ckIfValidMove(entered)
{
if (trace == "Y")
{ alert("In ckIfValidMove withe entered.name =" +entered.name); }
console.log("Entering ckIfValidMove ****");
var entered;
var result;
var en;
var i;
var j;
if(pac=="Y" && whoseTurn == comp ) /* @004a */
{ en = moveIs ; /* *004a */
}
else /* @004a */
{ en = entered.name;
}
i=en.substring(1,2);
j=Right(en,1);
/* alert("in ckIfUnoccupied entered.mame=" +en +" row="+i +" col="+j) */
/* alert("board["+i+"]["+j+"[="+board[i][j]) */
if(reqAction == "M")
{
tmp = ckMove2(); /* cj if within 1 space for no wrap, more for wrap */
/* returns 1 - valid move 0-INVALID move */
if (tmp == 1)
{
result=1;
newFrom=entered.name;
}
else
{ /* console.log("In ckIfValidMove: errmsg = " +errmsg); @0.093d */
errmsg = playerName[whoseTurn] +playerChar[whoseTurn] +" Illegal move rowDif=" +rDif +" cDif="+cDif +" wrapAllowed="+wrapAllowed;
console.log("errmsg = " +errmsg);
result = 0; /* return 0 means Not a legal move */
}
}
document.Form.out.value = errmsg;
if (trace == "Y")
{ alert("Leaving ckIfValidMove with result=" +result +" reqAction=" +reqAction); }
console.log("Exiting ckIfValidMove ****");
return result
}
/************************************************************************/
/* */
/* ckMove2 - check the differenc in row & col from the From position */
/* to the To position */
/* */
/* don't need to check if reqAction is Remove only do for Move */
/* */
/* Returns 1 - valid move */
/* Returns 0 - valid move */
/* */
/* */
/************************************************************************/
function ckMove2() {
if (trace == "Y")
{ alert("In ckMove2"); }
console.log("in ckMove2");
var result = 1; /* passe back 1 if ok, legal, therewise 0*/
/* examine fromMove[whoseTurn] and toMove[whoseTurn] ex:from r31 to r28 */
errmsg="";
var fi = moveFrom[whoseTurn].substring(1,2); /* start , end+1 ... inthis ex it's 3 */
var fj;
fj = Right(moveFrom[whoseTurn],1); /* get rightmost char...inthis ex it's 8 */
/* examine toMove[whoseTurn]*/
var ti = moveTo[whoseTurn].substring(1,2); /* start , end+1 ... in thisex it's 3 */
var tj;
tj = Right(moveTo[whoseTurn],1); /* get rightmost char inthis ex it's 8 */
rDif = Math.abs(ti - fi ); /* absolute value of the difference in rows*/
cDif = Math.abs(tj - fj ); /* absolute value of the difference in rows*/
if(reqAction == "R")
return 1
if (wrapAllowed == "N" && (rDif >1 || cDif >1))
{
errmsg = playerName[whoseTurn] +" "+playerChar[whoseTurn]+ " Illegal Move. Moving more than one space horizontally,vertically or diagonly"+" wrapAllowed="+wrapAllowed +"\n" ;
errmsg = errmsg + "rDif=" +rDif+" cDif="+cDif ;
result = 0 ;
}
if (wrapAllowed == "Y") /* 6x8: valid wrap moves 10,11,50,51,57, 07,17,01 */
{ /* 8x8: */
/* 8x9 @0.097a @0.097c */
switch(rDif)
{
case 0:
if (cDif != 0 && cDif != 1 && cDif != 8) /* @0.097c cDif != 7 to cDif !=8 */
{
errmsg = playerName[whoseTurn] +" "+playerChar[whoseTurn] +" Case 0 Attempted Illegal move."+" wrapAllowed="+wrapAllowed;
result = 0;
}
break;
case 1:
if (cDif != 0 && cDif != 1 && cDif != 8) /* @0.097c cDif != 7 to cDif !=8 */
{
errmsg = playerName[whoseTurn]+" " +playerChar[whoseTurn] +" Case 1 Attempted Illegal move."+" wrapAllowed="+wrapAllowed;
result = 0;
}
break;
/*
case 5:
if (cDif != 0 && cDif != 1 && cDif != 8)
{
errmsg = playerName[whoseTurn]+" " +playerChar[whoseTurn] +" Case 5 Attempted Illegal move."+" wrapAllowed="+wrapAllowed;
result = 0;
}
break;
removed for fix 1.017d*/
case 7: /* @061 added this for 8x8 board instead of 6x8 board */
if (cDif != 0 && cDif != 1 && cDif != 8) /* @0.097c cDif != 7 to cDif !=8 */
{
errmsg = playerName[whoseTurn]+" " +playerChar[whoseTurn] +" Case 7 Attempted Illegal move."+" wrapAllowed="+wrapAllowed;
result = 0;
}
break;
default:
errmsg = playerName[whoseTurn]+" " +playerChar[whoseTurn] +" Case default Attempted Illegal move."+" wrapAllowed="+wrapAllowed;
/* alert(errmsg); @066 */
result = 0;
} /* End switch */
} /* End If Wrapallowed */
document.Form.out.value = errmsg;
console.log("in ckMov2: rDif=" +rDif +" cDif=" +cDif +" errmsg=" +errmsg); /* @064 */
write2gameLog(errmsg);
spAlert("in ckMove2");
if (result == 0)
console.log("leaving ckMove2 with rc=" +result +" invalid move");
if (trace == "Y")
{ alert("Leaving ckMove2 with result="+result ); }
console.log("leaving ckMove2 with result=" +result);
return result
}
/*****************************************************/
/* Check if player has a move ( ie Game Over ? ) */
/* pass 1 or 2 to ck player1 or 2 */
/* */
/* call getRC to get Row,Col for current r## */
/* which is in moveFrom[#] for player 1&2 */
/* */
/* returns Y if has move N if doesnt */
/*****************************************************/
function ckHaveMove(playnum)
{
if (trace == "Y")
alert("Entering ckHaveMove: playnum=" +playnum +"\n"
+" whoseTurrn=" +whoseTurn +"\n"
+" moveFrom["+playnum +"]=" +moveFrom[playnum]);
console.log("Entering ckHaveMove playnum=" +playnum +" whoseTurrn=" +whoseTurn +" moveFrom[" +playnum +"]=" +moveFrom[playnum]);
var playnum;
hasMove = "N"; /* default to N */
whoDoesntHaveMove = playnum; /* say one we are cking */
var row;
var col;
var saveRow;
var saveCol;
var fRow;
var fCol;
fRow = getRC("R",moveFrom[playnum]); /* pass 'r'n1n2 retrrns n1 */
fCol = getRC("C",moveFrom[playnum]); /* pass 'r'n1n2 returns n2 */
curRow = parseInt(fRow); /* curCol & Row are char data */
curCol = parseInt(fCol);
saveRow = 0;
saveCol = 0;
console.log("ck sq fRow="+fRow +" fCol=" +fCol);
for(row=curRow-1 ; row <= curRow+1; row++)
{if (trace =="Y" )
alert("cking player: "+playerName[playnum] +" "+playerChar[playnum]+" in row loop checking row="+row +" <= "+curRow);
for(col=curCol-1; col <= curCol+1 ; col++)
{ /*alert("col loop checking col="+col + " <="+curCol);*/
if(wrapAllowed == "Y" )
{saveRow = row;
saveCol = col;
if(row == 0) row = 8; /* @0.060 0.097c */
if(row == 9) row = 1; /* @0.060 */
if(col == 0) col = 9; /* @0.097c */
if(col == 10) col = 1; /* @0.097c */
}
if(((col <1) || (col >9)) && (wrapAllowed == "Y") ) /* @0.097c */
{row=saveRow;
col=saveCol;
}
if(row >0 && row <9 ) /* @008c || to && @0.060 */
{ /* console.log("---> row="+row +" col="+col +"board["+row+"]["+col+"]="+board[row][col]);*/
if(board[row][col]==0)
{hasMove="Y";
whoDoesntHaveMove = 0;
/* col = curCol + 1;
row = curRow + 1; */
}
}
if(wrapAllowed == "Y" )
{row = saveRow;
col = saveCol;
}
/* alert("checked row="+row+" col="+col+" and hasMove="+hasMove); */
} /* end for col... */
} /* end for row */
if (gameOver =="Y") /*@003c was undefine var ckGameOver made global gameOver variab;r. also may be able to use hasMove=N */
/* alert("returning with info for player: "+playerName[playnum] +" hasMove="+hasMove ); */
if (trace == "Y")
{alert("Leaving ckHaveMove with hasMove=" +hasMove);}
console.log("Leaving ckHaveMove with hasMove="+hasMove);
return hasMove /* Y or N */
} /* end function */
/************************************************************************/
/* */
/* check if game over */
/* */
/* */
/************************************************************************/
function ckIfGameOver()
{
console.log("Entering ckIfGameOver");
if (trace == "Y")
alert("Entering ckIfGameOver");
if(hasMove=="N")
{
if(whoDoesntHaveMove == whoseTurn)
winningPlayer = otherTurn;
else
winningPlayer = whoseTurn;
endDte = new Date();
endTime = endDte.getHours() + ":" + endDte.getMinutes() + ":" + endDte.getSeconds();
temp = new Date().getTime() - strtTime; /* @1.003 a */
temp = temp.toFixed(2);
et = temp/1000/60; /* @1.003 a */
if(hasMove=="N" && gameOver=="N")
{
console.log(" In ckIfGameOver: whodoesntHaveMove=" +whoDoesntHaveMove +" winningPlayer="
+ winningPlayer + " playerName[winningPlayer]=" +playerName[winningPlayer]
+ " hasMove=" +hasMove +" gameOver="+gameOver );
/* alert("Inconsistency found..hasMove=N, gameOver=N setting gameOver = Y"); */
console.log(" Inconsistency found in ckIfGameOver. hasMove=N gameOver=N Forcing gameOver to Y");
gameOver="Y";
}
/* @0.094a Award bonus pts to the player that isolated his opponent */
ptsTotal[winningPlayer] = ptsTotal[winningPlayer] + 10**(levelDif) ; /* isolated winner bonus points @0.094a */
if(winningPlayer == 1) /* @0.094@ */
document.Form.pt1.value = ptsTotal[1];
else
document.Form.pt2.value = ptsTotal[2];
console.log(msg);
write2gameLog(" ");
write2gameLog(" ");
document.Form.out.value = msg;
playerName[1] = playerName[1] + " "; /* @0.098f2 */
playerName[1] = playerName[1].substring(0,9); /* @0.098f2 */
playerName[2] = playerName[2] + " "; /* @0.098f2 */
playerName[2] = playerName[2].substring(0,8); /* @0.098f2 */
playerChar[1]=playerChar[1] + " "; /* @0.098f2 */
playerChar[2]=playerChar[2] + " "; /* @0.098f2 */
var el = document.getElementsByClassName("textareaOut"); /* @074 */
el[0].style.color="darkblue"; /* @074 */
el[0].style.borderColor="darkblue"; /* 074 */
el[0].style.backgroundColor="lightblue"; /* 074 */
el[0].style.fontWeight="bold"; /* 074 */
el[0].style.fontSize="100%"; /* adjust size of Info Box 074 */
console.log("-------------------Game Summary -------------------------");
console.log("Game Date : " +todays_date);
console.log("Start Time: "+startTime);
console.log("End Time : "+endTime);
console.log("Elapsed Time : "+et +" minutes");/* @1.002-AR */
console.log("Winning Player Name : " +winningPlayer +" " +playerName[winningPlayer] + " " +ptsTotal[winningPlayer] + " pts");
console.log("Player who cannot move: " +whoDoesntHaveMove) +" " +playerName[whoDoesntHaveMove] + " pts";
console.log("Number of Squares Removed : " +remSqCount);
console.log("Number of Available squares: " +availSqCount);
console.log("Who went first : "+playerName[goesFirst] );
console.log("turnNumber : " +turnNumber);
console.log("Player 1 turn Count : " +turnCount[1] +" (moveTo as counts 1, remove as counts 1) ");
console.log("Player 2 turn Count : " +turnCount[2]);
console.log("Play against Computer: " +pac);
console.log("Level of Difficulty : " +levelDif);
console.log("WrapAllowed : " +wrapAllowed);
console.log("AutoRemove : " +autoRemove);
console.log("ValuBoardName : " +valuBoardName);
console.log("Player 1 score : " +ptsTotal[1]);
console.log("Player 2 score : " +ptsTotal[2]);
console.log("Bonus Points awarded : " +10**(levelDif)+" points awarded to " +playerName[winningPlayer] + " playerchar: " + playerChar[winningPlayer] ) ;
console.log("timesCalledlvv : " +timesCalledlvv);
console.log("Number Board Checks : " +nbc);
console.log(" ");
console.log("----------------End of Game Summary ----------------------");
/* gameOverWindow(); @1.010a 1.016 gameOverWindow() was here move about 17 lines down fro here */
gameOver = "Y"
logValuVars(); /* write valu[][] array to the console log */
gameoverBorder(); /* 1.014a game over change color if important Msg Box */
msg = "Game Over !!!!" ;
winMsg = msg + winMsg +"\n" ; /* 1.014a */
msg = "Winning Player is: " +playerName[winningPlayer] +playerChar[winningPlayer]
+ " Loosing Player is: " +playerName[whoDoesntHaveMove] +playerChar[whoDoesntHaveMove]+"\n";
write2gameLog(msg);
write2gameLog(" ");
write2gameLog(" ");
winMsg = winMsg +"\n" +msg +"\n"; /* 1.014a */
msg= 10**(levelDif)+" bonus points awarded to " +playerName[winningPlayer] + " playerChar: " + playerChar[winningPlayer] ;
winMsg = winMsg + msg +"\n"; /* 1.014a */
msg = "Final Score Player1: " +ptsTotal[1] +" - Player2: " +ptsTotal[2];
write2gameLog(msg);
winMsg = winMsg +"\n" +msg; /* 1.014a */
document.Form.out.value = winMsg; /* 1.014 here here here here here*/
gameOverWindow(); /* 1.016 moved gameOverWindow() to here from above */
}
if (trace == "Y")
alert("Leaving ckIfGameOver withe gameOver=" +gameOver);
console.log("Exiting ckIfGameOver with gameOver= " +gameOver );
return gameOver
}
/**********************************************************/
/* */
/* */
/* check the value of the sq we are removing & pass it */
/* back to the caller. */
/* */
/* */
/* */
/**********************************************************/
function ckAdjSq(rCk,cCk)
{
console.log("In ckAdjSq: reqAction=" +reqAction +" wrapAllowed=" +wrapAllowed +" levelDif="+levelDif +" row="+rCk +" col="+cCk );
ptsThisTurn[whoseTurn] = valu[rCk][cCk];
nsc = ptsThisTurn[whoseTurn];
logValuVars();
console.log("Leaving ckAdjSq with ptsThisTurn[" +whoseTurn +"]=" +nsc +" ptsThisTurn["+whoseTurn +"]=" +ptsThisTurn[whoseTurn]); /* @0.093c */
return nsc;
}
/**********************************************************/
/* */
/* Pick a random number between 1 & noTies[0] */
/* */
/* sample call x=randNoBtw(1,noTies[0]] */
/* */
/**********************************************************/
function randNoBtw(a,b)
{
var a;
var b;
var result = Math.floor(Math.random()* (b-a+1) +a );
return result
}
/************************************************************************/
/* */
/* write the message that is passed in to gameLog glc is global */
/* */
/* */
/************************************************************************/
function write2gameLog(passedMsg) {
gameLog[glc] = passedMsg;
glc=glc+1;
}
/************************************************************************/
/* */
/* write messages to out textarea */
/* */
/* */
/************************************************************************/
function writeOutGameLog() {
var et2 = et;
blankline = " " ;
hdr1 = " Isolation version: " +ver + " Game Messages " +".....: Date: " +todays_date
hdr2 = " Start time: " +startTime +" - " +" End Time :" +endTime +" " +et +" minutes ("+et*60 +" sec.)"; /* @1.003c */
hdr3 = " ------------------------------------------------------------------------- "+"\n" ;
nlo = 1;
myWindow=window.open('','','width=650,height=555,resizable=yes,scrollbars=yes' );
myWindow.document.write("<body bgcolor=darkseagreen > <title> ISOLATION Game Log </title> ");
myWindow.document.write("<p><b><u><font color=black size=+2 > <center> Isolation ( ver 1.019) Game Log </u></b><br> ");
myWindow.document.write("</center> </p> ");
myWindow.document.write("<font style='font-family:monospace ' color=black size=3> ");
myWindow.document.write("<br> " +hdr1 );
myWindow.document.write("<br> " +hdr2 );
myWindow.document.write("<br> " +hdr3 );
myWindow.document.writeln(blankline);
myWindow.document.writeln(" ");
myWindow.document.writeln("<br> ");
myWindow.document.write("<br> Turn....Player.......Move.........Move.......Remove ");
myWindow.document.write("<br> Nbr.....Char.........From.........To.........Sq..............msg ");
for (ol = 1; ol < glc; ol++)
{
myWindow.document.write("<br>" + gameLog[ol] +" ");
}
myWindow.document.write("<br> ");
myWindow.document.write("<br> Play against Computer: " +pac );
myWindow.document.write("<br> Level of Difficulty : " +levelDif );
myWindow.document.write("<br> autoRemove : " +autoRemove );
myWindow.document.write("<br> ");
myWindow.document.write("<br> Winning Player Name : " +playerName[winningPlayer] );
myWindow.document.write("<br> Winning Player Char : " +playerChar[winningPlayer] );
myWindow.document.write("<br> ");
myWindow.document.write("<br> ");
myWindow.document.write("<br> ");
myWindow.document.write("<br> Opponent Player Name : " +playerName[whoDoesntHaveMove] );
myWindow.document.write("<br> Opponent Player Char : " +playerChar[whoDoesntHaveMove] );
myWindow.document.write("<br> ");
myWindow.document.write("<br> *** End of gameLog Output *** ");
myWindow.document.write("<br> ");
myWindow.document.write("<br> ");
myWindow.document.write("</body> ");
myWindow.document.write("<form> <font color=black > ");
myWindow.document.write("<INPUT TYPE='button'; Style='font-style:italic; font-size:100%; ' value='Print' onClick='window.print()'> ");
myWindow.document.write("<INPUT TYPE='button'; Style='font-style:italic; font-size:100%; ' value='email' onClick='emailit2()'> ");
myWindow.document.write("<a href='mailto:tomyy@optonline.net?subject=ISOLATE gameLog'>... email-Tom Yurkovic </a> ")
myWindow.document.write("<INPUT TYPE='button'; Style='font-style:italic; font-size:100%; ' value='Close' onClick='window.close()'> ");
myWindow.document.write("<form> ");
}
/************************************************************************/
/* */
/* set board[i][j] to occupied by whoseTurn */
/* */
/* */
/************************************************************************/
function set2Occupied(entered)
{
var entered
var en
var i
var j
en = entered.name ;
i=en.substring(1,2);
j=Right(en,1);
board[i][j] = whoseTurn;
/* alert("set board["+i+"]["+j+"]="+board[i][j])*/
}
/************************************************************************/
/* */
/* get column or row passed rnn pass R,r35 or C,r35 */
/* */
/* if you pass R,r35 or C,r35 */
/* returns retVal 3 or 5 retVal is Global */
/* */
/************************************************************************/
function getRC(rc,rNum)
{
var rNum /* Rnn ex r35 */
var rc
var i
var j
i=rNum.substring(1,2);
j=Right(rNum,1);
if(rc=="R")
retVal = i;
else
retVal = j;
return retVal
}
/************************************************************************/
/* */
/* set board[i][j] to removed by player1(-1) or player2(-2) player */
/* */
/* */
/************************************************************************/
function set2Removed(entered)
{
var entered
var en
var i
var j
en = entered.name;
if (autoRemove == "Y" && whoseTurn == comp) /* @1.001-AR add */
en = saveFrom[comp];
if (autoRemove == "Y"&& whoseTurn== human) /* @1.002-AR add */
en = saveFrom[human];
i=en.substring(1,2);
j=Right(en,1);
saveRemoved[whoseTurn]=en;
board[i][j] = -1*whoseTurn; /* board[][]=-1 is removed */
remSqCount = remSqCount +1;
availSqCount = availSqCount - 1;
document.Form.rs.value = remSqCount;
document.Form.as.value = availSqCount;
}
/************************************************************************/
/* */
/* blank Move From Sq */
/* */
/* */
/************************************************************************/
function blankMoveFromSq()
{
console.log("In blankMoveFromSq");
var i
var j
moveFromSqName = moveFrom[whoseTurn] /* @008 */
saveFrom[whoseTurn] = moveFrom[whoseTurn]; /* @008 */
/*
alert("at beginning of blankMoveFromSq whoseTurn = " +whoseTurn +"\n"
+ " moveFrom[whoseTurn] = " +moveFrom[whoseTurn] +"\n"
+ " moveTo[whoseTurn] = " +moveTo[whoseTurn] +"\n"
+" saveFrom[whoseTurn] = " +saveFrom[whoseTurn] +"\n"
+" saveFrom[whoseTurn] = " +saveFrom[whoseTurn] );
*/
var cssEvNum
cssEvNum = moveFromSqName;
console.log("moveFromSqName= " +moveFromSqName +" cssEvNum=" +cssEvNum +" blankChar=(" +blankChar +")" );/* @091*/
document.getElementById(cssEvNum).value = blankChar;
var entrd = document.getElementById(moveFromSqName); /* 091 */
entrd.value = "" ; /* 091 */
document.getElementById(cssEvNum).style.backgroundColor = colorBlank; /* last change */
document.getElementById(cssEvNum).style.backgroundColor = colorBlank;
document.getElementById(cssEvNum).style.backgroundImage = "none";
document.getElementById(cssEvNum).style.backgroundImage = image[0];
i=moveFromSqName.substring(1,2);
j=Right(moveFromSqName,1);
board[i][j] = 0 ; /* set board array to 0 from thge sq he moved from */
moveFrom[whoseTurn] = moveTo[whoseTurn]; /* set movFrom to where we are */
}
/************************************************************************/
/* */
/* doIt called from onMouseOver for Hint button in Form */
/* */
/* currently - called from all the board deefinition @081 */
/* */
/************************************************************************/
function doIt(entered) {
console.log("in doIt with whoseTurn = " +whoseTurn);
var i = 0;
var j = 0;
var lineOut = "";
var pos = "";
var temp = "";
var ot = Math.ceil(2-(whoseTurn/2)) ;
if(reqAction=="M")
{pos = moveFrom[whoseTurn] }
else
{ pos = moveFrom[ot]}
var i = getRC("R",pos);
var j = getRC("C",pos);
i = parseInt(i); /* curCol & Row are char data */
j = parseInt(j);
/*
var i = getRC("R",entered.name);
var j = getRC("C",entered.name);
*/
temp = document.Form.out.value;
lineOut = temp;
ret = showAround(i,j); /* get a list of the surrounding 9 values */
lineOut = "\n" + "reqAction=" +reqAction +" The values around board position " +pos +" are: " +"\n" +ret +"\n" + temp;
document.Form.out.value = lineOut;
}
/************************************************************************/
/* */
/* doItOut */
/* */
/* currently - called from onClick for the Hint button on Form */
/* */
/************************************************************************/
function doItOut(entered) {
console.log("in doItOut with hoseTurn = " +whoseTurn);
var i = 0;
var j = 0;
var lineOut = "";
var pos = "";
var temp = "";
var ot = Math.ceil(2-(whoseTurn/2)) ;
if(reqAction=="M")
{pos = moveFrom[whoseTurn] }
else
{ pos = moveFrom[ot]}
var i = getRC("R",pos);
var j = getRC("C",pos);
i = parseInt(i); /* curCol & Row are char data */
j = parseInt(j);
/*
var i = getRC("R",entered.name);
var j = getRC("C",entered.name);
*/
temp = document.Form.out.value;
lineOut = temp;
ret = showAroundOut(i,j); /* get a list of the surrounding 9 values */
lineOut = temp + "\n" + "Valid moveTo squares (" +noess +" of them) are indicated with a: (" +String.fromCharCode(42) +")";
document.Form.out.value = lineOut +"\n" +temp
var count=0 ; /* *0.089a go thru list of empty surounding sq in format r## */
for (count=1; count <= surroundingEmptySq[0]; count++ )
{
entrd = document.getElementById(surroundingEmptySq[count]);
entrd.value = " " + String.fromCharCode(42); /*46 - period ck 75540 */
entrd.style.color = color[whoseTurn] ;
}
noess = 0; /* @089a */
lineout =
console.log("leaving doItOut");
}
/************************************************************************/
/* */
/* ck squares around: */
/* - show valu[][] of adj squares */
/* */
/* @081 */
/************************************************************************/
function showAroundOut(II,JJ)
{
console.log("entering showAroundOut");
var rCk = 0;
var cCk = 0;
ctr = 0;
retList = ""
var ro = parseInt(II); /* without this the numbers are actually strings */
var co = parseInt(JJ); /* and ro+1 concatenates instead of adding */
noses = 0; /* @0.089a */
surroundingEmptySq[0] = 0; /* @0.089a */
for(i= ro-1;i<= ro+1;i++)
{
for(j= co-1;j <= co+1; j++)
{
if(wrapAllowed == "Y")
{ rCk = i;
cCk = j;
if(i==0 && wrapAllowed == "Y") rCk=8;
if(i==9 && wrapAllowed == "Y") rCk=1;
if(j==0 && wrapAllowed == "Y") cCk=9; /* @1.011.f1 chng rCk=8 to rCk=9 */
if(j==10 && wrapAllowed == "Y") cCk=1; /* @1.011.f1 chng j==9 to j==10 */
ctr = ctr + 1;
if(board[rCk][cCk] == 0)
{ noess = noess + 1 /* @0.089a */
surroundingEmptySq[noess] = "r" + rCk +cCk; /* @0.089a */
if (ctr == 3 || ctr == 6)
{retList = retList + valu[rCk][cCk]+ " " +" \n" ; }
else
{retList = retList +valu[rCk][cCk] + " "; }
}
else
{if (ctr == 3 || ctr == 6)
retList = retList + "x " +" " +"\n"; /* @086c */
else
retList = retList + "X "; /* @086c */
}
} /* end if wrapAllowed=Y */
else /* else for if wrapAllowed = Y */
{
rCk = i;
cCk = j;
if( ( j<= numCols && j>0) && (i<9 && i>0) ) /* @0.098c */
{ ctr = ctr + 1;
if(board[i][j] == 0)
{ noess = noess + 1 /* @0.089a */
surroundingEmptySq[noess] = "r" + rCk +cCk; /* @0.089a */
if (ctr == 3 || ctr == 6)
{ retList = retList + valu[rCk][cCk] +" \n" ;}
else
{retList = retList +valu[rCk][cCk] +" "; }
}
else
if (ctr == 3 || ctr == 6)
retList = retList + "x " +"\n"; /* @086c */
else
retList = retList + "X "; /* @086c */
} /* else if j<9 */
} /* end else if wrapAllowed=Y */
} /* for j = col */
} /* for i= */
surroundingEmptySq[0] = noess; /* @0.089a */
console.log("leaving showAroundOut");
return retList
}
/************************************************************************/
/* */
/* switch pieces for player1,2 Not sure if I want this feature */
/* Will leave for now in case i do. */
/* */
/************************************************************************/
function switchXO(entered) {
/*
var entered;
var na1
var na2
na1 = entered.value ;
na2 = entered.value;
if(na1 != "name1") xChar=na1;
if(na2 != "name2") oChar=na2;
alert("in switchXO with c1="+document.Form.c1.value+" xChar="+xChar +" na1=" +na1 +"na2=" +na2)
na1 = document.Form.n1.value
na2 = document.Form.n2.value
playerChar[1] = xChar;
playerChar[2] = oChar;
playerName[1] = xChar;
playerName[2] = oChar;
alert("in switchXO with c1="+document.Form.c1.value+" xChar="+xChar +" na1=" +na1 +"na2=" +na2)
if(document.Form.n1.value !="name1" || document.Form.n2.value != "name2")
{ alert("changing player2 character to ( X)")
document.Form.c2.value = xChar;
playerChar[2]= xChar
playerChar[1]= oChar
turnNumber = goesFirst;
playerName[goesFirst];
whoseTurn = goesFirst;
np = goesFirst;
document.Form.pt.value = turnName[goesFirst];
document.Form.ptn.value = playerName[goesFirst];
document.Form.ptc.value = playerChar[goesFirst];
}
alert("leave switchOX")
*/
}
/************************************************************************/
/* */
/* dispBoardVars @0.097c added a column */
/* called from onClick of DispBoardVars button on Form */
/* */
/************************************************************************/
function dispBoardVars()
{
alert("Display board[][] Variables " +"\n"
+ "row 1 2 3 4 5 6 7 8 9" +"\n"
+ "---------------------------------------" +"\n"
+ " 1 " +board[1][1] +" "+board[1][2] +" "+board[1][3] +" "+board[1][4] +" "+board[1][5]+" "+board[1][6] +" "+board[1][7] +" "+board[1][8] +" "+board[1][9] +"\n"
+ " 2 " +board[2][1] +" "+board[2][2] +" "+board[2][3] +" "+board[2][4] +" "+board[2][5]+" "+board[2][6] +" "+board[2][7] +" "+board[2][8] +" "+board[2][9] +"\n"
+ " 3 " +board[3][1] +" "+board[3][2] +" "+board[3][3] +" "+board[3][4] +" "+board[3][5]+" "+board[3][6] +" "+board[3][7] +" "+board[3][8] +" "+board[3][9] + "\n"
+ " 4 " +board[4][1] +" "+board[4][2] +" "+board[4][3] +" "+board[4][4] +" "+board[4][5]+" "+board[4][6] +" "+board[4][7] +" "+board[4][8] +" "+board[4][9] +"\n"
+ " 5 " +board[5][1] +" "+board[5][2] +" "+board[5][3] +" "+board[5][4] +" "+board[5][5]+" "+board[5][6] +" "+board[5][7] +" "+board[5][8] +" "+board[5][9] +"\n"
+ " 6 " +board[6][1] +" "+board[6][2] +" "+board[6][3] +" "+board[6][4] +" "+board[6][5]+" "+board[6][6] +" "+board[6][7] +" "+board[6][8] +" "+board[6][9] +"\n"
+ " 7 " +board[7][1] +" "+board[7][2] +" "+board[7][3] +" "+board[7][4] +" "+board[7][5]+" "+board[7][6] +" "+board[7][7] +" "+board[7][8] +" "+board[7][9] +"\n"
+ " 8 " +board[8][1] +" "+board[8][2] +" "+board[8][3] +" "+board[8][4] +" "+board[8][5]+" "+board[8][6] +" "+board[8][7] +" "+board[8][8] +" "+board[8][9] +"\n"
)
}
/************************************************************************/
/* */
/* log board[][] array @0.097c added a column */
/* */
/* */
/************************************************************************/
function logBoardVars()
{
var logBoard = "";
logBoard = "row 1 2 3 4 5 6 7 8 9 " +"\n"
+ "------------------------------------------" +"\n"
+ " 1 " +board[1][1] +" "+board[1][2] +" "+board[1][3] +" "+board[1][4] +" "+board[1][5]+" "+board[1][6] +" "+board[1][7] +" "+board[1][8] +" "+board[1][9] +"\n"
+ " 2 " +board[2][1] +" "+board[2][2] +" "+board[2][3] +" "+board[2][4] +" "+board[2][5]+" "+board[2][6] +" "+board[2][7] +" "+board[2][8] +" "+board[2][9] +"\n"
+ " 3 " +board[3][1] +" "+board[3][2] +" "+board[3][3] +" "+board[3][4] +" "+board[3][5]+" "+board[3][6] +" "+board[3][7] +" "+board[3][8] +" "+board[3][9] +"\n"
+ " 4 " +board[4][1] +" "+board[4][2] +" "+board[4][3] +" "+board[4][4] +" "+board[4][5]+" "+board[4][6] +" "+board[4][7] +" "+board[4][8] +" "+board[4][9] +"\n"
+ " 5 " +board[5][1] +" "+board[5][2] +" "+board[5][3] +" "+board[5][4] +" "+board[5][5]+" "+board[5][6] +" "+board[5][7] +" "+board[5][8] +" "+board[5][9] +"\n"
+ " 6 " +board[6][1] +" "+board[6][2] +" "+board[6][3] +" "+board[6][4] +" "+board[6][5]+" "+board[6][6] +" "+board[6][7] +" "+board[6][8] +" "+board[6][9] +"\n"
+ " 7 " +board[7][1] +" "+board[7][2] +" "+board[7][3] +" "+board[7][4] +" "+board[7][5]+" "+board[7][6] +" "+board[7][7] +" "+board[7][8] +" "+board[7][9] +"\n"
+ " 8 " +board[8][1] +" "+board[8][2] +" "+board[8][3] +" "+board[8][4] +" "+board[8][5]+" "+board[8][6] +" "+board[8][7] +" "+board[8][8] +" "+board[8][9] +"\n"
console.log(logBoard);
}
/************************************************************************/
/* */
/* disp valu[][] array @0.097c added a column */
/* */
/* */
/************************************************************************/
function dispValuVars()
{
if (levelDif ==1 )
alert("Display valu[][] Variables for board name:" +valuBoardName +" levelDif=" +levelDif +" wrapAllowed="+wrapAllowed +"\n"
+ "row 1 2 3 4 5 6 7 8 9 " +"\n"
+ "-----------------------------------------" +"\n"
+ " 1 " +valu[1][1] +" "+valu[1][2] +" "+valu[1][3] +" "+valu[1][4] +" "+valu[1][5]+" "+valu[1][6] +" "+valu[1][7] +" "+valu[1][8] +" "+valu[1][9] +"\n"
+ " 2 " +valu[2][1] +" "+valu[2][2] +" "+valu[2][3] +" "+valu[2][4] +" "+valu[2][5]+" "+valu[2][6] +" "+valu[2][7] +" "+valu[2][8] +" "+valu[2][9] +"\n"
+ " 3 " +valu[3][1] +" "+valu[3][2] +" "+valu[3][3] +" "+valu[3][4] +" "+valu[3][5]+" "+valu[3][6] +" "+valu[3][7] +" "+valu[3][8] +" "+valu[3][9] +"\n"
+ " 4 " +valu[4][1] +" "+valu[4][2] +" "+valu[4][3] +" "+valu[4][4] +" "+valu[4][5]+" "+valu[4][6] +" "+valu[4][7] +" "+valu[4][8] +" "+valu[4][9] +"\n"
+ " 5 " +valu[5][1] +" "+valu[5][2] +" "+valu[5][3] +" "+valu[5][4] +" "+valu[5][5]+" "+valu[5][6] +" "+valu[5][7] +" "+valu[5][8] +" "+valu[5][9] +"\n"
+ " 6 " +valu[6][1] +" "+valu[6][2] +" "+valu[6][3] +" "+valu[6][4] +" "+valu[6][5]+" "+valu[6][6] +" "+valu[6][7] +" "+valu[6][8] +" "+valu[6][9] +"\n"
+ " 7 " +valu[7][1] +" "+valu[7][2] +" "+valu[7][3] +" "+valu[7][4] +" "+valu[7][5]+" "+valu[7][6] +" "+valu[7][7] +" "+valu[7][8] +" "+valu[7][9] +"\n"
+ " 8 " +valu[8][1] +" "+valu[8][2] +" "+valu[8][3] +" "+valu[8][4] +" "+valu[8][5]+" "+valu[8][6] +" "+valu[8][7] +" "+valu[8][8] +" "+valu[8][9] +"\n"
)
if (levelDif==2)
alert("Display valu[][] Variables for board name:" +valuBoardName +" levelDif=" +levelDif +" wrapAllowed="+wrapAllowed +"\n"
+ "row 1 2 3 4 5 6 7 8 9 " +"\n"
+ "------------------------------------------------------------------------" +"\n"
+ " 1 " +valu[1][1] +" "+valu[1][2] +" "+valu[1][3] +" "+valu[1][4] +" "+valu[1][5]+" "+valu[1][6] +" "+valu[1][7] +" "+valu[1][8] +" "+valu[1][9] +"\n"
+ " 2 " +valu[2][1] +" "+valu[2][2] +" "+valu[2][3] +" "+valu[2][4] +" "+valu[2][5]+" "+valu[2][6] +" "+valu[2][7] +" "+valu[2][8] +" "+valu[2][9] +"\n"
+ " 3 " +valu[3][1] +" "+valu[3][2] +" "+valu[3][3] +" "+valu[3][4] +" "+valu[3][5]+" "+valu[3][6] +" "+valu[3][7] +" "+valu[3][8] +" "+valu[3][9] +"\n"
+ " 4 " +valu[4][1] +" "+valu[4][2] +" "+valu[4][3] +" "+valu[4][4] +" "+valu[4][5]+" "+valu[4][6] +" "+valu[4][7] +" "+valu[4][8] +" "+valu[4][9] +"\n"
+ " 5 " +valu[5][1] +" "+valu[5][2] +" "+valu[5][3] +" "+valu[5][4] +" "+valu[5][5]+" "+valu[5][6] +" "+valu[5][7] +" "+valu[5][8] +" "+valu[5][9] +"\n"
+ " 6 " +valu[6][1] +" "+valu[6][2] +" "+valu[6][3] +" "+valu[6][4] +" "+valu[6][5]+" "+valu[6][6] +" "+valu[6][7] +" "+valu[6][8] +" "+valu[6][9] +"\n"
+ " 7 " +valu[7][1] +" "+valu[7][2] +" "+valu[7][3] +" "+valu[7][4] +" "+valu[7][5]+" "+valu[7][6] +" "+valu[7][7] +" "+valu[7][8] +" "+valu[7][9] +"\n"
+ " 8 " +valu[8][1] +" "+valu[8][2] +" "+valu[8][3] +" "+valu[8][4] +" "+valu[8][5]+" "+valu[8][6] +" "+valu[8][7] +" "+valu[8][8] +" "+valu[8][9] +"\n"
)
if (levelDif>=3)
alert("Display valu[][] Variables for board name:" +valuBoardName +" levelDif=" +levelDif +" wrapAllowed="+wrapAllowed +"\n"
+ "row 1 2 3 4 5 6 7 8 9 " +"\n"
+ "--------------------------------------------------------------------------------------------" +"\n"
+ " 1 " +valu[1][1] +" "+valu[1][2] +" "+valu[1][3] +" "+valu[1][4] +" "+valu[1][5]+" "+valu[1][6] +" "+valu[1][7] +" "+valu[1][8] +" "+valu[1][9] +"\n"
+ " 2 " +valu[2][1] +" "+valu[2][2] +" "+valu[2][3] +" "+valu[2][4] +" "+valu[2][5]+" "+valu[2][6] +" "+valu[2][7] +" "+valu[2][8] +" "+valu[2][9] +"\n"
+ " 3 " +valu[3][1] +" "+valu[3][2] +" "+valu[3][3] +" "+valu[3][4] +" "+valu[3][5]+" "+valu[3][6] +" "+valu[3][7] +" "+valu[3][8] +" "+valu[3][9] +"\n"
+ " 4 " +valu[4][1] +" "+valu[4][2] +" "+valu[4][3] +" "+valu[4][4] +" "+valu[4][5]+" "+valu[4][6] +" "+valu[4][7] +" "+valu[4][8] +" "+valu[4][9] +"\n"
+ " 5 " +valu[5][1] +" "+valu[5][2] +" "+valu[5][3] +" "+valu[5][4] +" "+valu[5][5]+" "+valu[5][6] +" "+valu[5][7] +" "+valu[5][8] +" "+valu[5][9] +"\n"
+ " 6 " +valu[6][1] +" "+valu[6][2] +" "+valu[6][3] +" "+valu[6][4] +" "+valu[6][5]+" "+valu[6][6] +" "+valu[6][7] +" "+valu[6][8] +" "+valu[6][9] +"\n"
+ " 7 " +valu[7][1] +" "+valu[7][2] +" "+valu[7][3] +" "+valu[7][4] +" "+valu[7][5]+" "+valu[7][6] +" "+valu[7][7] +" "+valu[7][8] +" "+valu[7][9] +"\n"
+ " 8 " +valu[8][1] +" "+valu[8][2] +" "+valu[8][3] +" "+valu[8][4] +" "+valu[8][5]+" "+valu[8][6] +" "+valu[8][7] +" "+valu[8][8] +" "+valu[8][9] +"\n"
)
}
/************************************************************************/
/* */
/* Write valu[][] array to console.log @0.07c add column */
/* */
/* */
/************************************************************************/
function logValuVars()
{
console.log("In logValuVars");
console.log("valu[][] Array for board name: " +valuBoardName +" levelDif=" +levelDif +" wrapAllowed = " +wrapAllowed);
if (levelDif <= 2)
console.log(" row 1 2 3 4 5 6 7 8 9 " );
else
console.log(" row 1 2 3 4 5 6 7 8 9 " );
console.log("-----------------------------------------------------");
console.log(" 1 " +valu[1][1] +" "+valu[1][2] +" "+valu[1][3] +" "+valu[1][4] +" "+valu[1][5]+" "+valu[1][6] +" "+valu[1][7] +" "+valu[1][8] +" "+valu[1][9] );
console.log(" 2 " +valu[2][1] +" "+valu[2][2] +" "+valu[2][3] +" "+valu[2][4] +" "+valu[2][5]+" "+valu[2][6] +" "+valu[2][7] +" "+valu[2][8] +" "+valu[2][9] );
console.log(" 3 " +valu[3][1] +" "+valu[3][2] +" "+valu[3][3] +" "+valu[3][4] +" "+valu[3][5]+" "+valu[3][6] +" "+valu[3][7] +" "+valu[3][8] +" "+valu[3][9] );
console.log(" 4 " +valu[4][1] +" "+valu[4][2] +" "+valu[4][3] +" "+valu[4][4] +" "+valu[4][5]+" "+valu[4][6] +" "+valu[4][7] +" "+valu[4][8] +" "+valu[4][9] );
console.log(" 5 " +valu[5][1] +" "+valu[5][2] +" "+valu[5][3] +" "+valu[5][4] +" "+valu[5][5]+" "+valu[5][6] +" "+valu[5][7] +" "+valu[5][8] +" "+valu[5][9] );
console.log(" 6 " +valu[6][1] +" "+valu[6][2] +" "+valu[6][3] +" "+valu[6][4] +" "+valu[6][5]+" "+valu[6][6] +" "+valu[6][7] +" "+valu[6][8] +" "+valu[6][9] );
console.log(" 7 " +valu[7][1] +" "+valu[7][2] +" "+valu[7][3] +" "+valu[7][4] +" "+valu[7][5]+" "+valu[7][6] +" "+valu[7][7] +" "+valu[7][8] +" "+valu[7][9] );
console.log(" 8 " +valu[8][1] +" "+valu[8][2] +" "+valu[8][3] +" "+valu[8][4] +" "+valu[8][5]+" "+valu[8][6] +" "+valu[8][7] +" "+valu[8][8] +" "+valu[8][9] );
console.log(" . ");
timesCalledlvv = timesCalledlvv + 1 ; /* track how many times this is called */
console.log("Exiting logValuVars");
}
/************************************************************************/
/* */
/* GetGameOptions - not called by anyone */
/* */
/************************************************************************/
function GetGameOptions(entered)
{
if(trace == "Y")
alert("In GetGameOptions..code is commented out. passed this form!!");
/*
alert("in GetGameOptions")
len = document.gameOptionsForm.pinput.length
for (i = 0; i <len; i++) {
if (document.gameOptionsForm.pinput[i].checked)
{
playerOptions = document.gameOptionsForm.pinput[i].value;
numberOfPlayers = playerOptions;
alert("number players="+numberOfPlayers)
}
}
len = document.gameOptionsForm.wa.length
for (i = 0; i <len; i++) {
if (document.gameOptionsForm.wa[i].checked)
{
playerOptions = document.gameOptionsForm.wa[i].value;
wrapAllowed = playerOptions;
alert("wrap allowed="+wrapAllowed)
}
}
len = document.gameOptionsForm.ld.length
for (i = 0; i <len; i++) {
if (document.gameOptionsForm.ld[i].checked)
{
playerOptions = document.gameOptionsForm.ld[i].value;
levelDif = playerOptions;
alert("level of difficulty="+levelDif)
}
}
*/
}
/************************************************************************/
/* */
/* GeSelectedItem - which radion button was clicked, if any & get its */
/* value */
/* Not used anymore */
/************************************************************************/
function GetSelectedItem()
{
tmp=init();
foundRBN=99
reqAction = "M" /* default to Move to a Sq, change to R for Remove */
var chosen = " "
len = document.Form.rb1.length
for (i = 0; i <len; i++) {
if (document.Form.rb1[i].checked)
{
chosen = document.Form.rb1[i].value;
foundRBN = i;
}
}
alert("in getSelectedItem with numberOfPlayers ="+numberOfPlayers +" chosen="+chosen +"\n" +" foundRBN="+foundRBN +" typeof(foundRBN)"+typeof(foundRBN) +"\n" +" 0=X, 1=O, 2= blank, 3=removeSq")
switch(foundRBN)
{
case 0: /* X */
chosen = xChar;
/* entered.style.backgroundColor='darkseagreen';*/
break;
case 1: /* "O" */
chosen = oChar;
/* entered.style.backgroundColor='darkseagreen';*/
break;
case 2: /* " ": */
chosen = blankChar;
/* entered.style.backgroundColor='darkseagreen';
entered.style.backgroundColor='navy';*/
break;
case 3: /* "- ": */
chosen = removeChar;
reqAction = "R" /* Remove a Square */
/* entered.style.backgroundColor='darkseagreen'; */
break;
case 99: /* Nothing found */
chosen = ""
alert("No radio button selected")
/* entered.style.backgroundColor='darkseagreen'; */
break;
default:
alert("Error bad switch variable in getSelectedItem foundRBN="+foundRBN)
errmsg = errmsg +"Should never get here Report Errcode 23 and foundRBN="+foundRBN +"\n";
}
alert("after switch chosen = "+chosen)
/* If they dont choose one, coose it for them */
/*
if (chosen == "") {
document.Form.rb1[0].value = " X";
document.Form.rb1[0].checked = "true"
printChar = remChar
alert("No rb selected...defaulting")
}
else {
alert("else Rb1 selected with i=" +i +" value =" +chosen)
}
*/
printChar = chosen
alert("printChar / chosen=" +printChar +"/" +chosen)
/* alert("Rb1 selected with i=" +i +" value =" +chosen +" printChar="+printChar +" foundRBN="+foundRBN) */
n1 = document.Form.n1.value
c1 = document.Form.c1.value
n2 = document.Form.n2.value
c2 = document.Form.c2.value
ptn = document.Form.ptn.value /* @003a */
ptc = document.Form.ptc.value /* @003a */
/*
if(turnNumber%2==0)
{ document.Form.pt.value = doucment.Form.n2.value;
document.Form.ptc.value = document.Form.c1.value;
}
else
{ document.Form.pt.value = document.Form.n1.value;
document.Form.ptc.value = document.Form.c1.value;
alert("After if turnNumber= " +turnNumber +"/n"
+" name pt= " +pt +"/n"
+" symbol= "+ptc )
}
*/
if(trace == "Y")
{alert("leaving getSelectedItem");}
}
/************************************************************************/
/* initformGetSelectedItem */
/* GeSelectedItem - which radion button was clicked, if any & get its */
/* value */
/* Not used anymore */
/************************************************************************/
function initformGetSelectedItem()
{
console.log("In initformGetSelectedItem");
alert("In initformGetSelectedItem");
if(document.initform.iwgf[0].checked)
{goesFirst = 1;
goesSecond = 2;
}
else
{goesFirst = 2;
goesSecond = 1;
}
document.initform.initfornn1.value = playerName[goesFirst];
document.initform.initformn1.value = playerChar[goesFirst];
document.initform.initfornn2.value = playerName[goesSecond];
document.initform.initformn2.value = playerChar[goesSecond];
temp = putFormFields();
alert("Display Options Settings " +"\n"
+ " numberOfPlayers = " +numberOfPlayers +"\n"
+ " goesFirst = " +goesFirst +"\n"
+ " wrapAllowed = " +wrapAllowed +"\n"
+ " levelDif = " +levelDif +"\n"
+ " playerName[1] = " +playerName[1] +"\n"
+ " playerName[2] = " +playerName[2] +"\n"
+ " playerChar[1] = " +playerChar[1] +"\n"
+ " playerChar[2] = " +playerChar[2] +"\n"
+ " trace = " +trace +"\n" )
alert("Leaving initformGetSelectedItem goesFirst=" +goesFirst +"playerName going first = " +playerName[goesFirst] +"playerChar[goesFirst]= " +playerChar[goesFirst]+"\n"
+" goesSecond=" +goesSecond +"playerName going second = " +playerName[goesSecond] +"playerChar[goesSecond]= " +playerChar[goesSecond] );
console.log("initform save Settings ...successfully completed");
}
/************************************************************************/
/* */
/* sgOS Save Game Options Settings */
/* */
/* Called by: onClick for button Save Game Options Settings */
/* */
/* Called by: onClick for button Save Customization */
/* */
/* */
/************************************************************************/
function sgOS() {
console.log("In sgOS");
var msgOnEntry = document.Form.out.value + "\n";
/**************************************************************************/
/* Play autoRemove = Y if selected, N if not selected @1.002 -AR add */
/* if 1st.ar[] element is checked its Y */
/* if 2nd.ar[] element is checked its N */
/**************************************************************************/
len = document.gameOptionsForm.ar.length ; /* */
if (document.gameOptionsForm.ar[0].checked )
{
arValue = document.gameOptionsForm.ar[0].value;
autoRemove = "Y";
console.log("autoRemove set to " +autoRemove);
}
if (document.gameOptionsForm.ar[1].checked )
{
arValue = document.gameOptionsForm.ar[1].value;
autoRemove = "N";
console.log("autoRemove set to " +autoRemove);
}
/**************************************************************************/
/* Num of Players (np on Form pinput[0] 1 player pinput[1] is 2 players */
/**************************************************************************/
len = document.gameOptionsForm.pinput.length ;
for (i = 0; i <len; i++) {
if (document.gameOptionsForm.pinput[i].checked)
{
playerOptions = document.gameOptionsForm.pinput[i].value;
numberOfPlayers = playerOptions;
}
}
if(numberOfPlayers == 2)
pac="N";
/***************************************************************************/
/* Who Goes First wgf on Form iwgf on initform */
/***************************************************************************/
len = document.gameOptionsForm.wgf.length /* wgf(1 or 2) */
for (i = 0; i <len; i++) { /* Who Goes First */
if (document.gameOptionsForm.wgf[i].checked)
{
playerOptions = document.gameOptionsForm.wgf[i].value;
goesFirst = playerOptions;
whoseTurn = goesFirst; /* last change @@@@ 6/6/20 added this line */
console.log("goesFirst changed to: " +whoseTurn );
document.Form.ptn.value = playerName[goesFirst];
document.Form.ptc.value = playerChar[goesFirst];
if (goesFirst ==1) /* player 1 goes first rb1[0] else player2 rb1[1] */
document.Form.rb1[0].checked = true;
else
{
document.Form.rb1[1].checked = true;
computersTurn();
}
}
}
/***************************************************************************/
/* Wrap Allowed */
/***************************************************************************/
len = document.gameOptionsForm.wa.length /* wrapAllowed ( Y or N) */
for (i = 0; i <len; i++) {
if (document.gameOptionsForm.wa[i].checked)
{
playerOptions = document.gameOptionsForm.wa[i].value;
wrapAllowed = playerOptions;
document.Form.wr.value = wrapAllowed;
var junk; /* @0.085a */
if(wrapAllowed =="Y") /* @085a */
{ junk = initValuArray("valuWy1a"); }
else
{junk = initValuArray("valuWn1a"); }
}
}
/***************************************************************************/
/* Level of Difficulty - how far ahead computer looks */
/***************************************************************************/
len = document.gameOptionsForm.ld.length /* levelDif (1 to 4) */
for (i = 0; i <len; i++) {
if (document.gameOptionsForm.ld[i].checked)
{
playerOptions = document.gameOptionsForm.ld[i].value;
levelDif = playerOptions;
document.Form.wr.value = wrapAllowed;
loadValuArray(); /* set valu[] to either valuWy or valuWn */
document.Form.lod.value = levelDif;
}
}
/***************************************************************************/
/* Number of Players */
/***************************************************************************/
/*
if (numberOfPlayers ==1)
{
document.Form.n2.value = "Computer";
playerName[2] = "Computer";
pac = "Y" ;
document.Form.np.value = numberOfPlayers;
document.Form.arem.value = autoRemove;
document.Form.n2.readOnly = true;
document.Form.c2.readOnly = true;
}
*/
/***************************************************************************/
/* See if they changed the name of player 1 &/or 2 */
/* */
/* We check to see if its still the same as the default, */
/* if not then they changed it */
/***************************************************************************/
/*
if(document.Form.n1.value != "Human")
playerName[1] =document.Form.n1.value;
if(document.Form.n2.value != "Computer")
playerName[2] =document.Form.n2.value;
if(document.Form.c1.value != " X")
playerChar[1] = document.Form.c1.value;
if(document.Form.c2.value != " O")
playerChar[2] = document.Form.c2.value;
*/
/********************************************************/
/* Default colors & chars for Aiden, Ethan, Rhys & Veya */
/********************************************************/
var specialNameEntered = ""; /* @1.011.f2 */
if(playerName[1].substring(0,2) == "Ai")
{
colorX = "darkorange"
color[1]= colorX
xChar = "Mets"
playerChar[1] = xChar
specialNameEntered = "1"; /* @1.011.f2 */
}
if(playerName[1].substring(0,2) == "Et")
{
colorX = "sienna"
color[1]= colorX
xChar = "EM"
playerChar[1] = xChar
specialNameEntered = "1"; /* @1.011.f2 */
}
if(playerName[1].substring(0,2) == "Rh")
{
colorX = "green"
color[1]= colorX
xChar = "Jets"
playerChar[1] = xChar
specialNameEntered = "1"; /* @1.011.f2 */
}
if(playerName[1].substring(0,2) == "Ve" )
{
colorX = "hotpink"
color[1]= colorX
xChar = "VY"
playerChar[1] = xChar
specialNameEntered = "1"; /* @1.011.f2 */
}
if(specialNameEntered == "1") /* @1.011.f2 */
{ document.gameOptionsForm.c1.value = playerChar[1];
specialNameEntered = ""; /* @1.011.f2 */
}
if (playerName[2].substring(0,2) == "Ai" )
{
colorO = "darkorange"
color[2]= colorO
oChar = " Mets"
playerChar[2] = oChar
specialNameEntered = "2"; /* @1.011.f2 */
}
if (playerName[2].substring(0,2) == "Et" )
{
colorO = "sienna"
color[2]= colorO
oChar = " EM"
playerChar[2] = oChar
specialNameEntered = "2"; /* @1.011.f2 */
}
if(playerName[2].substring(0,2) == "Rh" )
{
colorO = "green"
color[2]= colorO
oChar = " Jets"
playerChar[2] = oChar
specialNameEntered = "2"; /* @1.011.f2 */
}
if(playerName[2].substring(0,2) == "Ve" )
{
colorO = "hotpink"
color[2]= colorO
oChar = " VY"
playerChar[2] = oChar
specialNameEntered = "2"; /* @1.011.f2 */
}
if(specialNameEntered == "2") /* @1.011.f2 */
{document.gameOptionsForm.c2.value = playerChar[2];
specialNameEntered = ""; /* @1.011.f2 */
}
/********************************************************/
/* Let the user pick a color to use as the color */
/* when we remove a square @068 */
/********************************************************/
var xyz = document.getElementById("remsqcolor");
var defaultVal = xyz.defaultValue;
var currentVal = xyz.value;
defaultVal = defaultVal.toUpperCase();
colorRemove = currentVal.toUpperCase() ;
if (colorRemove != defaultVal )
{ msg = msg + "\n" +"User changed colorRemove from: " +defaultVal + " to: " +colorRemove;
console.log(msg);
write2gameLog(msg);
document.Form.out.value = msg;
}
else
console.log("The color of removed sq values are the same if uppered");
/********************************************************/
/* Let the user pick a color to use as the color */
/* for the entire screen. It found in the CSS selector */
/* to change the background-color @069 */
/********************************************************/
var bgc = "";
var junk = "";
var xyz = document.getElementById("chngbgcolor");
var defaultVal = xyz.defaultValue;
var currentVal = xyz.value;
defaultVal = defaultVal.toUpperCase();
bgc = currentVal.toUpperCase();
if (bgc != "undefined")
junk = setbg(bgc);
if ( bgc != defaultVal )
{ msg = msg + "\n" +"User changed background color for entire screen from: " +defaultVal + " to: " +colorRemove;
console.log(msg);
write2gameLog(msg);
document.Form.out.value = msg;
}
else
console.log("The entire screen background color values are the same.");
/***************************************************************************/
/* toggle trace on/off ( Y or N) - removed from gameOptions Form */
/***************************************************************************/
/*
if (document.gameOptionsForm.tro[0].checked)
{ trace = document.gameOptionsForm.tro[0].value; }
else
{ if (document.gameOptionsForm.tro[1].checked)
{ trace = document.gameOptionsForm.tro[1].value; }
}
*/
temp = putFormFields();
/* msg = "Game Options Settings Changed: " +"\n"
+ " numberOfPlayers = " +numberOfPlayers +"\n"
+ " pac = " +pac +"\n"
+ " goesFirst = " +goesFirst +"\n"
+ " whoseTurn = " +whoseTurn +"\n"
+ " wrapAllowed = " +wrapAllowed +"\n"
+ " levelDif = " +levelDif +"\n"
+ " playerName[1] = " +playerName[1] +"\n"
+ " playerName[2] = " +playerName[2] +"\n"
+ " playerChar[1] = " +playerChar[1] +"\n"
+ " playerChar[2] = " +playerChar[2] ;
@074 commented this out*/
console.log(msg);
/* write2gameLog(msg); */
/************************************************************/
/* Only let user change : */
/* - Player1/2 character color (defaults X-blue/O-red) */
/* - change board color */
/* if the game hasn't started yet (ie turnNumber = 1 */
/* */
/* @072 */
/************************************************************/
if (turnNumber == 1) /* can only change x & 0 color, & change board color before game starts */
{
/************************************************************/
/* Let the user pick a color to use as the color */
/* for player1 char (def is X) and player 2 char def(red) */
/* element id: chngplayer1charcolor (cp1cc) */
/* & chngplayer2charcolor (cp2cc) */
/* @071 */
/************************************************************/
var cp1cc = document.getElementById("chngplayer1charcolor");
var defaultVal = cp1cc.defaultValue;
var currentVal = cp1cc.value;
colorX = currentVal.toUpperCase() ;
defaultVal = defaultVal.toUpperCase();
if (colorX != defaultVal )
{ msg = msg + "\n" +"User changed player 1 color(colorX) from: " +defaultVal + " to: " +colorX;
console.log(msg);
write2gameLog(msg);
document.Form.out.value = msg;
color[1] = colorX;
/* document.Form.r41.style.color = colorX; */
document.getElementById(moveFrom[1]).style.color = colorX /* @v1.006f */
}
else
{console.log("The color of player1 colors are the same if uppered from "+defaultVal +" to " +currentVal);
}
/* now do player2 char color */
var cp2cc = document.getElementById("chngplayer2charcolor");
var defaultVal = cp2cc.defaultValue;
var currentVal = cp2cc.value;
colorO = currentVal.toUpperCase() ;
defaultVal = defaultVal.toUpperCase();
if (colorO != defaultVal )
{ msg = msg + "\n" + "User changed player 2 color(colorO) from: " +defaultVal + " to: " +colorO;
console.log(msg);
write2gameLog(msg);
document.Form.out.value = msg;
color[2] = colorO;
var elem = document.getElementById(moveFrom[2]); /* @v1.006f */
elem.style.color = colorO; /* @v1.006f */
}
else
{ console.log("The color of player2 colors are the same if uppered from "+defaultVal +" to " +currentVal);
}
/********************************************************/
/* Let the user pick a color to use as the color */
/* for the game board. It found in the CSS selector */
/* element for entire screen background-color @070 */
/********************************************************/
var boardColor = "";
var junk = "";
var xyz = document.getElementById("chngboardcolor");
var defaultVal = xyz.defaultValue;
var currentVal = xyz.value;
boardColor = currentVal.toUpperCase();
defaultVal = defaultVal.toUpperCase();
if ((boardColor) != defaultVal )
{ msg = msg + "\n" + "User changed board color from: " +defaultVal + " to: " +colorRemove;
console.log(msg);
write2gameLog(msg);
document.Form.out.value = msg;
}
else
console.log("The board color values are the same.");
colorBlank = boardColor;
var elctr = 0;
var el = document.getElementsByClassName("inputBoard");
for (elctr=0; elctr <= totSq-1; elctr++) /* @0.097c */
{
el[elctr].style.backgroundColor = boardColor;
}
/********************************************************/
/* set the height & width of inputBoard ClassName to */
/* the InputBoardSize ibs they requested 1-5 */
/* @077 */
/********************************************************/
var sizeSelected = 3; /* Default to medium size */
len = document.gameOptionsForm.ibs.length
for (i = 0; i <len; i++) {
if (document.gameOptionsForm.ibs[i].selected)
{
sizeSelected = document.gameOptionsForm.ibs[i].value;
}
}
var elctr = 0;
var el = document.getElementsByClassName("inputBoard");
for (elctr=0; elctr <= totSq-1; elctr++) /* @0.097c */
{
el[elctr].style.height = ibHeight[sizeSelected];
el[elctr].style.width = ibWidth[sizeSelected];
}
if (sizeSelected != 3)
{ msg = msg + "\n" + "Board Size is: Height=" +ibHeight[sizeSelected] + " width=" +ibWidth[sizeSelected];
console.log(msg);
write2gameLog(msg);
document.Form.out.value = msg;
}
else
{console.log("The board size did not change.");
}
}
temp = document.Form.out.value; /* @V0.054 */
document.Form.out.value = temp + "\n" +"Set Game Options Settings (sgOS) ...successfully completed " +"\n" + msgOnEntry;
console.log("Set Game Options Settings (sgOS) ...successfully completed");
}
/************************************************************************/
/* */
/* pCharNameChanged("PorN","0,1or 2") @075 */
/* */
/* */
/* called from: */
/* onChange for player1 name & char on form gameOptionsForm */
/* */
/* onChange for player2 name & char on form gameOptionsForm */
/* */
/* */
/* */
/* */
/* */
/************************************************************************/
function pCharNameChanged(cORn,pn) {
var cORn;
var pn ;
console.log("Entering pCharNameChanged cORn="+cORn +" whoseTurn=" +whoseTurn);
switch(pn) {
case "1": /* Player 1 Char or Namme */
if(cORn == "C")
{
xChar = document.getElementById("chng1Char").value;
playerChar[1] = xChar;
var pos = moveFrom[1]; /* @0.092a */
var tmpElem = document.getElementById(pos); /* @0.092a */
tmpElem.value = playerChar[1]; /* @0.092a */
/*
var tmpElem = document.getElementById("r41");
tmpElem.value = playerChar[1];
*/
var temp = document.Form.out.value;
msg = "Player1 Character changed to:(" +playerChar[1] +") with a length of " +playerChar[1].length +"\n" ;
document.Form.c1.value = playerChar[1]; /* now update dashboard ie Form*/
document.gameOptionsForm.c1.value = playerChar[1]; /* now update gameOptionsFormForm */
console.log("playerChar[1].substring(0,1)=("+playerChar[1].substring(0,1) +") length is:" +playerChar[1].length );/* @087a */
if(playerChar[1] == "") /* @087a */
{ var elem = document.getElementById(moveFrom[1]) ; /* @087a */
elem.style.backgroundColor = color[1]; /* @087a */
}
document.Form.out.value = msg;
console.log(msg);
}
else
{
playerName[1] = document.Form.n1.value;
playerName[1] = document.gameOptionsForm.n1.value;
var temp = document.Form.out.value;
document.Form.n1.value
document.gameOptionsForm.n1.value = playerName[1];
document.Form.n1.value = playerName[1];
msg = "Player1 Name top/bottomchanged to: " +playerName[1] +"\n" ;
document.Form.out.value = msg;
console.log(msg);
}
break;
case "2": /* Player 2 Char or Namme */
if(cORn == "C")
{
oChar = document.getElementById("chng2Char").value;
playerChar[2] = oChar;
var pos = moveFrom[2]; /* @0.092a */
var tmpElem = document.getElementById(pos); /* @0.092a */
tmpElem.value = playerChar[2]; /* @0.092a */
/* removed with @0.092d
var tmpElem = document.getElementById("r58");
tmpElem.value = playerChar[2];
*/
var temp = document.Form.out.value;
msg = "Player2 Character changed to:(" +playerChar[2] +") with a length of " +playerChar[2].length +"\n" ;
document.Form.c2.value = playerChar[2]; /* now updae dashboard */
document.gameOptionsForm.c2.value = playerChar[2]; /* now updae Form */
console.log("playerChar[2].substring(0,1)=("+playerChar[2].substring(0,1) +") length is:" +playerChar[2].length );
if(playerChar[2] == "") /* @087a */
{ var elem = document.getElementById(moveFrom[2]) ; /* @087a */
elem.style.backgroundColor = color[2]; /* @087a */
}
document.Form.out.value = msg;
console.log(msg);
}
else
{
playerName[2] = document.Form.n2.value;
playerName[2] = document.gameOptionsForm.n2.value;
var temp = document.Form.out.value;
document.gameOptionsForm.n2.value = playerName[2];
document.Form.n2.value = playerName[2];
msg = "Player2 Name on top & bottom changed to: " +playerName[2] +"\n" ;
document.Form.out.value = msg;
console.log(msg);
}
break;
default:
var errmsg = "Invaild parameter default passed to pCharNameChanged (" +pn+")";
alert(errmsg);
console.log(errmsg);
break;
}
console.log("Leaving pCharNameChanged");
}
/************************************************************************/
/* */
/* pCharChanged("PorN","0,1or 2") @087 */
/* */
/* onChange for player1 c1 on Form (drop down menu) */
/* onChange for player2 c2 on Form (drop down menu) */
/* */
/* */
/************************************************************************/
function pCharChanged(cORn,pn) {
var cORn;
var pn ;
var valSelected = 0; /* Char Selected Number */
foundAt = 0;
console.log("Entering pCharChanged cORn="+cORn +" whoseTurn=" +whoseTurn);
switch(pn) {
case "1": /* Player 1 Char or Namme */
if(cORn == "C")
{ len = document.gameOptionsForm.pcs1.length
for (i = 0; i <len; i++) {
if (document.gameOptionsForm.pcs1[i].selected)
{
valSelected = document.gameOptionsForm.pcs1[i].value;
foundAt = i;
console.log("foundAt=" +foundAt);
i=document.gameOptionsForm.pcs1.length; /* get out of loop, found it */
}
}
console.log("valSelected=" +valSelected + " valSelected = " +valSelected +" at position =" +foundAt);
xChar = " " + String.fromCharCode(valSelected);
playerChar[1] = xChar;
document.Form.c1.value = playerChar[1]; /* now update dashboard */
document.gameOptionsForm.c1.value = playerChar[1]; /* now update Form */
console.log("xChar=" +xChar +" playerChar[1]=" +playerChar[1]);
var pos = moveFrom[1]; /* @0.092a */
/* var tmpElem = document.getElementById("r41"); /* @0.092d */
var tmpElem = document.getElementById(pos); /* @0.092a */
tmpElem.value = playerChar[1]; /* @0.092a */
document.Form.c1.value = playerChar[1]
var temp = document.Form.out.value;
msg = "Player1 Character changed to:(" +playerChar[1] +") with a length of " +playerChar[1].length +"\n" ;
document.Form.c1.value = playerChar[1]; /* now updae dashboard */
console.log("playerChar[1].substring(0,1)=("+playerChar[1].substring(0,1) +") length is:" +playerChar[1].length );/* @087a */
if(playerChar[1] == "") /* @087a */
{ var elem = document.getElementById(moveFrom[1]) ; /* @087a */
elem.style.backgroundColor = color[1]; /* @087a */
}
document.Form.out.value = msg;
console.log(msg);
}
else
{
playerName[1] = document.Form.n1.value;
playerName[1] = document.gameOptionsForm.n1.value;
var temp = document.Form.out.value;
document.Form.n1.value
document.gameOptionsForm.n1.value = playerName[1];
document.Form.n1.value = playerName[1];
msg = "Player1 Name top/bottomchanged to: " +playerName[1] +"\n" ;
document.Form.out.value = msg;
console.log(msg);
}
break;
case "2": /* Player 2 Char or Namme */
if(cORn == "C")
{ len = document.gameOptionsForm.pcs2.length
for (i = 0; i <len; i++) {
if (document.gameOptionsForm.pcs2[i].selected)
{
valSelected = document.gameOptionsForm.pcs1[i].value;
foundAt = i;
console.log("foundAt=" +foundAt);
i=document.gameOptionsForm.pcs2.length; /* get out of loop, found it */
}
}
console.log("valSelected=" +valSelected + " valSelected = " +valSelected +" at position =" +foundAt);
oChar = " " + String.fromCharCode(valSelected);
playerChar[2] = oChar;
document.Form.c2.value = playerChar[2]; /* now updae dashboard */
document.gameOptionsForm.c2.value = playerChar[2]; /* now updae Form */
console.log("oChar=" +oChar +" playerChar[2]=" +playerChar[2]);
var pos = moveFrom[2]; /* @0.092a */
/* var tmpElem = document.getElementById("r58"); /* @0.092d */
var tmpElem = document.getElementById(pos); /* @0.092a */
tmpElem.value = playerChar[2]; /* @0.092a */
var temp = document.Form.out.value;
msg = "Player2 Character changed to:(" +playerChar[2] +") with a length of " +playerChar[2].length +"\n" ;
document.Form.c2.value = playerChar[2]; /* now updae dashboard */
console.log("playerChar[2].substring(0,1)=("+playerChar[2].substring(0,1) +") length is:" +playerChar[2].length );
if(playerChar[2] == "") /* @087a */
{ var elem = document.getElementById(moveFrom[2]) ; /* @087a */
elem.style.backgroundColor = color[2]; /* @087a */
}
document.Form.out.value = msg;
console.log(msg);
}
else
{
playerName[2] = document.Form.n2.value;
playerName[2] = document.gameOptionsForm.n2.value;
var temp = document.Form.out.value;
document.gameOptionsForm.n2.value = playerName[2];
document.Form.n2.value = playerName[2];
msg = "Player2 Name on top & bottom changed to: " +playerName[2] +"\n" ;
document.Form.out.value = msg;
console.log(msg);
}
break;
default:
var errmsg = "Invaild parameter default passed to pCharNameChanged (" +pn+")";
alert(errmsg);
console.log(errmsg);
break;
}
console.log("Leaving pCharNameChanged");
}
/************************************************************************/
/* */
/* getFormFields() - get data off screen no called fro anywhere */
/* */
/* */
/************************************************************************/
function getFormFields() {
playerName[1] = document.Form.n1.value;
playerName[2] = document.Form.n2.value;
playerChar[1] = c1;
playerChar[2] = c2;
alert("in get form Fields remSqCount="+remSqCount);
remSqCount = document.Form.rs.value;
availSqCount= document.Form.as.value;
alert("in get form Fields remSqCount="+remSqCount);
wrapAllowed = document.Form.wr.value;
levelDif = document.Form.lod.value;
}
/************************************************************************/
/* */
/* putFormFields() - put data to screen lsq lSq */
/* */
/* called from: */
/* foc() */
/* sgOs() */
/* doTheHumansRemove() */
/* doTheComputerRemove() */
/* */
/* */
/************************************************************************/
function putFormFields() {
document.Form.n1.value = playerName[1]
document.Form.n2.value = playerName[2]
document.Form.c1.value = playerChar[1]
document.Form.c2.value = playerChar[2]
document.Form.rs.value = remSqCount;
document.Form.as.value = availSqCount;
document.Form.tn.value = turnNumber;
/* document.Form.np.value = numberOfPlayers; @1.003d */
document.Form.arem.value = autoRemove;
document.Form.lod.value = levelDif; /* level of Difficulty */
document.Form.ptn.value = playerName[whoseTurn]; /* name of whose turn @003a*/
document.Form.ptc.value = playerChar[whoseTurn]; /* char of whose turn it is */
document.Form.wr.value = wrapAllowed;
}
/************************************************************************/
/* */
/* Loads the valu[][] table with the values from either */
/* */
/* passed table (name of table to load */
/* */
/* */
/* valuWy1a[][] (valuse when wrapAllowed="Y" or */
/* valuWn1a,b or c[][] (valuse when wrapAllowed="N" */
/* */
/* called from both INIT & sgOS */
/* */
/* @004a */
/************************************************************************/
function initValuArray(tbl)
{
var jj;
var ij;
switch(tbl)
{ /* Level 1a - Beginner No Wrap yields same as count @0.097c */
/* values for No Wrap Allowed valuWn1a */
/****************************************/
/* 0 | 1 2 3 4 5 6 7 8 9 */
/* ------------------------------- */
/* 1 | 7 7 7 7 7 7 7 7 7 */
/* 2 | 7 7 7 7 7 7 7 7 7 */
/* 3 | 7 7 7 7 7 7 7 7 7 */
/* 4 | 7 7 7 7 7 7 7 7 7 */
/* 5 | 7 7 7 7 7 7 7 7 7 */
/* 6 | 7 7 7 7 7 7 7 7 7 */
/* 7 | 7 7 7 7 7 7 7 7 7 */
/* 8 | 7 7 7 7 7 7 7 7 7 */
/* */
/****************************************/
case "valuWn1a":
valuBoardName = "valuWn1a";
/* valuse for No Wrap valuWn (this is the default @0.097c */
valuWn[1][1]= 7; valuWn[1][2]= 7; valuWn[1][3]= 7; valuWn[1][4]= 7; valuWn[1][5]= 7; valuWn[1][6]= 7; valuWn[1][7]= 7; valuWn[1][8]= 7; valuWn[1][8]= 7;
valuWn[2][1]= 7; valuWn[2][2]= 7; valuWn[2][3]= 7; valuWn[2][4]= 7; valuWn[2][5]= 7; valuWn[2][6]= 7; valuWn[2][7]= 7; valuWn[2][8]= 7; valuWn[2][8]= 7;
valuWn[3][1]= 7; valuWn[3][2]= 7; valuWn[3][3]= 7; valuWn[3][4]= 7; valuWn[3][5]= 7; valuWn[3][6]= 7; valuWn[3][7]= 7; valuWn[3][8]= 7; valuWn[3][8]= 7;
valuWn[4][1]= 7; valuWn[4][2]= 7; valuWn[4][3]= 7; valuWn[4][4]= 7; valuWn[4][5]= 7; valuWn[4][6]= 7; valuWn[4][7]= 7; valuWn[4][8]= 7; valuWn[4][8]= 7;
valuWn[5][1]= 7; valuWn[5][2]= 7; valuWn[5][3]= 7; valuWn[5][4]= 7; valuWn[5][5]= 7; valuWn[5][6]= 7; valuWn[5][7]= 7; valuWn[5][8]= 7; valuWn[5][8]= 7;
valuWn[6][1]= 7; valuWn[6][2]= 7; valuWn[6][3]= 7; valuWn[6][4]= 7; valuWn[6][5]= 7; valuWn[6][6]= 7; valuWn[6][7]= 7; valuWn[6][8]= 7; valuWn[6][8]= 7;
valuWn[7][1]= 7; valuWn[7][2]= 7; valuWn[7][3]= 7; valuWn[7][4]= 7; valuWn[7][5]= 7; valuWn[7][6]= 7; valuWn[7][7]= 7; valuWn[7][8]= 7; valuWn[7][8]= 7;
valuWn[8][1]= 7; valuWn[8][2]= 7; valuWn[8][3]= 7; valuWn[8][4]= 7; valuWn[8][5]= 7; valuWn[8][6]= 7; valuWn[8][7]= 7; valuWn[8][8]= 7; valuWn[8][8]= 7;
for (ii=1; ii <= numRows; ii++)
{
for(jj = 1; jj <= numCols; jj++)
{valu[ii][jj] = valuWn[ii][jj]; }
}
break;
/* Level 1b - Beginner No Wrap looses on 9th move @0.097c */
/* values for No Wrap Allowed valuWn1c */
/***************************************/
/* 0 | 1 2 3 4 5 6 7 8 9 */
/*-------------------------------- */
/* 1 | 1 2 4 6 6 4 4 2 1 */
/* 2 | 2 7 6 5 5 6 6 7 2 */
/* 3 | 4 8 8 10 12 10 8 8 4 */
/* 4 | 4 8 10 10 12 10 10 8 4 */
/* 5 | 4 8 10 10 12 10 10 8 4 */
/* 6 | 4 8 8 10 12 10 8 8 4 */
/* 7 | 2 7 6 5 5 6 7 7 2 */
/* 8 | 1 2 4 6 6 4 2 2 1 */
/* */
/***************************************/
case "valuWn1b":
valuBoardName = "valuWn1b";
valuWn[1][1]= 1; valuWn[1][2]= 2; valuWn[1][3]= 4; valuWn[1][4]= 6; valuWn[1][5]= 6; valuWn[1][6]= 6; valuWn[1][7]= 4; valuWn[1][8]= 2; valuWn[1][9]= 1;
valuWn[2][1]= 2; valuWn[2][2]= 7; valuWn[2][3]= 6; valuWn[2][4]= 5; valuWn[2][5]= 5; valuWn[2][6]= 5; valuWn[2][7]= 6; valuWn[2][8]= 7; valuWn[2][9]= 2;
valuWn[3][1]= 4; valuWn[3][2]= 8; valuWn[3][3]= 8; valuWn[3][4]=10; valuWn[3][5]=12; valuWn[3][6]=10; valuWn[3][7]= 8; valuWn[3][8]= 8; valuWn[3][9]= 4;
valuWn[4][1]= 4; valuWn[4][2]= 8; valuWn[4][3]= 10; valuWn[4][4]=10; valuWn[4][5]=12; valuWn[4][6]=10; valuWn[4][7]=10; valuWn[4][8]= 8; valuWn[4][9]= 4;
valuWn[5][1]= 4; valuWn[5][2]= 8; valuWn[5][3]= 10; valuWn[5][4]=10; valuWn[5][5]=12; valuWn[5][6]=10; valuWn[5][7]=10; valuWn[5][8]= 8; valuWn[5][9]= 4;
valuWn[6][1]= 4; valuWn[6][2]= 8; valuWn[6][3]= 8; valuWn[6][4]=10; valuWn[6][5]=12; valuWn[6][6]=10; valuWn[6][7]= 8; valuWn[6][8]= 8; valuWn[6][9]= 4;
valuWn[7][1]= 2; valuWn[7][2]= 7; valuWn[7][3]= 8; valuWn[7][4]= 5; valuWn[7][5]= 5; valuWn[7][6]= 5; valuWn[7][7]= 6; valuWn[7][8]= 7; valuWn[7][9]= 2;
valuWn[8][1]= 1; valuWn[8][2]= 2; valuWn[8][3]= 4; valuWn[8][4]= 6; valuWn[8][5]= 6; valuWn[8][6]= 6; valuWn[8][7]= 4; valuWn[8][8]= 2; valuWn[8][9]= 1;
for (ii=1; ii <= numRows; ii++)
{
for(jj = 1; jj <= numCols; jj++)
{valu[ii][jj] = valuWn[ii][jj]; }
}
break;
;
/* Level 1c - Intermediate No Wrap @0.097c */
/* values for No Wrap Allowed valuWn1b */
/***************************************/
/* 0 | 1 2 3 4 5 6 7 8 9 */
/*------------------------------- */
/* 1 | 1 2 6 6 6 6 6 2 1 */
/* 2 | 2 7 8 8 8 8 8 7 2 */
/* 3 | 6 7 8 8 8 8 8 7 6 */
/* 4 | 6 7 8 10 10 10 8 7 6 */
/* 5 | 6 7 8 10 10 10 8 8 7 */
/* 6 | 6 7 8 8 8 8 8 7 6 */
/* 7 | 2 7 8 8 8 8 8 7 2 */
/* 8 | 1 2 6 6 6 6 7 2 1 */
/* */
/***************************************/
case "valuWn1c":
valuBoardName = "valuWn1c";
valuWn[1][1]= 1; valuWn[1][2]= 2; valuWn[1][3]= 6; valuWn[1][4]= 6; valuWn[1][5]= 6; valuWn[1][6]= 6; valuWn[1][7]= 6; valuWn[1][8]= 2; valuWn[1][9]= 1;
valuWn[2][1]= 2; valuWn[2][2]= 7; valuWn[2][3]= 8; valuWn[2][4]= 8; valuWn[2][5]= 8; valuWn[2][6]= 8; valuWn[2][7]= 8; valuWn[2][8]= 7; valuWn[2][9]= 2;
valuWn[3][1]= 6; valuWn[3][2]= 7; valuWn[3][3]= 8; valuWn[3][4]= 8; valuWn[3][5]= 8; valuWn[3][6]= 8; valuWn[3][7]= 8; valuWn[3][8]= 7; valuWn[3][9]= 6;
valuWn[4][1]= 6; valuWn[4][2]= 7; valuWn[4][3]= 8; valuWn[4][4]=10; valuWn[4][5]=10; valuWn[4][6]=10; valuWn[4][7]= 8; valuWn[4][8]= 7; valuWn[4][9]= 6;
valuWn[5][1]= 6; valuWn[5][2]= 7; valuWn[5][3]= 8; valuWn[5][4]=10; valuWn[5][5]=10; valuWn[5][6]=10; valuWn[5][7]= 8; valuWn[5][8]= 7; valuWn[5][9]= 6;
valuWn[6][1]= 6; valuWn[6][2]= 7; valuWn[6][3]= 8; valuWn[6][4]= 8; valuWn[6][5]= 8; valuWn[6][6]= 8; valuWn[6][7]= 8; valuWn[6][8]= 7; valuWn[6][9]= 6;
valuWn[7][1]= 2; valuWn[7][2]= 7; valuWn[7][3]= 8; valuWn[7][4]= 8; valuWn[7][5]= 8; valuWn[7][6]= 8; valuWn[7][7]= 8; valuWn[7][8]= 7; valuWn[7][9]= 2;
valuWn[8][1]= 1; valuWn[8][2]= 2; valuWn[8][3]= 6; valuWn[8][4]= 6; valuWn[8][5]= 6; valuWn[8][6]= 6; valuWn[8][7]= 6; valuWn[8][8]= 2; valuWn[8][9]= 1;
for (ii=1; ii <= numRows; ii++)
{
for(jj = 1; jj <= numCols; jj++)
{valu[ii][jj] = valuWn[ii][jj]; }
}
break;
/* values for Wrap Allowed valuWy1a @0.097c*/
/***************************************/
/* 0 | 1 2 3 4 5 6 7 8 9 */
/*------------------------------- */
/* 1 | 7 7 7 6 6 6 7 7 7 */
/* 2 | 7 7 6 6 6 6 6 7 7 */
/* 3 | 7 6 6 8 8 8 6 6 7 */
/* 4 | 7 6 6 8 8 8 6 6 7 */
/* 5 | 7 6 6 8 8 8 6 6 7 */
/* 6 | 7 6 6 8 8 6 6 6 7 */
/* 7 | 7 7 6 6 6 6 6 7 7 */
/* 8 | 7 7 7 6 6 6 7 7 7 */
/* */
/***************************************/
case "valuWy1a":
valuBoardName = "valuWy1a";
valuWy[1][1]= 7; valuWy[1][2]= 7; valuWy[1][3]= 7; valuWy[1][4]= 7; valuWy[1][5]= 7; valuWy[1][6]= 7; valuWy[1][7]= 7; valuWy[1][8]= 7; valuWy[1][9]= 7;
valuWy[2][1]= 7; valuWy[2][2]= 7; valuWy[2][3]= 7; valuWy[2][4]= 7; valuWy[2][5]= 7; valuWy[2][6]= 7; valuWy[2][7]= 7; valuWy[2][8]= 7; valuWy[2][9]= 7;
valuWy[3][1]= 7; valuWy[3][2]= 7; valuWy[3][3]= 7; valuWy[3][4]= 7; valuWy[3][5]= 8; valuWy[3][6]= 7; valuWy[3][7]= 7; valuWy[3][8]= 7; valuWy[3][9]= 7;
valuWy[4][1]= 7; valuWy[4][2]= 7; valuWy[4][3]= 7; valuWy[4][4]= 8; valuWy[4][5]= 8; valuWy[4][6]= 8; valuWy[4][7]= 7; valuWy[4][8]= 7; valuWy[4][9]= 7;
valuWy[5][1]= 7; valuWy[5][2]= 7; valuWy[5][3]= 7; valuWy[5][4]= 8; valuWy[5][5]= 8; valuWy[5][6]= 8; valuWy[5][7]= 7; valuWy[5][8]= 7; valuWy[5][9]= 7;
valuWy[6][1]= 7; valuWy[6][2]= 7; valuWy[6][3]= 7; valuWy[6][4]= 7; valuWy[6][5]= 8; valuWy[6][6]= 7; valuWy[6][7]= 7; valuWy[6][8]= 7; valuWy[6][9]= 7;
valuWy[7][1]= 7; valuWy[7][2]= 7; valuWy[7][3]= 7; valuWy[7][4]= 7; valuWy[7][5]= 7; valuWy[7][6]= 7; valuWy[7][7]= 7; valuWy[7][8]= 7; valuWy[7][9]= 7;
valuWy[8][1]= 7; valuWy[8][2]= 7; valuWy[8][3]= 7; valuWy[8][4]= 7; valuWy[8][5]= 7; valuWy[8][6]= 7; valuWy[8][7]= 7; valuWy[8][8]= 7; valuWy[8][9]= 7;
for (ii=1; ii <= numRows; ii++)
{
for(jj = 1; jj <= numCols; jj++)
{valu[ii][jj] = valuWy[ii][jj]; }
}
break;
/* values for default valuWn1a @0.097c*/
/****************************************/
/* 0 | 1 2 3 4 5 6 7 8 9 */
/*------------------------------- */
/* 1 | 4 6 6 6 6 6 6 6 4 */
/* 2 | 6 9 9 9 9 9 9 9 6 */
/* 3 | 6 9 9 10 10 10 9 9 6 */
/* 4 | 6 9 9 12 12 12 9 9 6 */
/* 5 | 6 9 9 12 12 12 9 9 6 */
/* 6 | 6 9 9 10 10 10 9 9 6 */
/* 7 | 6 9 9 9 9 9 9 9 6 */
/* 8 | 4 6 6 6 6 6 6 6 4 */
/* */
/****************************************/
default:
valuBoardName = "valuWn1a";
/* valuse for No Wrap valuWn (this is the default */
valuWn[1][1]= 4; valuWn[1][2]= 6; valuWn[1][3]= 6; valuWn[1][4]= 6; valuWn[1][5]= 6; valuWn[1][6]= 6; valuWn[1][7]= 6; valuWn[1][8]= 6;valuWn[1][9]= 4;
valuWn[2][1]= 6; valuWn[2][2]= 9; valuWn[2][3]= 9; valuWn[2][4]= 9; valuWn[2][5]= 9; valuWn[2][6]= 9; valuWn[2][7]= 9; valuWn[2][8]= 9;valuWn[1][9]= 6;
valuWn[3][1]= 6; valuWn[3][2]= 9; valuWn[3][3]= 9; valuWn[3][4]=10; valuWn[3][5]=10; valuWn[3][6]=10; valuWn[3][7]= 9; valuWn[3][8]= 9;valuWn[1][9]= 6;
valuWn[4][1]= 6; valuWn[4][2]= 9; valuWn[4][3]= 9; valuWn[4][4]=12; valuWn[4][5]=12; valuWn[4][6]=12; valuWn[4][7]= 9; valuWn[4][8]= 9;valuWn[1][9]= 6;
valuWn[5][1]= 6; valuWn[5][2]= 9; valuWn[5][3]= 9; valuWn[5][4]=12; valuWn[5][5]=12; valuWn[5][6]=12; valuWn[5][7]= 9; valuWn[5][8]= 9;valuWn[1][9]= 6;
valuWn[6][1]= 6; valuWn[6][2]= 9; valuWn[6][3]= 9; valuWn[6][4]=10; valuWn[6][5]=10; valuWn[6][6]=10; valuWn[6][7]= 9; valuWn[6][8]= 9;valuWn[1][9]= 6;
valuWn[7][1]= 6; valuWn[7][2]= 9; valuWn[7][3]= 9; valuWn[7][4]= 9; valuWn[7][5]= 9; valuWn[7][6]= 9; valuWn[7][7]= 9; valuWn[7][8]= 9;valuWn[1][9]= 6;
valuWn[8][1]= 4; valuWn[8][2]= 6; valuWn[8][3]= 6; valuWn[8][4]= 6; valuWn[8][5]= 6; valuWn[8][6]= 6; valuWn[8][7]= 6; valuWn[8][8]= 6;valuWn[1][9]= 4;
for (ii=1; ii <= numRows; ii++)
{
for(jj = 1; jj <= numCols; jj++)
{valu[ii][jj] = valuWn1a[ii][jj]; }
}
break;
} /* end of switch */
console.log("initValuArray passed tbl=" +tbl +" completed for valuBoardName:" +valuBoardName );
}
/************************************************************************/
/* */
/* Loads the valu[][] table with the values from either */
/* */
/* valuWy[][] (valuse when wrapAllowed="Y" or */
/* valuWn[][] (valuse when wrapAllowed="N" */
/* */
/* called from both INIT & sgOS */
/* */
/* @004a */
/************************************************************************/
function loadValuArray()
{
var jj;
var ii;
console.log("Enter loadValuArray")
/* console.log("ii=" +ii +" jj=" +jj +"valu[ii][jj]=" +valu[ii][jj] + "valuWy[ii][jj]=" +valuWy[ii][jj]); */
for (ii=1; ii <= numRows; ii++)
{
for(jj = 1; jj <= numCols; jj++)
{
if(wrapAllowed == "Y")
valu[ii][jj] = valuWy[ii][jj];
else
valu[ii][jj] = valuWn[ii][jj];
}
} /* end for loop */
console.log("Exit loadValuArray")
}
/************************************************************************/
/* Assign a value to ever sq on board */
/* */
/* Call countAround1 pass row,col, return newValu */
/* */
/* counts # blanks squares surrounding the each empty sq of the entire */
/* game board(including the center sq */
/* */
/* called from: */
/* foc() */
/* getComputersMove() */
/* @007a */
/************************************************************************/
function recalValuArray()
{
var ij; /* row */
var jj; /* col */
nbc=0; /* 080m d */
document.Form.nbc.value = nbc; /* @079a */
bvTotal = 0 /* bvTotal Board Valu Total */
bvAverage = 0 /* bvAverage Board Valu Average */
var z = 0;
console.log(" Start recalculating: " +valuBoardName +" in recalValuArray..levenDif=" +levelDif +" numRows=" +numRows +" nnumCols=" +numCols );
for (ii=1; ii <= numRows; ii++)
{
for(jj = 1; jj <= numCols; jj++)
{
if(wrapAllowed == "Y" )
{
if(levelDif == 1)
{
valu[ii][jj] = valuWy[ii][jj];
/* document.Form.nbc.value
nbc = nbc + 0 + valu[ii][jj]; 080m del */
}
else
{
valu[ii][jj] = countAround1(ii,jj);
/* document.Form.nbc.value
nbc = nbc + 0 + valu[ii][jj]; @080m del */
if(jj==1 )
z=0;
/* console.log("recalculating valu[][] row " +ii);*/
/* console.log("===> in recalValuArray after calling countAround1 valu[" +ii +"]["+jj +"]=" +valu[ii][jj] ); */
}
}
else
{/* alert("In recalcValuArray for r" +ii +jj ); */
/* console.log(" before calling countAround1 from recalValuArray with valu[" +ii +"]["+jj +"]=" +valuWn[ii][jj] );*/
valu[ii][jj] = countAround1(ii,jj);
/* document.Form.nbc.value
nbc = nbc + 0 + valu[ii][jj]; 080m del */
}
bvTotal = bvTotal + valu[ii][jj];
bvAverage = bvTotal/48;
bvAverage = bvAverage.toFixed(0);
}
} /* end for loop */
console.log(" Finished re-calcing: " + valuBoardName +" Total of valu array: "+bvTotal +" Average of valu[][] : " +bvAverage + " No. Board cks=" +nbc);
}
/************************************************************************/
/* Cout no. of empty squares around the passed sq (ii,jj) */
/* (row,col) */
/* go as deep as level of dfficulty dictates */
/* 1 use valu for every square (dont call this routine) */
/* >1 sum the # or empty surrounding sq for all squares */
/* */
/* return board values if levelDif = 1 or 2 ,else count squares */
/* */
/* Called from: recalcValueArray */
/* */
/************************************************************************/
function countAround1(ii,jj)
{
timesCalled[1] = timesCalled[1] + 1;
/* alert("in CountAround1 timesCalled[1]="+ timesCalled[1]);*/
/* console.log("In countAround1 passed r"+ii + jj +" levelDif=" +levelDif +" wrapAllowed="+wrapAllowed); */
var lr1 = 0;
var lc1 = 0;
var lcount1 = 0; /* local count */
nbc = 0 /* Number Board Checks */
/*if ( jj == 1)
console.log("+In countAround1 processing r"+ii + jj +" levelDif=" +levelDif +" wrapAllowed="+wrapAllowed);
*/
for (lr1=ii-1; lr1<=ii+1 ; lr1++)
{
for(lc1=jj-1; lc1<=jj+1; lc1++)
{
if(wrapAllowed == "Y")
{
rCk = ii;
cCk = jj;
/* console.log("around2: processing r" +lr1 +"" +lc1);*/
if(lr1==0) rCk=8; /* @0.060 */
if(lr1==9) rCk=1; /* @0.060 */
if(lc1==0) cCk=9; /* @0.097c */
if(lc1==10) cCk=1; /* @0.097c */
if ( rCk>= 1 && rCk <=8 && cCk>= 1 && cCk<=9 ) /* @0.060 @0.097c */
{
if(board[rCk][cCk] == 0 )
{nbc = nbc + 1; /* Number Board Checks @080 */
lcount1 = lcount1 + 1;
if(levelDif > 1 )
{
/* console.log("Calling countAorund2");*/
lcount1 = lcount1 + countAround2(rCk,cCk); /* + l + lcount1; */
}
}
else
{
}
}
else
{/* console.log(" cking board["+lr2 +"]]["+lc2 +"] skipping its off the board..");*/
}
}
/* console.log(" -countAround1 after calling countAround2 valu[" +ii +"]["+jj +"]=" +valu[ii][jj] ); */
rCk = i; /* @063 */
cCk = j; /* @063 */
if( (lr1>0 && lr1<=8) && (lc1>0 && lc1 <=9) ) /* @0.060 @0.097c*/
{
if(board[lr1][lc1] == 0 )
{nbc = nbc + 1; /* Number Board Checks@080*/
lcount1 = lcount1 + 1;
if(levelDif > 1 )
lcount1 = lcount1 + countAround2(lr1,lc1) ;
}
}
else
{/* console.log(" cking board["+lr2 +"]]["+lc2 +"] skipping its off the board..");*/
}
} /* end of for lc1 loop */
} /* end for lr1 loop */
/*
if ( jj == 1)
console.log("..returning from countAround1 lcount1 = " +lcount1 +" for sq r"+ii +jj + "wrapAllowed="+wrapAllowed
+" levelDif=" +levelDif);
*/
if( timesCalled[1] % 1000 == 0 )
console.log("returning from countAround1 with r"+rCk +" " +cCk +" = " +lcount1);
return lcount1;
}
/************************************************************************/
/* Cout no. of square empty aroud the sq (ii,jj) passed */
/* (row,col) */
/* */
/* 1 use valu for every square (dont call this routine) */
/* >1 sum the # or empty surrounding sq for all squares */
/* */
/* called from countAround1() */
/* */
/* return board values if levelDif = 1 or 2 ,else count squares */
/* */
/************************************************************************/
function countAround2(ii,jj)
{
timesCalled[2] = timesCalled[2] + 1;
/* alert("in CountAround2 timesCalled[2]=" +timesCalled[2]);*/
/* console.log("In countAround2 passed r"+ii + jj +" levelDif=" +levelDif +" wrapAllowed="+wrapAllowed);*/
var lr2 = 0;
var lc2 = 0;
var lcount2 = 0; /* local count */
/*
if ( jj == 1)
console.log("In countAround2 processing r"+ii + jj +" levelDif=" +levelDif +" wrapAllowed="+wrapAllowed);
*/
for (lr2=ii-1; lr2<=ii+1 ; lr2++)
{
for(lc2=jj-1; lc2<=jj+1; lc2++)
{
if(wrapAllowed == "Y")
{
rCk = ii;
cCk = jj;
/* if(timesCalled[2] % 1000 == 0)
console.log("around2: processing r" +lr2 +"" +lc2);*/
rCk = lr2;
cCk = lc2;
if(lr2==0) rCk=8; /* @0.060 */
if(lr2==9) rCk=1; /* @0.060 */
if(lc2==0) cCk=9; /* @0.097c */
if(lc2==10) cCk=1; /* @0.097c */
if ( rCk>= 1 && rCk <=8 && cCk>= 1 && cCk<=9 ) /* @0.060 @0.097c*/
{
if(board[rCk][cCk] == 0 )
{nbc = nbc + 1; /* Number Board Checks @080 */
lcount2 = lcount2 + 1;
if(levelDif > 2 )
{
/* console.log("Calling countAorund3");*/
lcount2 = lcount2 + countAround3(rCk,cCk);
}
}
else
{
}
}
else
{/* console.log(" cking board["+lr2 +"]]["+lc2 +"] skipping its off the board..");*/
}
}
rCk = i; /* @063 */
cCk = j; /* @063 */
if( (lr2>0 && lr2<=8) && (lc2>0 && lc2 <=9) ) /* @0.097c */
{
if(board[lr2][lc2] == 0 )
{nbc = nbc + 1; /* Number Board Checks @080 */
lcount2 = lcount2 + 1;
if(levelDif > 2 )
lcount2 = lcount2 + countAround3(lr2,lc2) ;
}
}
else
{/* console.log(" cking board["+lr2 +"]]["+lc2 +"] skipping its off the board..");*/
}
} /* end of for lc2 loop */
} /* end for lr2 loop */
/*
if ( jj == 1)
console.log("returning from countAround2 lcount2 = " +lcount2 +" for sq r"+ii +jj + "wrapAllowed="+wrapAllowed
+" levelDif=" +levelDif);
*/
/* console.log("returning from countAround2 with r"+rCk +" " +cCk +" = " +lcount2);*/
return lcount2;
}
/************************************************************************/
/* Cout no. of square empty aroud the sq (ii,jj) passed */
/* (row,col) */
/* */
/* 1 use valu for every square (dont call this routine) */
/* >1 sum the # or empty surrounding sq for all squares */
/* */
/* called from countAround2() */
/* */
/* return board values if levelDif = 1 or 2 ,else count squares */
/* */
/************************************************************************/
function countAround3(ii,jj)
{
timesCalled[3] = timesCalled[3] + 1;
/*if(timesCalled[3] % 1000 == 0)
console.log("In countAround3 passed r"+ii + jj +" levelDif=" +levelDif +" wrapAllowed="+wrapAllowed); */
var lr3 = 0;
var lc3 = 0;
var lcount3 = 0; /* local count */
/*
if ( jj == 1)
console.log("In countAround3 processing r"+ii + jj +" levelDif=" +levelDif +" wrapAllowed="+wrapAllowed);
*/
for (lr3=ii-1; lr3<=ii+1 ; lr3++)
{
for(lc3=jj-1; lc3<=jj+1; lc3++)
{
if(wrapAllowed == "Y")
{
rCk = ii;
cCk = jj;
/*if(timesCalled[3] % 1000 == 0)
console.log("around3: processing r" +lr3 +"" +lc3);*/
rCk = lr3;
cCk = lc3;
if(lr3==0) rCk=8; /* @0.060 */
if(lr3==9) rCk=1; /* @0.060 */
if(lc3==0) cCk=9; /* @0.097c */
if(lc3==10) cCk=1; /* @0.097c */
if ( rCk>= 1 && rCk <=8 && cCk>= 1 && cCk<=9 ) /* @0.060 @0.097c */
{
if(board[rCk][cCk] == 0 )
{nbc = nbc + 1; /* Number Board Checks @080 */
lcount3 = lcount3 + 1;
if(levelDif > 3 )
{
/* console.log("Calling countAorund4");*/
lcount3 = lcount3 + countAround4(rCk,cCk) ;
}
}
else
{
}
}
else
{/* console.log(" cking board["+lr3 +"]]["+lc3 +"] skipping its off the board..");*/
}
}
rCk = i; /* @063 */
cCk = j; /* @063 */
if( (lr3>0 && lr3<=8) && (lc3>0 && lc3 <=9) ) /* @0.060 @0.097c */
{
if(board[lr3][lc3] == 0 )
{nbc = nbc + 1; /* Number Board Checks @080 */
lcount3 = lcount3 + 1;
if(levelDif > 3 )
lcount3 = lcount3 + countAround4(rCk,cCk);
}
}
else
{/* console.log(" cking board["+lr3 +"]]["+lc3 +"] skipping its off the board..");*/
}
} /* end of for lc3 loop */
} /* end for lr3 loop */
/*
if(j==1)
console.log("returning from countAround3 lcount3 = " +lcount3 +" for sq r"+ii +jj + "wrapAllowed="+wrapAllowed
+" levelDif=" +levelDif);
*/
/* console.log("returning from countAround3 with r"+rCk +" " +cCk +" = " +lcount3);*/
return lcount3;
}
/************************************************************************/
/* Cout no. of square empty aroud the sq (ii,jj) passed */
/* (row,col) */
/* */
/* 1 use valu for every square (dont call this routine) */
/* >1 sum the # or empty surrounding sq for all squares */
/* */
/* called from countAround1() */
/* */
/* return board values if levelDif = 1 or 2 ,else count squares */
/* */
/************************************************************************/
function countAround4(ii,jj)
{
/*
if(timesCalled[5] % 1000 == 0)
console.log("In countAround4 passed r"+ii + jj +" levelDif=" +levelDif +" wrapAllowed="+wrapAllowed);
*/
timesCalled[4] = timesCalled[4] + 1;
/* alert("in CountAround4 timesCalled[4]=" +timesCalled[4]);*/
var lr4 = 0;
var lc4 = 0;
var lcount4 = 0; /* local count */
/*
if ( jj == 1)
console.log("In countAround4 processing r"+ii + jj +" levelDif=" +levelDif +" wrapAllowed="+wrapAllowed);
*/
for (lr4=ii-1; lr4<=ii+1 ; lr4++)
{
for(lc4=jj-1; lc4<=jj+1; lc4++)
{
if(wrapAllowed == "Y")
{
rCk = ii;
cCk = jj;
/* console.log("around4: processing r" +lr4 +"" +lc4);*/
rCk = lr4;
cCk = lc4;
if(lr4==0) rCk=8; /* @0.060 */
if(lr4==9) rCk=1; /* @0.060 */
if(lc4==0) cCk=9; /* @0.097c */
if(lc4==10) cCk=1; /* @0.097c */
if ( rCk>= 1 && rCk <=8 && cCk>= 1 && cCk<=9 ) /* @0.060 @0.097c*/
{
if(board[rCk][cCk] == 0 )
{nbc = nbc + 1; /* Number Board Checks @080 */
lcount4 = lcount4 + 1;
if(levelDif > 4 )
lcount4 = lcount4 + countAround5(rCk,cCk); /* @0.093a */
}
else
{
}
}
else
{/* console.log(" cking board["+lr4 +"]]["+lc4 +"] skipping its off the board..");*/
}
}
rCk = i; /* @063 */
cCk = j; /* @063 */
if( (lr4>0 && lr4<=8) && (lc4>0 && lc4 <=9) ) /* @0.060 @0.097c*/
{
if(board[lr4][lc4] == 0 )
{nbc = nbc + 1; /* Number Board Checks @080 */
lcount4 = lcount4 + 1;
if(levelDif > 4 )
lcount4 = lcount4 + 1; /* @0.093a */
}
}
else
{/* console.log(" cking board["+lr4 +"]]["+lc4 +"] skipping its off the board..");*/
}
} /* end of for lc4 loop */
} /* end for lr4 loop */
/*
console.log("returning from countAround4 lcount4 = " +lcount4 +" for sq r"+lr4 +lc4 + "wrapAllowed="+wrapAllowed
+" levelDif=" +levelDif);
*/
/*
if(levelDif > 4)
lcount4 = lcount4 + countAround5(rCk,cCk);
*/
/*console.log("returning from countAround4 with r"+rCk +" " +cCk +" = " +lcount4);*/
return lcount4;
}
/************************************************************************/
/* Cout no. of square empty aroud the sq (ii,jj) passed */
/* (row,col) */
/* */
/* 1 use valu for every square (dont call this routine) */
/* >4 sum the # or empty surrounding sq for all squares */
/* called from countAround4() */
/* */
/* return board values if levelDif = 1 or 2 ,else count squares */
/* */
/************************************************************************/
function countAround5(ii,jj)
{
var lr5 = 0;
var lc5 = 0;
var lcount5 = 0; /* local count */
timesCalled[5] = timesCalled[5]+1;
/* alert("In countAround5 should never get here"); comment out since adding levelDif=5 0.093c */
/*console.log("In countAround5 passed r"+ii + jj +" levelDif=" +levelDif +" wrapAllowed="+wrapAllowed); @0.093c */
for (lr5=ii-1; lr5<=ii+1 ; lr5++)
{
for(lc5=jj-1; lc5<=jj+1; lc5++)
{
if(wrapAllowed == "Y")
{if(lr5==0) rCk=8; /* @0.060 */
if(lr5==9) rCk=1; /* @0.060 */
if(lc5==0) cCk=9; /* @0.097c */
if(lc5==10) cCk=1; /* @0.097c */
/* console.log("around5: processing r" +lr5 +"" +lc5);*/
}
else /* @063 */
{
rCk = i; /* @063 */
cCk = j; /* @063 */
rCk = lr5;
cCk = lc5;
}
if( (rCk>0 && rCk<=8) && (cCk>0 && cCk <=9) ) /* @0.060 @0.097c*/
{
if(board[rCk][cCk] == 0 )
{nbc = nbc + 1; /* Number Board Checks @080 */
lcount5 = lcount5 + 1;
}
}
else
{/* console.log(" cking board["+lr5 +"]]["+lc5 +"] skipping its off the board..");*/
}
} /* end of for lc5 loop */
} /* end for lr5 loop */
/* console.log("returning from countAround5 lcount5 = " +lcount5 +" for sq r"+ii +jj + " wrapAllowed="+wrapAllowed
+" levelDif=" +levelDif); */
if(timesCalled[5] % 1000000 == 0)
console.log("in ca5 timesCalled: " +timesCalled[5] + " r" + " ii=" +ii +" jj=" +jj );
/*
console.log("returning from countAround5 with r"+rCk +" " +cCk +" = " +lcount5);
console.log(" ");
*/
return lcount5;
}
/************************************************************************/
/* Cout /sum values of the surrounding squares (ii,jj) passed */
/* (row,col) */
/* This is an alternate method for determining move */
/* */
/* currently not called */
/* */
/* */
/* @007a */
/************************************************************************/
function countValuesAround(ii, jj)
{
var lr1; /* local row1 */
var lc1; /* local Col1 */
lcount = 0; /* local count */
/* alert("In countValuesAround, passed row " +ii +" passed col = "+jj); */
/* console.log("In countAround processing r"+ii + jj); */
for (lr1=ii-1; lr1<=ii+1 ; lr1++)
{
for(lc1=jj-1; lc1<=jj+1; lc1++)
{
if(wrapAllowed == "Y")
{/* what will i do */
}
else /* wrap not allowed */
{if (( lr1>0 && lr1<=8) && (lc1>0 && lc1<=9) ) /* @0.060 @0.097c */
{if(board[lr1][lc1] == 0 )
{nbc = nbc + 1; /* Number Board Checks @080 */
lcount=lcount + valu[ii][jj];
/* console.log(" cked board["+lr1 +"][" +lc1 +"]=" +board[lr1][lc1] +"lcount=" +lcount); */ }
else
{/* console.log(" cked board[][] not 0 dont count it");*/ }
} /* else for id lr1>0 &&& .... */
else /* board[][] <> 0 */
{ /* console.log(" row,col not in range of row="+Number.parseInt(ii-1) +" to row="+Number.parseInt(ii+1)
+" & col=" +Number.parseInt(col-1) +" to col=" +Number.parseInt(col+1) ); */ }
} /* end of else wrap not allowed */
} /* end of for lc1 loop */
} /* end for lr1 loop */
/* console.log("returning lcount = " +lcount +" for sq r"+ii +jj ); */
/* alert ("return lcount=" +lcount +" for sq " +ii +jj);*/
return lcount;
}
/************************************************************************/
/* */
/* gameOptions() */
/* called from onClick on DispVars Button on Form */
/* */
/************************************************************************/
function dispVars() {
alert("Display Variables " +"\n"
+ " ver = " +ver +"\n"
+ " numberOfPlayers = " +numberOfPlayers +"\n"
+ " pac = " +pac +"\n"
+ " goesFirst = " +goesFirst +"\n"
+ " comp = " +comp +"\n"
+ " human = " +human +"\n"
+ " wrapAllowed = " +wrapAllowed +"\n"
+ " levelDif = " +levelDif +"\n"
+ " autoRemove = " +autoRemove +"\n"
+ " printChar = " +printChar +"\n"
+ " xChar = " +xChar +"\n"
+ " oChar = " +oChar +"\n"
+ " turnNumber = " +turnNumber +"\n"
+ " whoseTurn = " +whoseTurn +"\n"
+ " reqAction = " +reqAction +"\n"
+ " turnName[1] = " +turnName[1] +"\n"
+ " turnName[2] = " +turnName[2] +"\n"
+ " availSqCount = " +availSqCount +"\n"
+ " remSqCount = " +remSqCount +"\n"
+ " nbc (#BoardCks) = " +nbc +"\n"
+ " playerChar[1] = " +playerChar[1] +"\n"
+ " playerChar[2] = " +playerChar[2] +"\n"
+ " playerName[1] = " +playerName[1] +"\n"
+ " playerName[2] = " +playerName[2] +"\n"
+ " moveFrom[1] = " +moveFrom[1] +"\n"
+ " moveFrom[2] = " +moveFrom[2] +"\n"
+ " moveTo[1] = " +moveTo[1] +"\n"
+ " moveTo[2] = " +moveTo[2] +"\n"
+ " rDif = " +rDif +"\n"
+ " cDif = " +cDif +"\n"
+ " image[1] = " +image[1] +"\n"
+ " image[2] = " +image[2] +"\n"
+ " whoDoesntHaveMove=" +whoDoesntHaveMove +"\n"
+ " playerName[whoDoesntHaveMove] = " +playerName[whoDoesntHaveMove] +"\n"
+ " playerChar[whoDoesntHaveMove] = " +playerChar[whoDoesntHaveMove] +"\n"
);
}
/************************************************************************/
/* */
/* Pad right ot being called */
/* */
/************************************************************************/
function padRight(s, c, n) {
if (! s || ! c || s.length >= n) {
return s; }
var max = (n - s.length)/c.length;
for (var i = 0; i < max; i++) {
s += c; }
return s;
}
/************************************************************************/
/* */
/* left padding s with c to a total of n chars - not being called */
/* */
/************************************************************************/
function padLeft(s, c, n) {
if (! s || ! c || s.length >= n) {
return s; }
var max = (n - s.length)/c.length;
for (var i = 0; i < max; i++) {
s = c + s; }
return s;
}
/************************************************************************/
/* */
/* trim Left not being called */
/* */
/************************************************************************/
function trimLeft(str){
return str.replace(/^\s+/, '');
}
/************************************************************************/
/* */
/* Left function */
/* */
/************************************************************************/
function Left(str, n){
if (n <= 0)
return "";
else if (n > String(str).length)
return str;
else
return String(str).substring(0,n);
}
/************************************************************************/
/* */
/* Right function */
/* */
/************************************************************************/
function Right(str, n){
if (n <= 0)
return "";
else if (n > String(str).length)
return str;
else {
var iLen = String(str).length;
return String(str).substring(iLen, iLen - n);
}
}
/************************************************************************/
/* */
/* set background color usuallu of onBlur or onMouseover, etc */
/* */
/* currently called from sgOs() */
/* */
/************************************************************************/
function setbg(color)
{
var color;
document.bgColor=color;
document.body.style.backgroundColor=color;
return color
}
/************************************************************************/
/* */
/* removeOptions from listbox */
/* */
/* currently - not being called */
/* */
/************************************************************************/
function removeOptions(selbox)
{
var i;
var selbox;
alert("got here selbox=" +selbox);
alert("selbox.options.length="+selbox.options.length +"\n"
+"selbox.options[0].text=" +selbox.options[0].text +"\n"
+"selbox.options.selectedIndex=" +selbox.options.selectedIndex +"\n"
+"selbox.options[1].text=" +selbox.options[1].text +"\n"
+"selbox.options[2].text=" +selbox.options[2].text +"\n"
+"selbox.options[0].value=" +selbox.options[0].value +"\n"
+"selbox.options[1].value=" +selbox.options[1].value +"\n"
+"selbox.options[2].value=" +selbox.options[2].value +"\n"
+"selbox.options[0].selected=" +selbox.options[0].selected +"\n"
+"selbox.options[1].selected=" +selbox.options[1].selected +"\n"
+"selbox.options[2].selected=" +selbox.options[2].selected +"\n" )
var temp
temp = selbox.options.length-1
for(i=selbox.options.length-1;i>=0;i--)
{
if(selbox.options[i].selected)
{
/* selbox.remove(i); */
alert("looping for i=" +i +" to 0" +"\n"
+ "selbox.options.length="+selbox.options.length +"\n"
+"selbox.options[0].text=" +selbox.options[0].text +"\n"
+"selbox.options.selectedIndex=" +selbox.options.selectedIndex +"\n"
+"selbox.options[1].text=" +selbox.options[1].text +"\n"
+"selbox.options[2].text=" +selbox.options[2].text +"\n"
+"selbox.options[0].value=" +selbox.options[0].value +"\n"
+"selbox.options[1].value=" +selbox.options[1].value +"\n"
+"selbox.options[2].value=" +selbox.options[2].value +"\n"
+"selbox.options[0].selected=" +selbox.options[0].selected +"\n"
+"selbox.options[1].selected=" +selbox.options[1].selected +"\n"
+"selbox.options[2].selected=" +selbox.options[2].selected +"\n" )
alert("selected i=" +i +selbox.options[i].selected)
document.Form.n2la.options[i] = null;
document.Form.ptla.options[i] = null;
alert("removed element "+1 +" from other 2 options lists" )
}
}
}
/************************************************************************/
/* */
/* Init2() ipa - initform Play Against Computer */
/* Another Person */
/* */
/* iwgf - initformB WhoGoesFirst player1 or 2 */
/* */
/* called from init - currently commented out */
/* */
/* */
/************************************************************************/
function init2() {
myWindow=window.open('','My Window','left=650,top=450,width=350,height=450,resizable=yes,scrollbars=yes' );
myWindow.document.write("<form name=initformB > ");
myWindow.document.write("<body bgcolor=darkseagreen > <title> ISOLATION Game Settings </title> ");
myWindow.document.write("<p><b><font color=darkgreen size=+1> <center> Game Settings </b><br> ");
myWindow.document.write("</center> </p> ");
myWindow.document.write("<font color=black size=1> ");
myWindow.focus()
myWindow.document.write("<form name=init2 bgcolor= darkseagreen color=black> ");
myWindow.document.write("<fieldset class='fieldset' style='border: 2px solid light yellow; width:400px' >" );
myWindow.document.write("<legend> <font size=3 > Opponent Selection </font> </legend>");
myWindow.document.write("<font color=white size=-1> <br>");
myWindow.document.write("<input type='radio' STYLE='color: #FFFFFF; background-color: #72A4D2;' value=' ' name='ipa' onClick='GetSelectedItem(this.form)'size=6 > Play Against Another Person <br><br>");
myWindow.document.write("<input type='radio' STYLE='color: #FFFFFF; background-color: #72A4D2;' value=' ' name='ipa' onClick='GetSelectedItem(this.form)'size=6 checked > Play Against The Computer <br><br> ");
myWindow.document.write("</fieldset><br><br>");
myWindow.document.write("<fieldset class='fieldset' style='border: 2px solid light yellow; width:400px' >" );
myWindow.document.write("<legend> <font size=3 color=black > Player Selection </font> </legend>");
myWindow.document.write("<font color=blue size=-1> <br>");
myWindow.document.write("Player1 Name: ");
myWindow.document.write("<input type='text' value='Player 1' name='n1' class=inputName STYLE='color:blue;background-color:lightblue' > -- X --");
myWindow.document.write("<input type='radio' STYLE='color: #FFFFFF; background-color: #72A4D2;' value=' ' name='iwgf' onClick='GetSelectedItem(this.form)'size=6 checked > Goes First <br> ");
myWindow.document.write("<font color=red size=-1> <br>");
myWindow.document.write("Player2 Name: ");
myWindow.document.write("<input type='text' value='Player 2' name='n2' class=inputName STYLE='color:red;background-color:lightpink' > -- O --");
myWindow.document.write("<input type='radio' STYLE='color: #FFFFFF; background-color: #72A4D2;' value=' ' name='iwgf' onClick='GetSelectedItem(this.form)'size=6 > Goes First <br> ");
myWindow.document.write("</fieldset><br>");
myWindow.document.write("<br><INPUT TYPE='button'; Style='font-style:italic; font-size:100%; ' value='Start Game' onClick='window.close()'> ");
myWindow.document.write("<form> ");
myWindow.document.write("</body> ");
var temp1 = document.initformB.rb1.value;
var temp2 = document.initformB.rb2.value;
var tempn1 = document.initformB.n1.value;
var tempn2 = document.initformB.n2.valuee;
result = temp1 +"," + temp2 +"," + tempn1 +"," +tempn2;
return result
}
/************************************************************************/
/* */
/* gameOverWindow() called from ckIfGameOver() */
/* */
/* @1.010a */
/************************************************************************/
function gameOverWindow() {
temp = new Date().getTime() - strtTime; /* @1.011 a */
temp = temp.toFixed(2); /* @1.011 a */
et = temp/1000/60; /* @1.011 a */
et = et.toFixed(2); /* @1.011 a */
myWindow=window.open('','','width=450,height=370,top=200, left=680,resizable=yes,scrollbars=yes' );
myWindow.document.write("<body bgcolor=darkseagreen > <title> GAME OVER </title> ");
myWindow.document.write("<b><u><font color=black size=+1> <center> Game Over </u></b><br></center> ");
myWindow.document.write("</center> ");
myWindow.document.write("<font color=black size=1> ");
myWindow.document.write("<b><u><font color=darkgreen size=+3> </u></b><center> ");
myWindow.document.write("<br>" +playerName[winningPlayer]+ "(" +playerChar[winningPlayer] +") wins!!" );
myWindow.document.write("<br> in " +et + " minutes in " +turnCount[winningPlayer] +" moves. ");
myWindow.document.write("<br> </center> ");
myWindow.document.write("<b><font color=black size=+1> </b> ");
myWindow.document.write("<br> Level of Difficulty : " +levelDif );
myWindow.document.write("<br> ");
myWindow.document.write("<br> Winning Player Name : " +playerName[winningPlayer] );
myWindow.document.write("<br> Winning Player Char : " +playerChar[winningPlayer] );
myWindow.document.write("<br> ");
myWindow.document.write("<br> Opponent Player Name : " +playerName[whoDoesntHaveMove] );
myWindow.document.write("<br> Opponent Player Char : " +playerChar[whoDoesntHaveMove] );
myWindow.document.write("<br> ");
myWindow.document.write("<br> <center> ");
myWindow.document.write("<INPUT TYPE='button'; Style='font-style:italic; font-size:100%; ' value='Close' onClick='window.close()'> ");
myWindow.document.write("<br> </center> ");
}
/************************************************************************/
/* */
/* gameSummary() called from onClick button of Form */
/* */
/* */
/************************************************************************/
function gameSummary() {
myWindow=window.open('','','width=650,height=555,resizable=yes,scrollbars=yes' );
myWindow.document.write("<body bgcolor=darkseagreen > <title> ISOLATION Game Summary </title> ");
myWindow.document.write("<p><b><u><font color=black size=+1> <center> Game Summary </u></b><br> ");
myWindow.document.write("</center> </p> ");
myWindow.document.write("<font color=black size=3> ");
myWindow.document.write("<br> Ver : " +ver + " ");
myWindow.document.write("<br> ");
myWindow.document.write("<br> Start Time : " +startTime +" ");
myWindow.document.write("<br> End Time : " +endTime );
myWindow.document.write("<br> Elapsed Time : " +et +" minutes(" +et*60 +" sec.)" ); /*@1.003c */
console.log("et=" +et);
myWindow.document.write("<br> Winning Player Name : " +winningPlayer +" " +playerName[winningPlayer]);
myWindow.document.write("<br> Player who cannot move : " +whoDoesntHaveMove +" ");
myWindow.document.write("<br> Number of Squares Removed : " +remSqCount +" ");
myWindow.document.write("<br> Number of Available Squares: " +availSqCount+ " ");
myWindow.document.write("<br> Who went first : "+playerName[goesFirst] +" ");
myWindow.document.write("<br> turnNumber : " +turnNumber +" ");
myWindow.document.write("<br> Player 1 turn Count : " +turnCount[1] +" (moveTo as counts 1, remove as counts 1) ");
myWindow.document.write("<br> Player 2 turn Count : " +turnCount[2] +" ");
myWindow.document.write("<br> Play against Computer: " +pac +" ");
myWindow.document.write("<br> Level of Difficulty : " +levelDif +" ");
myWindow.document.write("<br> wrapAllowed : " +wrapAllowed +" ");
myWindow.document.write("<br> autoRemove : " +autoRemove +" ");
myWindow.document.write("<br> Player 1 total pts : " +ptsTotal[1] +" ");
myWindow.document.write("<br> Player 2 total pts : " +ptsTotal[2] +" ");
myWindow.document.write("<br> Including Bonus Pts :" +10**levelDif +" awarded to player " +winningPlayer +" " +playerName[winningPlayer] +" ");
myWindow.document.write("<br> ValuBoardName : " +valuBoardName +" ");
myWindow.document.write("<br> timesCalledlvv : " +timesCalledlvv +" ");
myWindow.document.write("<br> No. Board Cks nbc : " +nbc +" ");
myWindow.document.write("<br> ");
myWindow.document.write("<br> --- End of Game Summary --- ");
myWindow.document.write("</body> ");
myWindow.document.write("<form> <font color=black > ");
myWindow.document.write("<INPUT TYPE='button'; Style='font-style:italic; font-size:100%; ' value='Close' onClick='window.close()'> ");
myWindow.document.write("<INPUT TYPE='button'; Style='font-style:italic; font-size:100%; ' value='e-mail this' onClick='emailThis();windowclose()'> ");
myWindow.document.write("<form> ");
myWindow.document.write("</body> ");
myWindow.focus()
}
/************************************************************************/
/* */
/* setCookie @0.099 not being used yet */
/* */
/* */
/************************************************************************/
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/" +";" +"Secure" +";" ;
}
/************************************************************************/
/* */
/* getCookie @0.099 not being used yet */
/* */
/* */
/************************************************************************/
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
/************************************************************************/
/* */
/* checkCookie @0.099 not being used yet */
/* */
/* */
/************************************************************************/
function checkCookie() {
var username = getCookie("username");
if (username != "") {
alert("Welcome again " + username);
} else {
username = prompt("Please enter your name:", "");
if (username != "" && username != null) {
setCookie("username", username, 365);
}
}
}
/************************************************************************/
/* */
/* e-mailThis() ?????? not working yet */
/* */
/* */
/************************************************************************/
function emailThis()
{
alert("In emailThis");
console.log("in emailThis");
myWindow=window.open('','','width=650,height=555,resizable=yes,scrollbars=yes' );
window.open('mailto:tomyy@optonline.net?subject=from Isolate Function: emailThis()&body=body');
window.close();
mywindow.close();
alert("Leaving emailThis");
console.log("leaving emailThis");
}
/************************************************************************/
/* */
/* e-mailit() ?????? not working yet */
/* */
/* */
/************************************************************************/
function emailit()
{
alert("in emailit");
console.log("in emailit");
myWindow=window.open('','','width=650,height=555,resizable=yes,scrollbars=yes' );
window.open('mailto:tomyy@optonline.net?subject=from Isolate Function &body=body');
alert("Leaving emailit");
console.log("Leaving emailit");
}
/************************************************************************/
/* */
/* Helpem() display help in a new window */
/* */
/* */
/************************************************************************/
/************************************************************************/
/* */
/* Helpem() display help in a new window */
/* */
/* */
/************************************************************************/
function helpem() {
myWindow=window.open('','','width=695,height=715,resizable=yes,scrollbars=yes' )
myWindow.document.write("<body bgcolor=darkseagreen > <center> <title> ISOL Help </title> ");
myWindow.document.write("<p><b><u><font color=black size=+1> Help for ISOLATION ver 1.019 </u></b> ");
myWindow.document.write("<a href='mailto:tomyy@optonline.net?subject=ISOLATE'>... by:Tom Yurkovic </a> ");
myWindow.document.write("</center> </p> ");
myWindow.document.write("<font color=black size=+1> ");
myWindow.document.write("<br> Object of the game is to ISOLATE your opponent so ");
myWindow.document.write("<br> there are no empty adjacent squares for them to move to. ");
myWindow.document.write("<br> ");
myWindow.document.write("<br> It is played on a grid of 8 rows & 9 columns. ");
myWindow.document.write("<br> Positions are referenced by row,column, for example row 3 column 1 is designated as 31 ");
myWindow.document.write("<br> ");
myWindow.document.write("<br> ");
myWindow.document.write("<br> Each move consists of the following: ");
myWindow.document.write("<br> 1) Move your piece to a new square. ");
myWindow.document.write("<br> 2) Remove a square from game board so that no one can move to. (this happens ");
myWindow.document.write("<br> automatically if autoRemove = 'yes'. This can be changed in the ");
myWindow.document.write("<br> Set game Options Menu. Default is NO. ");
myWindow.document.write("<br> ");
myWindow.document.write("<br> <strong><em> When a player cannot move to an empty adjacent square, they loose. </em></strong> ");
myWindow.document.write("<br> ");
myWindow.document.write("<br> ");
myWindow.document.write("<br> Important messages will appear in the text area below: --- Important Message Below --- ");
myWindow.document.write("<br> ");
myWindow.document.write("<br> <strong> Make changes to game settings in Set Game Options below the gameboard. </strong> ");
myWindow.document.write("<br> ");
myWindow.document.write("<br>    1) The game is set to default to Play Against The Computer.(One Player) ");
myWindow.document.write("<br>    2) You can set Who Goes First ");
myWindow.document.write("<br>    3) You can change to allow or not allow Wrap. ");
myWindow.document.write("<br>        - if wrap is off you cannot move beyond any edge. ");
myWindow.document.write("<br>        - if wrap is on then : ");
myWindow.document.write("<br>          - moving left of column 1 moves you to column 9 ");
myWindow.document.write("<br>          - moving right of column 9 moves you to column 1 ");
myWindow.document.write("<br>          - moving up of row 1 moves you to row 8 ");
myWindow.document.write("<br>          - moving down from row 8 moves you to row 1 ");
myWindow.document.write("<br> ");
myWindow.document.write("<br>          - moving down & left from 9,1 moves you to 1,9 ");
myWindow.document.write("<br>          - moving down & right from 8,9 moves you to 1,1 ");
myWindow.document.write("<br>          - moving up & left from 1,1 moves you to 8,9 ");
myWindow.document.write("<br>          - moving up & right from 1,9 moves you to 8,1 ");
myWindow.document.write("<br> ");
myWindow.document.write("<br>      * Essentially the game board is folded so: ");
myWindow.document.write("<br>        - left side connects to right side ");
myWindow.document.write("<br>          ex: from r3c1 with wrap on you can move to 2,9, 3,9 or 4,9 ");
myWindow.document.write("<br>       - top connects to bottom ");
myWindow.document.write("<br>          ex: from r1c5 with wrap on you can move to 9,4, 9,5 or 9,6 ");
myWindow.document.write("<br>        - upper left side connects to lower right ");
myWindow.document.write("<br>          ex: from r1c1 with wrap on you can move to 1,9 2,9, 8,1 8,2 or 8,9 ");
myWindow.document.write("<br>       - lower left side connects to upper ");
myWindow.document.write("<br>          ex: from r8c9 with wrap on you can move to 1,9 1,8, 8,1 7,1 or 1,1 ");
myWindow.document.write("<br> ");
myWindow.document.write("<br>    5) You can set how well the computer plays in Level of Difficulty ");
myWindow.document.write("<br>        - click 'Save Game Options Settings' button ");
myWindow.document.write("<br> ");
myWindow.document.write("<br>    5) You can set autoRemove On or Off. ");
myWindow.document.write("<br>        - When on, a turn consists of one part, move to an adjacant square. ");
myWindow.document.write("<br> The computer will automatically remove the square you just moved from.");
myWindow.document.write("<br> ");
myWindow.document.write("<br>        - When off, a turn consists of two parts: ");
myWindow.document.write("<br> 1) Move your piece to a new square. ");
myWindow.document.write("<br> 2) Remove a square from game board that no one can move to.");
myWindow.document.write("<br> ");
myWindow.document.write("<br> ");
myWindow.document.write("<br>     Click Game Summary button to see a summary of game settings(variable values) ");
myWindow.document.write("<br> ");
myWindow.document.write("<br>     Click gameLog button at the end of the game to see a log of each turn, ");
myWindow.document.write("<br>     where you moved from, where you moved to & the sq you removed. ");
myWindow.document.write("<br> ");
myWindow.document.write("<br>      Click the Hint button & a sunburst character will appear in the square you can move to.");
myWindow.document.write("<br> ");
myWindow.document.write("<br>      Hover Mouse over Hint button & see the value of the adjacant squares in Message Area ");
myWindow.document.write("<br>      The higher the number the better the move. Helps you pick a move. ");
myWindow.document.write("<br> ");
myWindow.document.write("<br> <strong> Optionally you can Customize the game area such as: </strong> ");
myWindow.document.write("<br>    - set the color of the squares you remove ");
myWindow.document.write("<br>    - set the background color of the screen ");
myWindow.document.write("<br>    - set the color of the game board ");
myWindow.document.write("<br>    - set the size of the game board ");
myWindow.document.write("<br> ");
myWindow.document.write("<br> <strong> Optionally you can customize Player Information </strong> ");
myWindow.document.write("<br>    - set the color of each players character ");
myWindow.document.write("<br>    - set the character for each player ( from keyboard) or ");
myWindow.document.write("<br>    - select a character by name from a Dropdown Selection List. ");
myWindow.document.write("<br>    - change the name of each player ");
myWindow.document.write("<br>    - change the Starting Position name of each player ");
myWindow.document.write("<br> ");
myWindow.document.write("<br> --- End of Help --- ");
myWindow.document.write("</body> ");
myWindow.document.write("<form> <font color=black > ");
myWindow.document.write("<INPUT TYPE='button'; Style='font-style:italic; font-size:100%; ' value='Close' onClick='window.close()'> ")
myWindow.document.write("<form> ");
myWindow.document.write("</body> ");
myWindow.focus()
}
/************************************************************************/
/* */
/* setStrtPos @1.004 passed 1 - for player 2, 2 for player 2 */
/* */
/* use to be 4,1 for x 5,9 for O */
/* */
/* Only allow if turnNumber <= 1 */
/* check requested position they want if its an empty square. */
/* set board[][] of from pos to 0 (saying empty */
/* set board[][] of new position to 1 for player1 */
/* set board[][] of new position to 2 for player2 */
/* */
/* called from onChange on gameOptionsForm for sp1 & sp2 to change */
/* the starting position for player 1 &/or 2 */
/* */
/* @1.004a 1.005c */
/************************************************************************/
function setStrtPos(plyr) {
var emsg = "";
var errfnd = "N";
var r = plyr.substring(0,1); /* Be sure 1st char of input is "r" followed by ## */
if (turnNumber > 1)
{ errfnd = "Y";
emsg = emsg + " Can only change starting positions prior to the start of the game! r## format"+"\n";
console.log("Can only change starting positions prior to the start of the game! r## format");
alert("Can only change starting positions prior to the start of the game! r## format");
}
var fp; /* From Position r## */
var rp; /* Requested (to) Position r## */
fp = moveFrom[plyr]; /* From Position in r## format */
if (plyr == 1) /* get input from screen */
{rp = document.gameOptionsForm.sp1.value; } /* player1 */
else
{rp = document.gameOptionsForm.sp2.value;} /* player2 */
if (rp.substring(0,1) != "r") /* force input to be r## */
{ rp = "r" + rp.substring(1,3);
console.log("Auto-corrected input to " +rp);
/* alert("Auto-corrected input error");*/
}
var fpgr = getRC("R",fp); /* From Position Get Row # */
var fpgc = getRC("C",fp); /* From Position Get Col # */
var rpgr = getRC("R",rp); /* requested (to) position Row # */
var rpgc = getRC("C",rp); /* requested (to) position Col # */
console.log("In setStrtPos...passed plyr = " +plyr + " requesting new position of: " +rp );/* !.018a */
if( rp.length != 3) /* @1.018a */
{ errfnd = "Y";
rp = rp +"?"; /* dont let it be just 1 number , need 2 */
console.log("In setStrtPos...illegal requested position("+rp +")." );
emsg = "In setStrtPos...illegal requested position("+rp +").";
if(plyr == 1) /* 1.018a */
document.gameOptionsForm.sp1.value = rp;
else
document.gameOptionsForm.sp2.value = rp;
}
var temp = rp.substring(1,3);
if (isNaN(temp))
alert("this(" +temp +") is NOT a number");
/* Be sure requested to position is within the board */
if (rpgr > numRows || rpgr <1 || rpgc > numCols || rpgc < 1)
{errfnd = "Y";
emsg = emsg + " Illegal starting position requested. Must be r## where 1st # is (1-8) 2nd # is 1-9)."+"\n";;
console.log("Illegal starting position requested: r" +rpgr +rpgc +" Must be r## where 1st # is (1-8) 2nd # is 1-9).");
/* alert("Illegal starting position requested (off the playing board)."); */
}
/* Be sure requested to position is empty (ie board[][]=0 */
if (errfnd == "N")
{if (board[rpgr][rpgc] == 0) /* its a empty sq to move to */
{board[rpgr][rpgc] = parseInt(plyr); /* show occupied by player plyr */
var entrd = document.getElementById(rp); /* draw playChar in new pos*/
entrd.style.color = color[plyr] ;
document.getElementById(rp).value = playerChar[plyr];
if (plyr == 1)
{ document.gameOptionsForm.sp1.value = rp;
}
else
{ document.gameOptionsForm.sp2.value = rp;
}
board[fpgr][fpgc] = 0; /* mark From Pos as empty (ie 0 */
document.getElementById(fp).value = blankChar; /* remove char from the from pos */
document.getElementById(fp).style.backgroundColor = colorBlank;
if (plyr == 1) /* set moveFrom[] to reflect new position */
{moveFrom[1] = document.gameOptionsForm.sp1.value; } /* player1 */
else
{moveFrom[2] = document.gameOptionsForm.sp2.value;} /* player2 */
console.log(" board["+rpgr +"]["+rpgc +"] changed to " +board[rpgr][rpgc] +" to: 0 (unoccupied)");
}
else
{errfnd = "Y";
emsg = emsg + "requesting position occupied or illegal" +"\n";
console.log("requesting position occupied or illegal");
/*alert("requesting position occupied or illegal");*/
console.log(" board["+rpgr +"]["+rpgc +"]" +" is " +board[rpgr][rpgc]);
/* Now handle the From Position */
var elem = document.getElementById(fp);
elem.style.color = color[plyr];
console.log(" new start ppos for player " + plyr +" is " +moveFrom[plyr]);
}
} /* end of errfnd = n */
if (errfnd == "Y")
{emsg = emsg + " errors found ...request not processed. r" +r +"\n" + msg +"\n"; /* 1.018c */
alert("errors found ...request not processed. See Important Information Box "+ rp +" r" +rpgr +rpgc ); /* 1.018c */
console.log("errors found ...request not processed. " +rp); /* 1.018c */
document.Form.out.value = emsg; /* 1.018c */
}
else
{emsg = emsg + "No errors found ...request succesfully processed. " +"\n";
console.log("No errors found ...request succesfully processed. " +"\n");
}
} /* end of function*/
/************************************************************************/
/* */
/* Play Again? @0.095a */
/* */
/* */
/* */
/************************************************************************/
function playAgain() {
var numGames; /* 0.099a */
numGames = getCookie("numGames")
numGames = numGames + 1; /* 0.099a */
setCookie("numGames",numGames,0) /*@0.099a */
setCookie("winningPlayer",winningPlayer,0) /*@0.099a */
console.log("numGames=" +numGames);
console.log("winningPlayer=" +winningPlayer);
document.location.href = "";
}
/************************************************************************/
/* */
/* delayBtwMoves() */
/* */
/* The computer moves & removes too quickly. This will add a delay. */
/* Delay longer at lower levels of Difficulty (levelDif) */
/* */
/* @1.006a */
/************************************************************************/
async function delayBtwMoves(dla) {
console.log("<<<<<<<< delay of" +dla +" passed to delayBtwMoves >>>>>>>>>>>>>>>");
console.log("two a-----------------------------------------------------------------------------------------");
/* syncDelay(dla);*/
/*
var count = 10**(9-levelDif) ;
console.log("delay count = " +count );
var i;
var j;
for (i=0; i < count; i++)
{ j = j + 1; }
*/
console.log("two b-----------------------------------------------------------------------------------------");
return 1
}
function syncDelay(milliseconds){
var start = new Date().getTime();
var end=0;
while( (end-start) < milliseconds){
end = new Date().getTime();
}
}
function sleep(duration) {
return new Promise(resolve => {
setTimeout(() => {
resolve()
}, duration * 1000)
})
}
/************************************************************************/
/* */
/* Quit() close window */
/* */
/* */
/* */
/************************************************************************/
function Quit() {
window.close();
/*
window.stop();
var myURL=window.location.href
window.location=myURL
*/
}
/******************************************************************/
/* */
/* form: Form */
/* css id e1, e2 ..e12 for each entry box use with css defs */
/* css class: inputBoard , inputBoard */
/* */
/* */
/******************************************************************/
</script>
<form name=Form bgcolor= "silver" >
<fieldset class="fieldset" style="border: 2px double groove red; width:620px " >
<legend> <font size=3> Current Game Status Dashboard ver 1.019 </font> </legend>
<font color=darkgreen size=-1>
Name
Symbol
Pts
LvlDiff
Wrap
Turn#
autoRemov
<font color=darkblue>
<font color="blue">
<font color="green">
<br>
<font color=white size=1>
<font color=darkgreen size=-1>
Player1:
<input type="text" value="name1" name="n1" class=inputName ; onChange='pCharNameChanged("N","1")'>
<input type="text" value=" X" name="c1" class=scoreareaShort maxlength=2 size=1 ; onChange='pCharNameChanged("C","1")' >
<input type="text" value="0" name="pt1" class=scoreareaShort maxlength=2 size=1 STYLE="font-size:85%" >
RemovedSq:
<textarea name=rs rows=1 cols=3 readonly="readonly" class="scoreareaVeryShort" resizeable=no " ></textarea>
<textarea name=lod rows=1 cols=3 readonly="readonly" class="scoreareaVeryShort" ></textarea>
<textarea name=wr rows=1 cols=3 value="Y" readonly="readonly" class="scoreareaVeryShort" resizeable=no ></textarea>
<textarea name=tn rows=1 cols=3 readonly="readonly" class="scoreareaVeryShort" ></textarea>
<textarea name=arem rows=1 cols=1 value=1 readonly="readonly" class="scoreareaVeryShort" resizeable=no ></textarea>
<br><font color="black">
<br>
Player2:
<input type="text" value="name2" name="n2" class=inputName STYLE="color:red; " ; onChange='pCharNameChanged("N","2")'>
<input type="text" value=" O" name="c2" class=scoreareaShort ; onChange='pCharNameChanged("C","2")' >
<input type="text" value="0" name="pt2" class=scoreareaShort maxlength=2 size=1 STYLE="font-size:70%"; >
Avail Sq:
<textarea name=as rows=1 cols=6 readonly="readonly" class="scoreareaVeryShort" ></textarea>
computer checked
<textarea name=nbc rows=1 cols=4 readonly="readonly" class="scoreareaMedium" ></textarea>
moves
<hr>
WhoseTurn:
<textarea name=ptn rows=1 cols=4 readonly="readonly" class="scorearea" STYLE="border-style:hidden" > </textarea>
<textarea name=ptc rows=1 cols=1 readonly="readonly" class="scoreareaShort" STYLE="border-style:hidden" resizeable=no > </textarea>
<input type="radio" STYLE="color: #FFFFFF; background-color: #72A4D2;" value=" X" name="rb1" onClick="GetSelectedItem(this.form)"size=12 > X
<input type="radio" STYLE="color: #FFFFFF; background-color: #72A4D2;" value=" O" name="rb1" onClick="GetSelectedItem(this.form)"size=12 > O
Action:
<input type="radio" STYLE="color: #FFFFFF; background-color: #72A4D2;" value=" " name="rb2" onClick="GetSelectedItem(this.form)"size=6 > MoveTo Sq.
<input type="radio" STYLE="color: #FFFFFF; background-color: #72A4D2;" value=" -" name="rb2" onClick="GetSelectedItem(this.form)"size=12 > RemoveSq.
</fieldset>
<font color="blue">
<br>
<input type="text" class="inputBoard" value="" id="r11" name="r11" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r12" name="r12" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r13" name="r13" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r14" name="r14" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r15" name="r15" onFocus="foc(this)" size=1 maxlength=3 >
<input type="text" class="inputBoard" value="" id="r16" name="r16" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r17" name="r17" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r18" name="r18" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r19" name="r19" onFocus="foc(this)" size=1 maxlength=2 >
<br>
<input type="text" class="inputBoard" value="" id="r21" name="r21" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r22" name="r22" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r23" name="r23" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r24" name="r24" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r25" name="r25" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r26" name="r26" onFocus="foc(this)" size=1 maxlength=3 >
<input type="text" class="inputBoard" value="" id="r27" name="r27" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r28" name="r28" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r29" name="r29" onFocus="foc(this)" size=1 maxlength=2 >
<br>
<input type="text" class="inputBoard" value="" id="r31" name="r31" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r32" name="r32" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r33" name="r33" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r34" name="r34" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r35" name="r35" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r36" name="r36" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r37" name="r37" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r38" name="r38" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r39" name="r39" onFocus="foc(this)" size=1 maxlength=2 >
<br>
<input type="text" class="inputBoard" value=" X" id="r41" name="r41" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r42" name="r42" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r43" name="r43" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r44" name="r44" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r45" name="r45" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r46" name="r46" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r47" name="r47" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r48" name="r48" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r49" name="r49" onFocus="foc(this)" size=1 maxlength=2 >
<br>
<input type="text" class="inputBoard" value="" id="r51" name="r51" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r52" name="r52" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r53" name="r53" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r54" name="r54" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r55" name="r55" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r56" name="r56" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r57" name="r57" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r58" name="r58" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value=" O" id="r59" name="r59" onFocus="foc(this)" size=1 maxlength=2 >
<br>
<input type="text" class="inputBoard" value="" id="r61" name="r61" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r62" name="r62" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r63" name="r63" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r64" name="r64" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r65" name="r65" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r66" name="r66" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r67" name="r67" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r68" name="r68" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r69" name="r69" onFocus="foc(this)" size=1 maxlength=2 >
<br>
<input type="text" class="inputBoard" value="" id="r71" name="r71" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r72" name="r72" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r73" name="r73" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r74" name="r74" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r75" name="r75" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r76" name="r76" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r77" name="r77" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r78" name="r78" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r79" name="r79" onFocus="foc(this)" size=1 maxlength=2 >
<br>
<input type="text" class="inputBoard" value="" id="r81" name="r81" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r82" name="r82" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r83" name="r83" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r84" name="r84" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r85" name="r85" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r86" name="r86" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r87" name="r87" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r88" name="r88" onFocus="foc(this)" size=1 maxlength=2 >
<input type="text" class="inputBoard" value="" id="r89" name="r89" onFocus="foc(this)" size=1 maxlength=2 >
<br><br>
<strong>
<imh>
--- Important Message Below ---
</imh>
<br>
<font color="blue" font-family=monospace >
<textarea name=out rows=4 cols=84 readonly="readonly" wrap=virtual id="imb" class="textareaOut" scrollbars=yes >
</textarea>
<br>
<input type="button" STYLE="color: crimson ; font-style: italic ;background-color:white; font-size:100%" value=" Help " name="update" size=1 onClick="helpem()" >
<input type="button" STYLE="color: #FEFEFE; font-weight:bold ;background-color: darkblue;font-size:75%;";
value="Game Summary" onClick="gameSummary()" >
<input type="button" STYLE="color: #FEFEFE; background-color: darkblue;font-size:75%" value="Game Log" name="update" size=1 onClick="writeOutGameLog();">
<input type="button" STYLE="color: #FEFEFE; font-style: italic ;background-color: #72A4D2;font-size:70%" value="DispBoardVars" name="update" size=1 onClick="dispBoardVars()">
<input type="button" STYLE="color: #FEFEFE; font-style: italic ;background-color: #72A4D2;font-size:70%" value="DispValuVars" name="update" size=1 onClick="dispValuVars()" >
<input type="button" STYLE="color: #FEFEFE; font-style:normal ;background-color: darkblue;font-size:85%" value=" Hint " name="update" size=1 onMouseOver="doIt(this)" onClick="doItOut()">
<input type="button" STYLE="color: #FEFEFE; font-style: italic ;background-color: green ;font-size:85%" value=" New Game " name="update" size=1 onClick="playAgain()">
<input type="button" STYLE="color: #FEFEFE; font-style: italic ;background-color: red ;font-size:85%" value=" Exit " name="update" size=1 onClick="Quit()">
<br>
<br>
</form>
<! –– /* form: gameOptionsFormm -->
<form name=gameOptionsForm>
<body bgcolor=silver>
<! -- /* the h2 & /h2 tags puts a biggher space between game summary button & set game options -->
<fieldset style="border: 2px solid black; width:400px ">
<legend> <font size=4 > Set Game Options </font> </legend>
<input type="button" STYLE="color: #FEFEFE; font-style: italic ; background-color: darkgreen;
font-size:100%"
value=" Save Game Options Settings "
name="update" size=1 onClick="sgOS()">
<font color=darkgreen size=-1>
<br>
Number Players:
<INPUT TYPE='radio'; name='pinput' value='1' checked> One Player (Play vs computer)
<INPUT TYPE='radio'; name='pinput' value='2' > Two Players
<br>Who Goes First:
<INPUT TYPE='radio'; name='wgf' value='1' checked> Player 1
<INPUT TYPE='radio'; name='wgf' value='2' > Player 2
<br> Wrap Allowed :
<INPUT TYPE='radio'; name='wa' value='Y' checked > Yes
<INPUT TYPE='radio'; name='wa' value='N' > No
<br> Lvl Difficulty:
<INPUT TYPE='radio'; name='ld' value='1' checked > Novice
<INPUT TYPE='radio'; name='ld' value='2' > Easy
<INPUT TYPE='radio'; name='ld' value='3' > Fair
<INPUT TYPE='radio'; name='ld' value='4' > Good
<INPUT TYPE='radio'; name='ld' value='5' > Advanced
<br>Auto Remove :
<INPUT TYPE='radio'; name='ar' value='Y' checked > Yes
<INPUT TYPE='radio'; name='ar' value='N' checked > No
<br>
<br>
<br>
<fieldset style='border: 2px solid green; background-color:darkseagreen; width:500px' >
<legend> <font size=3 color=darkblue > Customization </font> </legend>
<! –– elements for color picker for remsqcolor, chngbgcolor & chnaboardcolor -->
<font color=red size=-1>
Select Removed Square Color:
<input type="color" id="remsqcolor" value="#FFFFFF" >
<br> <font color=blue size=-1>
Select Background Color:
<input type="color" id="chngbgcolor" value="#A0C0A0" >
<br> <font color=blue size=-1>
Select Board Color:
<input type="color" id="chngboardcolor" value="#8EB5A7" >
<label> boardSize </label>
<select id=ibs name = ibs size=1 >
<option boardSize value = "1" > xs </option>
<option boardSize value = "2" > s </option>
<option boardSize value = "3" > sm </option>
<option boardSize value = "4" > M </option>
<option boardSize value = "5" selected > mL </option>
<option boardSize value = "6" > L </option>
<option boardSize value = "7" > XL </option>
</select>
<br>
<br>
<br>
<fieldset style='border: 1px solid yellow; width:500px' >
<legend> <font size=2 color=darkblue> Player Customization </font> </legend>
<font color=white> <br>
Color
Char
Name
Special chars
StrtPos
<font color=black><br>
Set Player1:
<input type="color" id="chngplayer1charcolor" value="#0000FF" >
<input type="text" value=" X" id="chng1Char" name="c1" STYLE="color:blue;background-color:lightgray " maxlength=2 size=2 ; onChange='pCharNameChanged("C","1")' >
<input type="text" value="Human1" name="n1" class=inputName ; onChange='pCharNameChanged("N","1")'>
<select id=pcs1 name = pcs1 size=1 onChange='pCharChanged("C","1")'>
<option playerSel1 value = "75540" selected > select </option>
<option playerSel1 value = "9607" > solid rect </option>
<option playerSel1 value = "9648" > parrallelo </option>
<option playerSel1 value = "9654" > right arrow</option>
<option playerSel1 value = "9664" > left arrow </option>
<option playerSel1 value = "10148" > rt arrow </option>
<option playerSel1 value = "9711" > circle holl</option>
<option playerSel1 value = "2039" > clover </option>
<option playerSel1 value = "9728" > sunburst </option>
<option playerSel1 value = "75483" > triangle </option>
<option playerSel1 value = "9733" > star </option>
<option playerSel1 value = "9785" > frown face </option>
<option playerSel1 value = "9851" > recycle </option>
<option playerSel1 value = "10033" > asterick </option>
<option playerSel1 value = "10038" > sm asterick</option>
<option playerSel1 value = "10084" > heart </option>
<option playerSel1 value = "42648" > infinity </option>
<option playerSel1 value = "66473" > horseshoe </option>
<option playerSel1 value = "75540" > ck mark </option>
<option playerSel1 value = "10026" > inscrstar </option>
<option playerSel1 value = "75546" > big + </option>
<option playerSel1 value = "76298" > summ sign </option>
<option playerSel1 value = "10224" > house </option>
<option playerSel1 value = "" > staticcolor</option>
<option playerSel1 value = "75669" > gray + </option>
<option playerSel1 value = "11035" > black sq </option>
<option playerSel1 value = "11036" > white sq </option>
<option playerSel1 value = "9898" > white circ </option>
<option playerSel1 value = "9899" > black circ </option>
<option playerSel1 value = "9989" > gren box ck</option>
<option playerSel1 value = "10062" > green box x</option>
<option playerSel1 value = "10060" > red x </option>
<option playerSel1 value = "10067" > red ? </option>
<option playerSel1 value = "10068" > white ? </option>
<option playerSel1 value = "10069" > white ! </option>
<option playerSel1 value = "10071" > red ! </option>
<option playerSel1 value = "9203" > hourglass </option>
<option playerSel1 value = "9917" > soccerball </option>
<option playerSel1 value = "9918" > baseball </option>
<option playerSel1 value = "9200" > alarm clock</option>
<option playerSel1 value = "9757" > thumbs up </option>
<option playerSel1 value = "9889" > lightning </option>
<option playerSel1 value = "9973" > sailboat </option>
<option playerSel1 value = "11093" > red donut </option>
<option playerSel1 value = "9940" > red circle </option>
<option playerSel1 value = "9971" > golf flag </option>
<option playerSel1 value = "9924" > snowman </option>
<option playerSel1 value = "10024" > color stars</option>
<option playerSel1 value = "9749" > hot choc </option>
</select>
<input type="text" value="r41" name="sp1" class=scoreareaVeryShort ; onChange='setStrtPos("1")'>
<br>
Set Player2:
<input type="color" id="chngplayer2charcolor" value="#FF0000" >
<input type="text" value=" O" id="chng2Char" name="c2" STYLE="color:blue;background-color:lightgray " maxlength=2 size=2 ; onChange='pCharNameChanged("C","2")' >
<input type="text" value="Computer2" name="n2" class=inputName ; onChange='pCharNameChanged("N","2")'>
<select id=pcs2 name = pcs2 size=1 onChange='pCharChanged("C","2")'>
<option playerSel1 value = "75540" selected > select </option>
<option playerSel1 value = "9607" > solid rect </option>
<option playerSel1 value = "9648" > parrallelo </option>
<option playerSel1 value = "9654" > right arrow</option>
<option playerSel1 value = "9664" > left arrow </option>
<option playerSel1 value = "10148" > rt arrow </option>
<option playerSel1 value = "9711" > circle holl</option>
<option playerSel1 value = "2039" > clover </option>
<option playerSel1 value = "9728" > sunburst </option>
<option playerSel1 value = "75483" > triangle </option>
<option playerSel1 value = "9733" > star </option>
<option playerSel1 value = "9785" > frown face </option>
<option playerSel1 value = "9851" > recycle </option>
<option playerSel1 value = "10033" > asterick </option>
<option playerSel1 value = "10038" > sm asterick</option>
<option playerSel1 value = "10084" > heart </option>
<option playerSel1 value = "42648" > infinity </option>
<option playerSel1 value = "66473" > horseshoe </option>
<option playerSel1 value = "75540" > ck mark </option>
<option playerSel1 value = "10026" > inscrstar </option>
<option playerSel1 value = "75546" > big + </option>
<option playerSel1 value = "76298" > summ sign </option>
<option playerSel1 value = "10224" > house </option>
<option playerSel1 value = "" > staticcolor</option>
<option playerSel1 value = "75669" > gray + </option>
<option playerSel1 value = "11035" > black sq </option>
<option playerSel1 value = "11036" > white sq </option>
<option playerSel1 value = "9898" > white circ </option>
<option playerSel1 value = "9899" > black circ </option>
<option playerSel1 value = "9989" > gren box ck</option>
<option playerSel1 value = "10062" > green box x</option>
<option playerSel1 value = "10060" > red x </option>
<option playerSel1 value = "10067" > red ? </option>
<option playerSel1 value = "10068" > white ? </option>
<option playerSel1 value = "10069" > white ! </option>
<option playerSel1 value = "10071" > red ! </option>
<option playerSel1 value = "9203" > hourglass </option>
<option playerSel1 value = "9917" > soccerball </option>
<option playerSel1 value = "9918" > baseball </option>
<option playerSel1 value = "9200" > alarm clock</option>
<option playerSel1 value = "9757" > thumbs up </option>
<option playerSel1 value = "9889" > lightning </option>
<option playerSel1 value = "9973" > sailboat </option>
<option playerSel1 value = "11093" > red donut </option>
<option playerSel1 value = "9940" > red circle </option>
<option playerSel1 value = "9971" > golf flag </option>
<option playerSel1 value = "9924" > snowman </option>
<option playerSel1 value = "10024" > color stars</option>
<option playerSel1 value = "9749" > hot choc </option>
</select>
<input type="text" value="r59" name="sp2" class=scoreareaVeryShort ; onChange='setStrtPos("2")'>
</fieldset><br> <! -- end fieldest for border around Customization
</fieldset> <! -- end fieldest for border around Player customization
<br>
<input type="button" STYLE="color: #FEFEFE; font-style: italic ; background-color: darkgreen;
font-size:100%" value=" Save Customization "
name="update" size=1 onClick="sgOS()">
</fieldset>
</fieldset>
</body>
</form>