Commit 176c2611 authored by Michele's avatar Michele

small changes to tic tac toe

parent b6275c02
......@@ -8,8 +8,20 @@ any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details. */
for more details.
Source code copied on Tuesday 10th November 2015*/
<!DOCTYPE html>
<html>
<head>
<title>Tic-Tac-Toe</title>
<meta name="description" content="The game of Tic-Tac-Toe written in JavaScript to be played in the web browser, with computer challengers of varying skill.">
<meta name="keywords" content="tic-tac-toe javascript, javascript tic-tac-toe, tic-tac-toe, tictactoe, game of tic-tac-toe">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<meta name=viewport content="width=device-width, initial-scale=1">
<script type="text/javascript" language=javascript><!--
var turn = -1;
var xWon = 0;
var oWon = 0;
......@@ -371,3 +383,135 @@ function getCookie(name) {
end = document.cookie.length;
return unescape(document.cookie.substring(begin + prefix.length, end));
}
//--></script>
<style type="text/css">
body {
color:black;
background-color:white;
font-family:Tahoma,Verdana,Helvetica,Arial,sans-serif;
}
.cell {
background-color:green;
color:white;
font-size:2cm;
font-family:Courier New,Courier,monospaced;
font-weight:bold;
}
input.cell {
border:none;
width:2cm;
vertical-align:bottom;
}
td.cell {
border:thick green outset;
}
.board {
border:thin black ridge;
background-color:green;
margin-right:1cm;
}
.winstat {
color:black;
background-color:white;
border:none;
}
.player {
font-family:Courier New,Courier,monospaced;
font-weight:bold;
font-size:150%;
}
</style>
</head>
<body onload="makeCells();loadStats();newGame();">
<noscript><p style="color:red;">You must enable javascript to be able to play tic-tac-toe.</p></noscript>
<form name=board onsubmit="return false;">
<table border=0><tr><td valign=top>
<table align=left class=board cellspacing=6>
<tr>
<td class=cell><input class=cell name=c7 type=button accesskey=7 onclick="move(this);"></td>
<td class=cell><input class=cell name=c8 type=button accesskey=8 onclick="move(this);"></td>
<td class=cell><input class=cell name=c9 type=button accesskey=9 onclick="move(this);"></td>
</tr><tr>
<td class=cell><input class=cell name=c4 type=button accesskey=4 onclick="move(this);"></td>
<td class=cell><input class=cell name=c5 type=button accesskey=5 onclick="move(this);"></td>
<td class=cell><input class=cell name=c6 type=button accesskey=6 onclick="move(this);"></td>
</tr><tr>
<td class=cell><input class=cell name=c1 type=button accesskey=1 onclick="move(this);"></td>
<td class=cell><input class=cell name=c2 type=button accesskey=2 onclick="move(this);"></td>
<td class=cell><input class=cell name=c3 type=button accesskey=3 onclick="move(this);"></td>
</tr>
</table>
</td><td valign=top>
<h1>Tic-Tac-Toe</h1>
<table border=1 cellpadding=3>
<tr>
<th>Player</th>
<th>First</th>
<th>Type</th>
<th>Wins</th>
<th>Record</th>
</tr><tr>
<th class=player>X</th>
<td><input type=radio name=firstMove value=X checked onchange="newGame();"></td>
<td><select name=p1 onchange="newGame()">
<option value=1 selected>Human
<option value=2>Novice
<option value=3>Intermediate
<option value=4>Experienced
<option value=5>Expert
</select></td>
<td align=right><input type=button name=xWon class=winstat value="0"></td>
<td align=right><input type=button name=xWonPer class=winstat value="0%"></td>
</tr><tr>
<th class=player>O</th>
<td><input type=radio name=firstMove value=O onchange="newGame();"></td>
<td><select name=p2 onchange="newGame()">
<option value=1>Human
<option value=2>Novice
<option value=3 selected>Intermediate
<option value=4>Experienced
<option value=5>Expert
</select></td>
<td align=right><input type=button name=oWon class=winstat value="0"></td>
<td align=right><input type=button name=oWonPer class=winstat value="0"></td>
</tr><tr>
<th>Cat</th>
<td></td>
<td></td>
<td align=right><input type=button name=catsGame class=winstat value="0"></td>
<td align=right><input type=button name=catsGamePer class=winstat value="0"></td>
</tr></table>
<p align=right><input type=button name=newgame value="Clear Stats" accesskey=c onclick="clearStats();"></p>
<p><input type=button name=newgame value="New Game" accesskey=n onclick="newGame();"><p>
</td></tr></table>
</form>
<hr>
<h3>See Also</h3>
<p><a href="http://blog.ostermiller.org/tic-tac-toe-strategy">Tic Tac Toe strategy guide</a> - Learn how to win.</p>
<p><a href="http://ostermiller.org/games.html">Other games</a> such as <a href="http://qqwing.com/">Sudoku</a> or <a href="http://ostermiller.org/ladder/">Ladder</a>.</p>
<hr>
<h3>License</h3>
<p>This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.</p>
<p>This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the
<a href="http://www.gnu.org/copyleft/gpl.html">GNU
General Public License</a> for more details.</p>
<div style="padding:0.2cm;"><a href="http://ostermiller.org/calc/">More converters, calculators, and other JavaScript goodies</a></div>
<div style="padding:0.2cm;text-align:right;"><a href="http://ostermiller.org/">ostermiller.org</a> (<a href="http://ostermiller.org/siteindex.html">site index</a>)</div>
<div style="padding:0.2cm;"><p>Copyright <a href="http://ostermiller.org/contact.pl?regarding=JavaScript+Tic-Tac-Toe" class=mail>Stephen Ostermiller</a> 2002-2014</p></div>
</body>
</html>
......@@ -337,7 +337,7 @@ def nice_print():
for i in range(j,j+3):
cell = cells[i]
if cell == '':
cell = ' '
cell = str(i)
line = line + cell + " | "
print(line)
......@@ -345,6 +345,7 @@ def nice_print():
if __name__ == "__main__":
makeCells()
newGame()
nice_print()
# 0 to 8 for moves, 9 for reset
while True:
move1 = int(input("Next move? "))
......@@ -360,3 +361,4 @@ if __name__ == "__main__":
if winner != 0:
print("Game finished. Player 1 won "+ str(xWon) + " games, while Player 2 won "+ str(oWon) + " games. New game.")
newGame()
nice_print()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment