Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C PROGRAMMING INCLUDE MAIN FOR TESTING error and warning free code WILL GIVE RAT

ID: 3878941 • Letter: C

Question

C PROGRAMMING

INCLUDE MAIN FOR TESTING

error and warning free code

WILL GIVE RATING

a) program 2

b) program 3:

this is a snapshot of program 1:

Write a second program that writes a binary file, named "strategyfile", consisting of exactly 39366 bytes. This file should contain 19683 2-byte records. Each record will encode the following structure for every possible tic-tac-toe board in order for us=0 to us. 19682: struct strategy_struct char best_move char winner For now, set best move to -1 and set the value of winner to"blank space)

Explanation / Answer

determineNextMove(currentStateOfBoard)
currentBestMove= null
currentBestScore= - veryLargeNumber

for each legalMove
score=getFutureScoreOfMove(stateOfBoardAfterLegalMove , AI’sMove)
if score>currentBestScore
currentBestMove=legalMove
currentBestScore=score
end
end

make currentBestMove

end

getFutureScoreOfMove(stateOfBoard, playersTurn)

if no LegalMoves
return 1 if AI wins, 0 if draw, -1 if user wins
end


if playersTurn=AI’sTurn
currentBestScore= - veryLargeNumber //this is the worst case for AI
else
currentBestScore= + veryLargeNumber //this is the worst case for Player
end

for each legalMove
score=getFutureScoreOfMove(stateOfBoardAfterLegalMove , INVERT playersTurn)
if playersTurn ==AI’sTurn AND score>currentBestScore //AI wants positive score
currentBestScore=score
end
if playersTurn ==Users’sTurn AND score<currentBestScore //user wants negative score
currentBestScore=score
end

end

return currentBestScore
end