Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <body class="container">
	<div class="row">
		<div class="col-12">
			<h1 class="text-center pt-25">
				8Bit Tic Tac Toe
			</h1>
			</div>
		</div>

	<div class="outer-container pt-25">
		<button class="hard-reset">Reset All</button>
  <p class="score-1"><span class="points"></span><span class="name"></span></p>
  <i class="points-divider">&#124;</i>
  <p class="score-2"><span class="points"></span><span class="name"></span></p>
  <div class="player-one-turn">
    <p></p>
  </div>
  <div class="player-two-turn">
    <p></p>
  </div>
		
			<div class="board-container">
				<div class="game-starter">
					<p class="text-center"></p>
					
					<div class="text-center">
						<button class="choose-x">X</button>
						
						<button class="choose-o">O</button>
						<button class="back-button"><i class="fa fa-arrow-left"></i> Back</button>
					</div>
					<div class="clearfix"></div>
				</div>
				
				<div class="game-choice">
					<p>How many players do you want to play?</p>
					
					<div class="float-left">
        	<button class="one-player">One Player</button>

        	<button class="two-player">Two Player</button>
						</div>
				</div>
				
				<div class="game-board">
					<div class="draw-message">
						<p>It was a draw..</p>
					</div>
					<div class="lose-message">
						<p>Uh oh, you lost..</p>
					</div>
					<div class="win-message">
						<p>You Won!!! :)</p>
					</div>
					
					<canvas id="myCanvas"></canvas>
      		
					<ul class="boxes">
      		</ul>
				</div>
			</div>
	</div>
		</div>
	</div>
</body>
              
            
!

CSS

              
                $red-color: #ee2c2c;
$yellow-color: #ffff00;
$blue-color: #0000cd;

@import url(https://fonts.googleapis.com/css?family=Press+Start+2P);

body {
  width: 100%;
  height: 100%;
	background-color: #000;
}

li {
  list-style: none;
}

h1,
p{
	color: $red-color;
	font-family: 'Press Start 2P', cursive;
	font-size: 1.5em;
	text-shadow: 2px 3px 	$yellow-color;
}

.pt-25{
	padding-top: 25px;
}

.outer-container {
  position: relative;
  width: 400px;
  height: 390px;
  margin: 10% auto;
  padding: 40px 0 0;
}

.board-container {
  width: 350px;
  height: 350px;
  background-size: cover;
  position: relative;
  margin: 0 auto;
  overflow: hidden;
}

.game-board {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  position: relative;
}

.boxes {
  padding: 0;
  width: 100%;
  height: 100%;
  position: relative;
  left: 12px;
  top: 0;
}

.boxes li {
  width: 30%;
  height: 30%;
  display: inline-block;
  position: relative;
  z-index: 1000;
  margin-left: 2px;
  margin-right: 2px;
  overflow: hidden;
}

li i {
  font-size: 6.5rem;
  text-align: center;
  display: block;
  width: 100%;
  height: 100%;
  font-style: normal;
  font-family: 'Press Start 2P', cursive;
  color: $red-color;
  z-index: 500;
}

li span {
  position: relative;
  bottom: 15px;
}

#myCanvas {
  width: 330px;
  height: 330px;
  position: absolute;
  z-index: 0;
  left: 10px;
  top: 0;
  opacity: 0;
}

/* Player/Computer prompt */
.player-one-turn {
  background: #000;
  left: 15px;
}

.player-two-turn {
  background: #000;
  right: 15px;
}

.player-one-turn,
.player-two-turn {
  position: absolute;
  top: 0;
  width: 170px;
  height: 50px;
  z-index: -10;
  color: $red-color;
  text-align: center;
}

.player-one-turn p,
.player-two-turn p {
  font-size: 1rem;
  margin-top: 10px;
}

.points-divider,
.score-1,
.score-2 {
  position: absolute;
  font-size: .5rem;
  margin: 0;
  display: none;
}

.score-1,
.score-2 {
  font-family: 'Press Start 2P', cursive;
  top: 17px;
  color: $red-color;
}

