-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
160 lines (140 loc) · 7.08 KB
/
index.html
File metadata and controls
160 lines (140 loc) · 7.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TTC</title>
<!--Adding Favicon-->
<link rel="shortcut icon" href="favicon.png" type="image/x-icon">
<!-- Add mute button icon library -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css"
integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2"
crossorigin="anonymous"
/>
<link rel="stylesheet" href="style.css" type="text/css" />
<!-- Global site tag (gtag.js) - Google Analytics -->
<script
async
src="https://www.googletagmanager.com/gtag/js?id=UA-113861388-2"
></script>
<script src="index.mjs" defer></script>
</head>
<body>
<nav class="navbar fixed-top" id="hero">
<h1>TIC TAC TOE</h1>
<a class="navbar-brand" href="#">Play Game</a>
</nav>
</br>
<div class="popup-container">
<div class="instructions">
<p>You probably already know how to play Tic-Tac-Toe. It's a really simple game, right? That's what most people think. But if you really wrap your brain around it, you'll discover that Tic-Tac-Toe isn't quite as simple as you think!
Tic-Tac -Toe (along with a lot of other games) involves looking ahead and trying to figure out what the person playing against you might do next.</p>
<h1>RULES FOR TIC-TAC-TOE</h1>
<p>1. The game is played on a grid that's 3 squares by 3 squares. </p>
<p>2. You are X, your friend (or the computer in this case) is O. Players take turns putting their marks in empty squares.</p>
<p>3. The first player to get 3 of her marks in a row (up, down, across, or diagonally) is the winner.</p>
<p>4. When all 9 squares are full, the game is over. If no player has 3 marks in a row, the game ends in a tie.</p>
<h1>HOW CAN I WIN AT TIC-TAC-TOE?</h1>
<p>To beat the computer (or at least tie), you need to make use of a little bit of strategy. Strategy means figuring out what you need to do to win.
Part of your strategy is trying to figure out how to get three Xs in a row. The other part is trying to figure out how to stop the computer from getting three Os in a row.
After you put an X in a square, you start looking ahead. Where's the best place for your next X? You look at the empty squares and decide which ones are good choices—which ones might let you make three Xs in a row.
You also have to watch where the computer puts its O. That could change what you do next. If the computer gets two Os in a row, you have to put your next X in the last empty square in that row, or the computer will win. You are forced to play in a particular square or lose the game.
If you always pay attention and look ahead, you'll never lose a game of Tic-Tac-Toe. You may not win, but at least you'll tie.</p>
<table>
<tr>
<th><button type="button" class="player1-btn start-btn" name="button" onclick="singlePlayer()">Single Player</button></th>
<th><button type="button" class="player2-btn start-btn" name="button" onclick="twoPlayer()">2 Players</button></th>
</tr>
</table>
</div>
</div>
<!-- instruction phase ends here -->
<div class="container-custom">
<h1>Tic-Tac-Toe</h1>
<h4>Scoreboard</h4>
<table>
<tr>
<th><button type="button" name="button" onclick="singlePlayer()">Single Player</button></th>
<th><button type="button" name="button" onclick="twoPlayer()">2 Players</button></th>
</tr>
</table>
<table class="table">
<thead>
<tr style="color: crimson;">
<th scope="col">Game/User</th>
<th scope="col" id = "Player1">Player</th>
<th scope="col" id = "Player2">Computer</th>
</tr>
</thead>
<h2 id = "move">PLAYER MOVE!</h2>
<tbody>
<tr>
<th scope="row" class="table-success">Win</th>
<td id="playerstat1" class="playerstat table-success"></td>
<td id="computerstat1" class="computerstat table-success"></td>
</tr>
<tr>
<th scope="row" class="table-danger">Lost</th>
<td id="loss1" class="computerstat table-danger"></td>
<td id="loss2" class="playerstat table-danger"></td>
</tr>
<tr>
<th scope="row" class="table-warning">Draw</th>
<td id="draw1" class="drawstat table-warning"></td>
<td id="draw2" class="drawstat table-warning"></td>
</tr>
</tbody>
</table>
<div class="play-area" id="play">
<div id="block_0" class="block"></div>
<div id="block_1" class="block"></div>
<div id="block_2" class="block"></div>
<div id="block_3" class="block"></div>
<div id="block_4" class="block"></div>
<div id="block_5" class="block"></div>
<div id="block_6" class="block"></div>
<div id="block_7" class="block"></div>
<div id="block_8" class="block"></div>
</div>
<!-- <button onclick="myFunction()">Toggle dark mode</button> -->
<script>
function myFunction() {
var main = document.body;
var hero = document.getElementsByClassName('navbar')[0]
var container = document.getElementById('play')
var darkToggle = document.getElementsByClassName('btn')
var heroText = document.getElementsByClassName('navbar-brand')
var arr = Array.prototype.slice.call(heroText)
arr.forEach(element => {
element.classList.toggle('dark-text')
});
if (darkToggle[1].textContent === "Dark Mode"){
darkToggle[1].textContent = "Light Mode"
} else {
darkToggle[1].textContent = "Dark Mode"
}
hero.classList.toggle("dark-hero");
main.classList.toggle("dark-main");
container.classList.toggle("dark-play")
}
</script>
<select id="ai_level">
<option value="easy" selected>Easy</option>
<option value="normal">Normal</option>
<option value="hard">Hard</option>
</select>
<div class="div-end-of-game">
<!-- <button onclick="reset_board()">RESET BOARD</button> -->
<button onclick="undoLastMove()">Undo Move</button>
<button id="selectXButton" onclick="selectFirstPlayer('X')">Play O first</button>
<button id="selectOButton" onclick="selectFirstPlayer('O')">Play X first</button>
</div>
<h2 id="winner"></h2>
</div>
<script src="https://connect.facebook.net/en_US/fbinstant.6.3.js"></script>
<script src="app.js"></script>
</body>
</html>