checking if move is valid def isvalidmove(boardtilexstartystart) returns false if the player' move on space xstartystart is invalid if it is valid movereturns list of spaces that would become the player' if they made move here if board[xstart][ystart!or not isonboard(xstartystart) return false board[xstart][ystarttile temporarily set the tile on the board if tile =' ' othertile ' else othertile ' tilestoflip [given board data structurethe player' tileand the xy coordinates for player' moveisvalidmove(should return true if the reversi game rules allow move to those coordinates and false if they don' line checks if the xy coordinates are not on the game boardor if the space isn' empty isonboard(is function defined later in the program that makes sure both the and coordinates are between and the next step is to temporarily place the player' tile on the board this tile will be removed (by setting the board space back to before returningthe player' tile (either the human player or the computer playeris in tilebut this function will need to know the other player' tile if the player' tile is 'xthen obviously the other player' tile is ' 'and vice versa finallyif the given xy coordinate ends up as valid positionisvalidmove(returns list of all the opponent' tiles that would be flipped by this move for xdirectionydirection in [[ ][ ][ ][ - ][ ][- - ][- ][- ]]the for loop iterates through list of lists which represent directions you can move on the game board the game board is cartesian coordinate system with an and direction there are eight directions you can moveupdownleftrightand the four diagonal directions each of the eight -item lists in the list on line is used for moving in one of these directions the program moves in direction by adding the first value in the two-item list to the coordinateand the second value to the coordinate