.score-1 .points, 
.score-2 .points {
  position: absolute;
  text-align: center;
  bottom: 14px;
  color: $blue-color;
  font-family: 'Press Start 2P', cursive;
}

.points-divider {
  top: 5px;
  left: 141px;
  font-size: 2rem;
  font-family: helvetica, sans-serif;
  font-style: normal;
  opacity: .2;
}

.score-1 {
  left: 75px;
}

.score-2 {
  left: 161px;
}

.hard-reset {
  position: absolute;
  top: 5px;
  right: 20px;
  background: none;
  border: none;
  font-family: 'Press Start 2P', cursive;
  color: $blue-color;
	text-shadow: 2px 2px $yellow-color;
  font-size: 1rem;
  border-radius: 20px;
  border: 2px dashed transparent;
  display: none;
}

.hard-reset:hover {
  border: 2px dashed rgba $blue-color;
  color: rgba(100,60,50,1);
}

.hard-reset:focus {
  outline: none;
}

span.rotate {
  color: $blue-color;
}

i.win {
  background: black;
}

.draw-message,
.lose-message,
.win-message {
	border: 3px dashed $blue-color;
	background-color: #000;
  width: 100%;
  height: 100%;
  z-index: 2000;
  position: absolute;
  display: none;
  top: -15px;
  left: 0;
  box-sizing: border-box;
}

.draw-message p,
.lose-message p,
.win-message p {
  color: $red-color;
  text-align: center;
  position: absolute;
  font-size: 1.5rem;
  margin: 0;
  top: 150px;
  left: 50px;
  font-family: 'Press Start 2P', cursive;
}

.game-choice,
.game-starter {
	border: 3px solid $blue-color;
	border-radius: 5px;
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0px;
  text-align: center;
  font-family: 'Press Start 2P', cursive;
  z-index: 1500;
/*  display: none;*/
}

.game-starter {
  display: none;
}

.game-choice p,
.game-starter p {
  font-size: 1.1rem;
}

.game-choice button,
.game-choice p,
.game-starter button,
.game-starter p {
  color: $red-color;
  position: relative;
  margin: 10px auto;
}

.game-choice p,
.game-starter p {
  max-width: 80%;
}

.game-choice button,
.game-starter button {
  background: none;
  border: none;
  opacity: .6;
  border-radius: 20px;
  border: 2px solid transparent;
  font-size: 1.7rem;
	top: 55px;
}

.game-starter button {
   font-size: 2.5rem;
}

.game-choice button:focus,
.game-starter button:focus {
  outline: none;
}
.game-choice button:hover,
.game-starter button:hover {
  opacity: 1;
  border: 2px dashed rgba(230,230,230,.5);
}

.game-starter 
button.back-button  {
  position: absolute;
  top: 270px;
  right: 130px;
  font-size: 1.5rem;
  border: none;
}

.game-starter 
.back-button:hover {
  border: none;
}

button {
  cursor: pointer;
}

.rotate {
  -webkit-animation: rotating 2s linear infinite;
  -moz-animation: rotating 2s linear infinite;
  -ms-animation: rotating 2s linear infinite;
  -o-animation: rotating 2s linear infinite;
  animation: rotating 2s linear infinite;
}

@-webkit-keyframes rotating /* Safari and Chrome */ {
  from {
    -ms-transform: rotateY(0deg);
    -moz-transform: rotateY(0deg);
    -webkit-transform: rotateY(0deg);
    -o-transform: rotateY(0deg);
    transform: rotateY(0deg);
  }
  to {
    -ms-transform: rotateY(360deg);
    -moz-transform: rotateY(360deg);
    -webkit-transform: rotateY(360deg);
    -o-transform: rotateY(360deg);
    transform: rotateY(360deg);
  }
}
@keyframes rotating {
  from {
    -ms-transform: rotateY(0deg);
    -moz-transform: rotateY(0deg);
    -webkit-transform: rotateY(0deg);
    -o-transform: rotateY(0deg);
    transform: rotateY(0deg);
  }
  to {
    -ms-transform: rotateY(360deg);
    -moz-transform: rotateY(360deg);
    -webkit-transform: rotateY(360deg);
    -o-transform: rotateY(360deg);
    transform: rotateY(360deg);
  }
}
              
            
!

