return board 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 [ for xdirectionydirection in [[ ][ ][ ][ - ][ ][- - ][- ][- ]] xy xstartystart +xdirection first step in the direction +ydirection first step in the direction if isonboard(xyand board[ ][ =othertile there is piece belonging to the other player next to our piece +xdirection +ydirection if not isonboard(xy) continue while board[ ][ =othertile +xdirection +ydirection if not isonboard(xy)break out of while loopthen continue in for loop break if not isonboard(xy) continue if board[ ][ =tile there are pieces to flip over go in the reverse direction until we reach the original spacenoting all the tiles along the way while true -xdirection -ydirection if =xstart and =ystart