Tic Tac Toe game

This is the assignment’s information:

Your next project is to play a “random” computer the game of Tic Tac Toe. For this project, however, you are to have the logic and game scores stored on the server. The requirements are:

  1. When accessing the index.php file for the project, the page should post the last player who was playing Tic Tac Toe based on the cookie stored in the browser. It should also ask “Is this you?” and give the user a chance to change who he or she is before beginning to play. If cookies have been cleared, or nobody had played in that browser before, the page should ask for the name of the player who will play. There should also be a button on the page asking to “Start Playing” or something similar to go to the next page and begin playing.
  2. Once Tic Tac Toe is playing with the player entered, the player and computer will play the games and keep track of the score of: player wins, computer wins, and draws. This will be done using sessions to allow the computer to randomly pick its moves. That is, the player will play the computer with each player move being stored to the session and the computer making a random choice for its piece (O or X) by updating the board state and picking one of the remaining squares. You must have a Board.php class to keep the state of the board up to date, passing the row and column of the player move (as stored in the session) to the Board class, with the computer returning a row and column for its move back to the browser again through the session.
  3. At all times, the player wins, computer wins, and draws should be displayed in the browser. These are the values for all times! That is, is you close the browser then open it back up, then enter the name of a user who has previously played against the computer, these scores should all immediately appear even before the next game begins.
  4. Usually, the scores of all players vs computer should be stored to a database. But hey, we haven’t looked at databases yet!! So you will store all scores in a file on the computer (check php.net on how to work with files) and read that in whenever a player starts playing.
  5. For your CSS file, you will use SASS to create your CSS files as I demonstrated previously in class. Use the https://sass-lang.com/ site to see how to install SASS on your computer (mine has it running so I will essentially compile your SCSS files into CSS files) and use “Learn SASS” page on the site to learn the basics on how to create pages. (While you have a fairly simple CSS file to create, imagine a huge site with many pages and much styling to attend to! That’s when SASS is so important. You will just get a taste of using it here.) I will use “Preprocessing” to compile your SCSS file. You will notice that you can use SASS for Variables, Nesting, Partials, Import, Mixins, Inheritance and Operators. You are required to use at least 4 of these 7 for your project. Also, make your SCSS (and the resulting CSS file) interesting enough that your page looks reasonable.

 

Last Updated on March 19, 2019

Don`t copy text!
Scroll to Top