JS

              
                var app = app || {
  gameInPlay: false,
  winCombos: [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
    [1, 4, 7],
    [2, 5, 8],
    [3, 6, 9],
    [1, 5, 9],
    [7, 5, 3]
  ],
  playerOneScore: 0,
  playerTwoScore: 0,
  timeOuts: [],
  initializeVars: function() {
    this.numFilledIn = 0;
    this.currentBoard = {
      1: '',
      2: '',
      3: '',
      4: '',
      5: '',
      6: '',
      7: '',
      8: '',
      9: ''
    };
  },
  initializeGame: function() {
    app.initializeVars();
    app.display.drawBoard();
		
    $('.game-choice button').click(function() {
      app.secondPlayer = app.game.gameSelection(this);
      app.display.hideGameChoice();
      app.display.showGameStarter(app.secondPlayer);
      $('.game-starter .choose-x, .game-starter .choose-o').off().click(app.game.firstGame);

      $('.back-button').on('click', function() {
        app.display.hideGameStarter();
        app.display.showGameChoice();
      });
    });
    $('.hard-reset').on('click', app.game.resetGame);
  }
};

  /*=========================
      Display functions
==========================*/
app.display = {  
  hideGameStarter: function() {
  $('.game-starter').fadeOut();
},

  showGameStarter: function(isTwoPlayer) {
  var message;
  if (isTwoPlayer) {
    message = "Player 1 : Would you like X or O?"
  }
  else {
    message = "Would you like to be X or O?";
  }
  app.timeOuts.push(
    setTimeout(function() {
      $('.game-starter').fadeIn(500).children('p').text(message);
  }, 700));
},

  showGameChoice: function() {
  $('.game-choice').fadeIn(600);
},

  hideGameChoice: function() {
  $('.game-choice').fadeOut(600);
},

  showPlayerOnePrompt: function() {
  if (app.secondPlayer) {
    $('.player-one-turn p').text('Go Player 1!');
  }
  else {
    $('.player-one-turn p').text('Your turn!');
  }
  $('.player-one-turn').animate({'top': '-45px'}, 500);
},

  hidePlayerOnePrompt: function() {
  $('.player-one-turn').animate({'top': '0'}, 500);
},

  showPlayerTwoPrompt: function() {
  if (app.secondPlayer) {
    $('.player-two-turn p').text('Go Player 2!');
  }
  else {
    $('.player-two-turn p').text('Computer\'s turn');
  }
  $('.player-two-turn').animate({'top': '-45px'}, 500);
},

  hidePlayerTwoPrompt: function() {
  $('.player-two-turn').animate({'top': '0'}, 500);
},

  showDrawMessage: function() {
  app.timeOuts.push(
    setTimeout(function() {
    $('.draw-message').fadeIn(500);
  }, 1500));
},

  hideDrawMessage: function() {
  $('.draw-message').fadeOut(1000);
},

  showLoseMessage: function() {
    app.timeOuts.push(
      setTimeout(function() {
    $('.lose-message').fadeIn(500);
}, 1500)
    );
},

  hideLoseMessage: function() {
  $('.lose-message').fadeOut(1000);
},

  showWinMessage: function() {
    app.timeOuts.push(
      setTimeout(function() {
    $('.win-message').fadeIn(500).children('p').text("Player " + app.turn + " wins!! :D ")
}, 1500));
},

  hideWinMessage: function() {
  $('.win-message').fadeOut(1000);
},

  drawBoard: function() {
    app.timeOuts.push(setTimeout(function() {
    var c = document.getElementById("myCanvas");
    var canvas = c.getContext("2d");
    canvas.lineWidth = 2;
    canvas.strokeStyle = "#0000cd";
    //vertical lines
    canvas.beginPath();
    canvas.moveTo(100, 0);
    canvas.lineTo(100, 146.5);
    canvas.closePath();
    canvas.stroke();
    canvas.beginPath();
    canvas.moveTo(200, 0);
    canvas.lineTo(200, 146.5);
    canvas.closePath();
    canvas.stroke();

    // horizontal lines
    canvas.lineWidth = 2;

    canvas.beginPath();
    canvas.moveTo(4, 48.5);
    canvas.lineTo(296, 48.5);
    canvas.closePath();
    canvas.stroke();
      
    canvas.beginPath();
    canvas.moveTo(4, 98.5);
    canvas.lineTo(296, 98.5);
    canvas.closePath();
    canvas.stroke();  
  }, 1500));
},

  resetSquares: function() {
  $('.boxes').html('');
  for (var i = 1; i <= 9; i++) {
    var box = '<li class="' + i + '"><i class="letter"><span></span></i></li>';
    $(box).appendTo($('.boxes'));
  }
},
  
  showScore: function() {
    if (app.secondPlayer) {
      $('.score-1').children('.name').text('player 1'); 
      $('.score-2').children('.name').text('player 2'); 
    }
    else {
      $('.score-1').children('.name').text('player 1'); 
      $('.score-2').children('.name').text('computer'); 
    }
    $('.score-1, .score-2').children('.points').text('0');
    $('.score-1,.score-2, .points-divider').fadeIn();
  },
  updateScore: function(turn) {
    var currentScore = turn === 1 ? app.playerOneScore : app.playerTwoScore;

    $('.score-' + turn).children('.points').text(currentScore);
  }
};

