Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

1. given the following code snippet for the tic tac toe game, which par…

Question

  1. given the following code snippet for the tic tac toe game, which part of the ai computer algorithm is executed? (click here to see the complete program)
  2. if isspacefree(board, 5):

return 5

  1. for i in range(1, 10):

copy = getboardcopy(board)
if isspacefree(copy, i):
makemove(copy, playerletter, i)
if iswinner(copy, playerletter):
return i

  1. for i in range(1, 10):

copy = getboardcopy(board)
if isspacefree(copy, i):
makemove(copy, computerletter, i)
if iswinner(copy, computerletter):
return i

  1. return

chooserandommovefromlist(board, 2, 4, 6, 8)

  1. move =

chooserandommovefromlist(board, 1, 3, 7, 9)
if move != none:
return move
a. try to take one of the corners, if they are free
b. check if the player could win on the next move, and block that move.
c. check if computer can win in the next move.
d. move on one of the sides.
e. try to take the center, if it is free.

Explanation:

Brief Explanations

The first if statement checks if the center space (index 5 in a 1 - 9 numbering for a Tic - Tac - Toe board) is free and if so, returns 5, which means trying to take the center if it is free.

Answer:

e. Try to take the center, if it is free