tilestoflip [ check each of the eight directions for xdirectionydirection in [[ ][ ][ ][ - ][ ][- - ][- ][- ]] xy xstartystart +xdirection +ydirection if isonboard(xyand board[ ][ =othertile the piece belongs 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 break out of while loopcontinue in for loop 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 break tilestoflip append([xy] board[xstart][ystartempty_space make space empty if len(tilestoflip= if no tiles flippedthis move is invalid return false return tilestoflip def isonboard(xy) returns true if the coordinates are located on the board return > and and boardheight def getboardwithvalidmoves(boardtile) returns new board with hint markings dupeboard copy deepcopy(board