/*=========================
      Game Logic
==========================*/
app.game = {
  whoStarts: function() {
    var random = Math.floor(Math.random() * 2 + 1);
    return random;
  },
  gameSelection: function(item) {
    if ($(item).text() === 'One Player') {
      // returns what secondPlayer value to set
      return false;
    }
    else {
      return true;
    } 
  },
  firstGame: function() {
    app.playerOneSymbol = $(this).text();
    app.playerTwoSymbol = app.playerOneSymbol == 'X' ? 'O' : 'X'; 
    app.turn = app.game.whoStarts();
    app.display.hideGameStarter();
    $('#myCanvas').animate({'opacity': '1'}, 1200);
    $('.hard-reset').fadeIn(600);
    app.display.showScore();
    app.display.resetSquares();
    app.game.play();
  },
  play: function() {
    
    app.gameInPlay = true;
    $('.boxes li').on('click', function() {
     app.game.playerTurn(this);
    });  
    
    app.timeOuts.push(
      setTimeout(function(){
      if (app.turn === 1) {
        app.display.showPlayerOnePrompt();
      }
      else if (app.turn === 2) {
        app.display.showPlayerTwoPrompt();
      }
    }, 1500),
    setTimeout(function() {
      if (app.turn === 2 && !app.secondPlayer) {
        app.game.computerPlay();
      }
    }, 1200));
  },
  playerTurn: function(square) {
    var symbol = app.turn === 1 ? app.playerOneSymbol : app.playerTwoSymbol;
    var box = $(square).children('i').children('span');
    if (box.text() === '' && app.gameInPlay && (app.turn === 1 || (app.turn === 2 && app.secondPlayer))) {
      box.text(symbol);
      var number = $(square).attr('class');
      app.game.updateSquare(number, symbol);
      app.game.endTurn(symbol);
    }
  },
  computerPlay: function() {
    var computer = app.computer;
    //test computer move suggestion
    var boxNumber;
    if (computer.computerWhichMove(app.game) && app.turn === 2) {
      boxNumber = computer.computerWhichMove(app.game);
      var currentBox = $('.' + boxNumber).children('i');
      
      var symbol = app.playerTwoSymbol;

      app.timeOuts.push(
        setTimeout(function() {
        currentBox.children('span').text(symbol);
        app.game.updateSquare(boxNumber, app.playerTwoSymbol);
        app.game.endTurn(symbol);
      }, 1000));
    } 
  },
  endTurn: function(symbol) {
    app.numFilledIn = app.numFilledIn + 1;
    if (app.gameInPlay) {
      if (app.game.checkWin(symbol)[0]) {
        app.game.updateScore(app.turn);
        if (app.secondPlayer) {
          app.display.showWinMessage();
        }
        else {
          app.turn === 1 ? app.display.showWinMessage() : app.display.showLoseMessage();
        }
        app.gameInPlay = false;
        app.game.showWinningCombination();
        app.display.hidePlayerOnePrompt();
        app.display.hidePlayerTwoPrompt();
        app.game.reset();
      }
      // stop if it is a draw
      else if (app.numFilledIn >= 9) {
       app.gameInPlay = false;
        app.display.hidePlayerTwoPrompt();
        app.display.showDrawMessage();
        app.turn = app.game.whoStarts();
        app.game.reset();
      } else {
        if (app.turn === 1) {
          app.display.hidePlayerOnePrompt();
          app.display.showPlayerTwoPrompt();
          app.turn = 2;
          // call computer turn if no second player
          if (!app.secondPlayer) {
            app.game.computerPlay();
          }
        } else if (app.turn === 2) {
          app.display.showPlayerOnePrompt();
          app.display.hidePlayerTwoPrompt();
          app.turn = 1;
        }
      }
    }
  },
  updateSquare: function(number, symbol) {
    app.currentBoard[number] = symbol;
  },
  checkWin: function(symbol) {
    var currentBoard = app.currentBoard;
    var wins = app.winCombos;
    var winningCombo = [];
    var winner = wins.some(function(combination) {
      var winning = true;
      for (var i = 0; i < combination.length; i++) {
        if (currentBoard[combination[i]] !== symbol) {
          winning = false;
        }
      }
      if (winning) {
        winningCombo = combination;
      }
      return winning;
    });
    return [winner, winningCombo];
  },
  showWinningCombination: function() {
    var symbol = app.turn === 1 ? app.playerOneSymbol : app.playerTwoSymbol;
    var combo = app.game.checkWin(symbol)[1];
    for (var i = 0; i < combo.length; i++) {
      var currentBox = '.' + combo[i]; 
   // Black box and rotating test for winning combo  
        $(currentBox).children('i').addClass('win').children('span').addClass('rotate');
     }
  },
  updateScore: function(turn) {
    turn === 1 ? app.playerOneScore += 1 : app.playerTwoScore += 1; 
    
    app.display.updateScore(turn);
    
  },
  reset: function() {
    app.initializeVars();
    
    app.timeOuts.push(
      setTimeout(function() {
        app.display.hideDrawMessage();
        app.display.hideLoseMessage();
        app.display.hideWinMessage();
        $('.boxes li').fadeOut();
      }, 5000),
      setTimeout(function(){
        app.display.resetSquares();
        $('.boxes li').fadeIn();
        app.numFilledIn = 0;
      }, 6000),
    //Make sure time for next timeout is long enough
    //to not cause problems after first game
      setTimeout(function() {
        app.gameInPlay = true;
        app.game.play();
      }, 6000)
      );
  },
  resetGame: function() {
    $('#myCanvas').css('opacity', '0');
    $('.hard-reset').fadeOut();
    $('.points-divider, .score-1, .score-2').fadeOut();
    app.playerOneScore = 0;
    app.playerTwoScore = 0;
    app.display.resetSquares();
    app.initializeVars();
    app.gameInPlay = false;
    app.playerOneSymbol = null;
    app.playerTwoSymbol = null;
    app.timeOuts.forEach(function(timer) {
      clearTimeout(timer);
    });
    $('.draw-message, .win-message, .lose-message').hide();
    app.display.hidePlayerOnePrompt();
    app.display.hidePlayerTwoPrompt();
    app.display.showGameChoice();
  }
};

