return board def canmakemove(board) return true if the board is in state where matching move can be made on it otherwise return false the patterns in oneoffpatterns represent gems that are configured in way where it only takes one move to make triplet oneoffpatterns ((( , )( , )( , )) (( , )( , )( , )) (( , )( , )( , )) (( , )( , )( , )) (( , )( , )( , )) (( , )( , )( , )) (( , )( , )( , )) (( , )( , )( , )) the and variables iterate over each space on the board if we use to represent the currently iterated space on the boardthen this pattern(( , )( , )( , ))refers to identical gems being set up like this + that isgem is offset from the by ( , )gem is offset by ( , )and gem is offset by ( , in this casegem can be swapped to the left to form vertical three-in- -row triplet there are eight possible ways for the gems to be one move away from forming triplehence oneoffpattern has patterns for in range(boardwidth) for in range(boardheight) for pat in oneoffpatterns check each possible pattern of "match in next moveto see if possible move can be made if (getgemat(boardx+pat[ ][ ] +pat[ ][ ]= getgemat(boardx+pat[ ][ ] +pat[ ][ ]= getgemat(boardx+pat[ ][ ] +pat[ ][ ]!noneor (getgemat(boardx+pat[ ][ ] +pat[ ][ ]= getgemat(boardx+pat[ ][ ] +pat[ ][ ]= getgemat(boardx+pat[ ][ ] +pat[ ][ ]!none)email questions to the authoral@inventwithpython com