move input( return int(move def chooserandommovefromlist(boardmoveslist) returns valid move from the passed list on the passed board returns none if there is no valid move possiblemoves [ for in moveslist if isspacefree(boardi) possiblemoves append( if len(possiblemoves! return random choice(possiblemoves else return none def getcomputermove(boardcomputerletter) given board and the computer' letterdetermine where to move and return that move if computerletter =' ' playerletter ' else playerletter ' here is our algorithm for our tic tac toe ai firstcheck if we can win in the next move for in range( ) copy getboardcopy(board if isspacefree(copyi) makemove(copycomputerletteri if iswinner(copycomputerletter) return check if the player could win on their next moveand block them for in range( ) copy getboardcopy(board if isspacefree(copyi) makemove(copyplayerletteri if iswinner(copyplayerletter) return try to take one of the cornersif they are free move chooserandommovefromlist(board[ ] if move !none return move try to take the centerif it is free