set to the highest scoring move the code has found so farand bestscore is set to the best move' score when the code in the loop finds move that scores higher than bestscoreline to will store that move and score as the new values in bestmove and bestscore simulate all possible moves on duplicate board data structures before simulating moveline makes duplicate game board data structure by calling getboardcopy(you'll want copy so you can modify without changing the real game board data structure stored in the board variable then line calls makemove()passing the duplicate board (stored in dupeboardinstead of the real board this will simulate what would happen on the real board if this move was made makemove(will handle placing the computer' tile and the flipping the player' tiles on the duplicate board line calls getscoreofboard()with the duplicate boardwhich returns dictionary where the keys are 'xand ' 'and the values are the scores for examplepretend that getscoreofboard(returns the dictionary {' ': ' ': and computertile is 'xthen getscoreofboard(dupeboard)[computertilewould evaluate to {' ': ' ': }[' ']which would then evaluate to if is larger than bestscorebestscore is set to and bestmove is set to the current and values by the time this for loop is finishedyou can be sure that bestscore is the highest possible score move can makeand that move is stored in bestmove line first sets bestscore to - so that the first move the code checks will be set to the first bestmove this will guarantee that bestmove is set to one of the moves from possiblemoves when it returns even though the code always chooses the first in the list of these tied movesit' random because the list order was shuffled on line this ensures that the ai won' be predictable when there' more than one best move printing the scores to the screen def showpoints(playertilecomputertile) prints out the current score scores getscoreofboard(mainboard print('you have % points the computer has % points (scores[playertile]scores[computertile])