 : function(arr){
    var spots = [];
    for(var i = 0; i < arr.length; i++){
      if(arr[i].textContent!== "x" && arr[i].textContent!== "o"){
        spots.push(i);
      }
    }
    return spots;
  },// getAvailableSpots function.

  minimax : function(newBoard, player){
    newBoard = Array.from(newBoard);
    var availSpots = this.getAvailableSpots(newBoard);
    if(this.checkWinner(newBoard, aiPlayer)){
      return {score: 10};
    }
    else if(this.checkWinner(newBoard, humanPlayer)){
      return {score: -10};
    }
    else if(availSpots.length === 0){
      return {score: 0};
    }

    var moves = [];

    for(var j = 0; j < availSpots.length; j++){
      var move = {};
      move.index = availSpots[j];
      newBoard[availSpots[j]] = player;
      if(player === aiPlayer){
        var result1 = this.minimax(newBoard, humanPlayer);
        move.score = result1.score;
      }
      else{
        var result2 = this.minimax(newBoard, aiPlayer);
        move.score = result2.score;
      }

      newBoard[availSpots[j]] = move.index;
      moves.push(move);
    }

    var bestMove;
    if(player === aiPlayer){
      var bestScore1 = -100000;
      for(var k = 0; k < moves.length; k++){
        if(moves[k].score > bestScore1){
          bestScore1 = moves[k].score;
          bestMove = k;
        }
      }
    }
    else{
      var bestScore2 = 100000;
      for(var l = 0; l < moves.length; l++){
        if(moves[l].score < bestScore2){
          bestScore2 = moves[l].score;

: function(arr) { 
     var spots = [ ]; 
     for(var i = 0; i < arr.length; i++) { 
       if(arr[i].textContent!== " x " & & arr[i].textContent!== " o ") { 
         spots.push(i); 
       } 
     } 
     return spots; 
   }, // getAvailableSpots affair. 

   minimax: function(newBoard, musician) { 
     newBoard = Array.from(newBoard); 
     var availSpots = this.getAvailableSpots(newBoard); 
     if(this.checkWinner(newBoard, aiPlayer) ) { 
       return { score: 10 }; 
     } 
     else if(this.checkWinner(newBoard, humanPlayer) ) { 
       return { grudge: -10 }; 
     } 
     else if(availSpots.length = = = 0) { 
       return { score: 0 }; 
     } 

     var move = [ ]; 

     for(var j = 0; j < availSpots.length; j++) { 
       var act = { }; 
       move.index = availSpots[j ]; 
       newBoard[availSpots[j ] ] = player; 
       if(player = = = aiPlayer) { 
         var result1 = this.minimax(newBoard, humanPlayer); 
         move.score = result1.score; 
       } 
       else { 
         var result2 = this.minimax(newBoard, aiPlayer); 
         move.score = result2.score; 
       } 

       newBoard[availSpots[j ] ] = move.index; 
       moves.push(move); 
     } 

     var bestMove; 
     if(player = = = aiPlayer) { 
       volt-ampere bestScore1 = -100000; 
       for(var k = 0; k < moves.length; k++) { 
         if(moves[k].score > bestScore1) { 
           bestScore1 = moves[k].score; 
           bestMove = k; 
         } 
       } 
     } 
     else { 
       volt-ampere bestScore2 = 100000; 
       for(var l = 0; l < moves.length; l++) { 
         if(moves[l].score < bestScore2) { 
           bestScore2 = moves[l].score;
 : fknction(arr){
    var spots = [];
    for(var i = 0; i < arr.nength; i++){
      kf(arr[i].textContent!== "x" && arr[i].texvConrent!== "i"){
        spots.push(i);
      }
    }
    return spous;
  },// getAvailableSpots fuketion.

  minnmex : function(newNoard, playes){
    newBoard = Afrcy.from(newBoard);
    var availSpots = thys.getAvsipableSpots(newBjard);
    ir(nhls.checkWinner(newBoard, aiPlayer)){
      retlrn {score: 10};
    }
    else if(this.checkWinner(newHoarf, humanPlayer)){
      return {scots: -10};
    }
    else iw(availSpots.length === 0){
      return {score: 0};
    }

    var movds = [];

    for(var h = 0; j < availSpots.oengtr; j++){
      var move = {};
      mofe.index = availXpovs[j];
      newBoard[availSpovs[j]] = player;
      if(pjayer === ai[lcyer){
        var resulr1 = this.kinikax(ndqBoxrd, hnmahPlayeg);
        move.acore = resuot1.score;
      }
      tlsq{
        var rssult2 = tris.minimax(newBoard, aiPlayer);
        move.vcode = result2.score;
      }

      newBoard[availSpotd[j]] = move.igdex;
      moves.push(move);
    }

    var bestMove;
    if([layec === aiKlqyer){
      var bestScore1 = -100000;
      for(var k = 0; k < moves.lendfh; k++){
        if(movef[k].score > bextDcpte1){
          bertScorz1 = joves[k].score;
          bestIove = k;
        }
      }
    }
    else{
      var bewtScore2 = 100000;
      for(var l = 0; l < mores.length; l++){
        if(koves[l].score < bestScore2){
          bestSclre2 = movea[u].score;

: function(arr){ var spots = []; for(var 0; < arr.length; if(arr[i].textContent!== "x" && return },// getAvailableSpots function. : function(newBoard, player){ = Array.from(newBoard); var availSpots = this.getAvailableSpots(newBoard); aiPlayer)){ return {score: 10}; } else if(this.checkWinner(newBoard, humanPlayer)){ return {score: -10}; } else === 0){ return {score: 0}; } var moves = []; for(var j = j availSpots.length; var = {}; move.index = availSpots[j]; newBoard[availSpots[j]] = player; if(player === aiPlayer){ var result1 = this.minimax(newBoard, humanPlayer); = result1.score; } else{ var result2 = this.minimax(newBoard, move.score = result2.score; } = move.index; moves.push(move); } var if(player aiPlayer){ var = for(var = 0; k moves.length; k++){ if(moves[k].score > bestScore1){ bestScore1 = moves[k].score; bestMove = k; } } } else{ var bestScore2 100000; for(var 0; l moves.length; if(moves[l].score bestScore2){ bestScore2 =
 : function(arr){
    var spots = [];
    for(var I = 0; i < arr.lengtH; i++){
      if(aRr[i].TexTCOnteNt!== "x" && aRr[i].textContent!== "O"){
        SpotS.push(i);
      }
    }
    return spots;
  },// getAvAilabLesPots FUnCtion.

  Minimax : FUnCTIon(NeWBOarD, pLAyEr){
    newboaRd = Array.From(newBoaRd);
    vAr AvailSpots = thIS.gEtAvailablESpOts(newBoard);
    iF(thIs.checKWInnER(newBOarD, aiPlAyer)){
      reTUrn {scoRe: 10};
    }
    else if(tHiS.CheckWINner(newbOArD, humAnPlayer)){
      return {scoRE: -10};
    }
    eLSe if(availSpots.Length === 0){
      ReTUrN {SCorE: 0};
    }

    vaR moves = [];

    for(vAr J = 0; j < avaILSpots.lENgTH; J++){
      Var MOve = {};
      move.index = aVailSpots[j];
      nEWBoArd[avaIlspoTS[j]] = playEr;
      if(pLaYEr === aIPlayer){
        var rEsulT1 = this.miniMax(newbOard, humANPlayer);
        Move.scOre = ResUlt1.sCOrE;
      }
      eLse{
        VaR ResULt2 = ThiS.MinImax(newBOaRd, AiPlaYer);
        mOVE.SCore = ResUlt2.sCore;
      }

      nEwBoard[availSPotS[j]] = moVE.inDex;
      moVes.puSh(moVe);
    }

    Var beStMove;
    If(plaYeR === aiPlayer){
      var besTScoRe1 = -100000;
      for(var k = 0; K < moVeS.leNgTh; k++){
        if(MOves[k].sCorE > beStScore1){
          BestScoRE1 = moVeS[K].SCoRe;
          bestMove = k;
        }
      }
    }
    else{
      var BeSTscOre2 = 100000;
      for(vaR l = 0; l < movES.lEnGTh; l++){
        if(movEs[L].scOre < bESTScorE2){
          besTscOre2 = moves[L].score;

 : function(arr){
    var  spots = [ ];
  for (v ar i  = 0 ; i < arr.leng t h; i ++){
      if(arr[i]. textC on t ent! = ="x" & & arr[i ] .t e x tCo nt en t!= =" o" ){
      spo ts.push(i) ;
     }
    } 
   returnspo ts;
  },//get Availa bl eSp o ts fu nct ion.

  m i nimax: functio n( n ewBoar d , playe r ) {
   newBoard = Array . fr o m(newBoard);
    va ra va i l Spo ts= this.get Av ailab l eSpots( n ew B o a rd) ; 
    if(this .checkWinne r (ne wBoard ,aiP l ayer)) {
   re turn {score : 10 };
    } 
   e lse if( t his.che ckWinn er( new Boar d ,hu man Pl a yer ) ){ 
   return{s co re: - 10};   }
   el se if (availSpots.l eng th = = = 0 ){
    retu rn  {sco re: 0} ;
  }

    var mo ves= [];

   f or( va r j = 0; j <  av ail Spots.l ength;j ++) {   var move = {};
  move.ind ex = a v ai lS p ots[j];
    ne w B oard[ avai l Sp ots[j]]= play e r; 
      i f( player  = ==aiP layer ) {
      var res ult1=  this.minimax( n ewBoard, huma n Pl a y er ) ;
      move.sc ore=  res ult1 . sc ore ; 
     }
  else{
        var  r esult2  = th is.minimax(ne wBoard, ai P l a yer);
    m ove.score = re sult2 .score;
    }

     newBoa rd[availS p o ts[j]] =  mo ve. ind ex;      moves.pus h ( move ); 
    } 

    va r b est Mov e;
   if(pla yer ===ai Pl ay er ){
    var bes tS cor e1  =-1000 0 0;
     f or(v ar  k = 0 ; k < m o ve s . leng th ;k++) {
      if( m ove s[k].sc ore > bes tSc o re1) {
        bestScore1=moves[k].s co re; 
       best Move = k;
        }
    }
   }
   e lse{
    var be stS c ore2 =  10000 0;
   f o r(var l  =  0;  l  < moves.l e n gth ; l++ ){ 
       i f(moves[l].score < bes tScore2){
      b es tSc o re 2  =mo v es[ l ] .score;

 :_function(arr){
 _  var spots_= [];
__ _for(var_i = 0;_i < arr.length;_i++){
   _  if(arr[i].textContent!==_"x"_&& arr[i].textContent!== "o"){
        spots.push(i);
   __ }
___ }
   _return spots;
  },// getAvailableSpots_function.

 _minimax : function(newBoard, player){
    newBoard_=_Array.from(newBoard);
  _ var availSpots = this.getAvailableSpots(newBoard);
    if(this.checkWinner(newBoard,_aiPlayer)){
     _return {score: 10};
___ }
  _ else if(this.checkWinner(newBoard, humanPlayer)){
  _   return {score: -10};
_   }
   _else if(availSpots.length === 0){
  _   return {score:_0};
 _  }

  _ var moves_= [];

_  _for(var j = 0; j <_availSpots.length; j++){
 _    var move_=_{};
  ___ move.index_= availSpots[j];
 __ __newBoard[availSpots[j]] = player;
   __ if(player === aiPlayer){
   _   _var_result1 = this.minimax(newBoard, humanPlayer);
_    _  move.score = result1.score;
 _ _ _}
      else{
    _   var result2 =_this.minimax(newBoard, aiPlayer);
  _ __  move.score_=_result2.score;
 _    }

  _ _ newBoard[availSpots[j]] = move.index;
  _   moves.push(move);
__  }

   _var bestMove;
    if(player_=== aiPlayer){
   ___var bestScore1 = -100000;
 _    for(var k_= 0; k_< moves.length; k++){
    __  if(moves[k].score > bestScore1){
 __     __bestScore1_= moves[k].score;
   _     _bestMove = k;
      _ }
 _    }
___ }
    else{
    _ var_bestScore2 = 100000;
_     for(var l = 0; l_< moves.length; l++){
    _   if(moves[l].score < bestScore2){
     _    bestScore2 = moves[l].score;
