Question
create a web-based version of the classic game Tic-Tac-Toe. The classic rules are to be applied. Requirements for a perfect score The computer player must
create a web-based version of the classic game Tic-Tac-Toe. The classic rules are to be applied.
Requirements for a perfect score
The computer player must choose automatically.
Human player's choices must be processed via html form POSTs.
Must implement a usable interface (see below), the more advanced your interface... the higher your score. Included below is a template that can be used if you lack HTML experience. However points will be deducted if you fail to customize the template for your code.
The program must be able to determine a winner (or a draw) for all 8 winning combination
The program must prevent both the user and computer from choosing an already used block.
Automate both players, but instead of choosing randomly implement some form of BASIC artificial intelligence. For example automatically blocking when the opponent has 2 in a row.
Below is the Template of Game
# Your PHP code can go here... or you can do a require() to another file
?>
$(document).ready(function(){
// This block of code prevents you from entering anything but X or O
$('input').bind('keyup',function() {
if( $(this).hasClass('button') == false ){
this.value = this.value.toUpperCase();
if(this.value != 'X' && this.value != 'O') {
this.value = '';
}
}
});
// This block of code makes the used spots on the grid readonly once used
$('input').each(function(i){
this.value = this.value.toUpperCase();
if(this.value == 'X' || this.value == 'O') {
$(this).addClass('disabled').attr('readonly', true);
//this.readOnly = true;
}
});
});
body * { padding:0; margin:0; }
.disabled { background: #eeeeee; }
.button { display: block; width:180px; margin: 10px 0; }
#gameboard { border-collapse:collapse; padding:0; margin:0; }
#gameboard tr:nth-child(even) {
border-top:2px solid black;
border-bottom:2px solid black;
}
#gameboard tr td:first-child { border-right:2px solid black; }
#gameboard tr td:last-child { border-left:2px solid black; }
#gameboard input {
font-size:50px;
width:60px;
padding:3px;
text-transform:uppercase;
text-align:center;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started