/* End Game Logic */
  
/*================================
    Computer Move Decisions
=================================*/    
app.computer = {
  computerWhichMove: function () {
    var move = this.winOrBlockChoice('win')[0];
    if (!move) {
      move = this.winOrBlockChoice('block')[0];
      console.log(this.winOrBlockChoice('block'));
    }
    if (!move) {
      move = this.doubleThreatChoice('win');
    }
    if (!move) {
      move = this.doubleThreatChoice('block');
    }
    if (!move) {
      move = this.firstPlay();
    }
    if (!move) {
      move = this.playCenter();
    }
    if (!move) {
      move = this.emptyCorner();
    }
    if (!move) {
      move = this.emptySide();
    }
    move = (move && app.currentBoard[move]) === '' ? move : false;
    return move;
  },

  winOrBlockChoice: function(choiceType, board) {
    var board = board || app.currentBoard;
    if (choiceType === 'win') {
      var currentSymbol = app.playerTwoSymbol;
      var opponentSymbol = app.playerOneSymbol;
    } else if (choiceType === 'block') {
      var currentSymbol = app.playerOneSymbol;
      var opponentSymbol = app.playerTwoSymbol;
    } else {
      return;
    }
    var moves = [];
    app.winCombos.forEach(function(combo) {
      var notFound = [];
      var notPlayer = true;
      for (var i = 0; i < combo.length; i++) {
        if (board[combo[i]] !== currentSymbol) {
          if (board[combo[i]] === opponentSymbol) {
            notPlayer = false;
          } else {
            notFound.push(combo[i]);
          }
        }
      }
      if (notFound.length === 1 && notPlayer) {
        var move = notFound[0];
        moves.push(move);
      }
    });
    return moves;
},

  doubleThreatChoice: function(choiceType) {
  // use winChoice function to test a spot for double threat
  var board = app.currentBoard;
  var move;

  if (choiceType === 'win') {
    var currentSymbol = app.playerTwoSymbol;
    var opponentSymbol = app.playerOneSymbol;
  } else if (choiceType === 'block') {
    var currentSymbol = app.playerOneSymbol;
    var opponentSymbol = app.playerTwoSymbol;
  }

  // forced diagonal win on 4th move prevention
    if (board[5] === currentSymbol && app.numFilledIn === 3) {
      if ((board[1] === opponentSymbol && board[9] === opponentSymbol) || (board[3] === opponentSymbol && board[7] === opponentSymbol)) {
        // Play an edge to block double threat
        move = this.emptySide();
      }
    }
  
    if (!move && board[5] === opponentSymbol && app.numFilledIn === 2) {
      move = this.diagonalSecondAttack();
    }

  if (!move) {
    // clone current board;
    var testBoard = $.extend({}, board);
    for (var i = 1; i <= 9; i++) {

      testBoard = $.extend({}, board);
      if (testBoard[i] === '') {
        testBoard[i] = currentSymbol;
        if (this.winOrBlockChoice(choiceType, testBoard).length >= 2) {
          move = i;
        }
      }
    }
  }
  return move || false;
},

  diagonalSecondAttack: function() {
  var board = app.currentBoard;
  var comp = app.playerTwoSymbol;
  var corners = [1,3,7,9];
  for (var i = 0; i < corners.length; i++) {
    if (board[corners[i]] === comp) {
      return 10 - corners[i];
    }
  }
},

  firstPlay: function() {
  var board = app.currentBoard;
  var corners = [1, 3, 7, 9];
  var move;
  if (app.numFilledIn === 1) {
    // player plays center
    if (board[5] === app.playerOneSymbol) {
      var cornerNum = Math.floor(Math.random() * 4 + 1);
      move = [1, 3, 7, 9][cornerNum];
    }
    //player plays corner, play opposite corner
    else {
      for (var i = 0; i < corners.length; i++) {
        if (app.currentBoard[corners[i]] === app.playerOneSymbol) {
          move = 5;
        }
      }
    }
  } else if (app.numFilledIn === 0) {
    var cornerNum = Math.floor(Math.random() * corners.length + 1);
    move = corners[cornerNum];
  }
  return move ? move : false;
},
  
  playCenter: function() {
    if (app.currentBoard[5] === '') {
      return 5;
    }
  },
  emptyCorner: function() {
  var board = app.currentBoard;
  var corners = [1, 3, 7, 9];
  var move;
  for (var i = 0; i < corners.length; i++) {
    if (board[corners[i]] === '') {
      move = corners[i];
    }
  }
  return move || false;
},

  emptySide: function() {
  var sides = [2, 4, 6, 8];
  for (var i = 0; i < sides.length; i++) {
    if (app.currentBoard[sides[i]] === '') {
      return sides[i];
    }
  }
  return false;
}
}

/* End Computer Move Decisions */  

$(document).ready(function() {  
  app.initializeGame();
});

/* end game initialization */


              
            
!
999px

Console