create list of chest data structures (two-item lists of xy int coordinates chests [ for in range(numchests) chests append([random randint( )random randint( )] return chests the game also randomly decides where the hidden treasure chests are the treasure chests are represented as list of lists of two integers these two integers will be the and coordinates of single chest for exampleif the chest data structure was [[ ][ ][ ]]then this would mean there are three treasure chestsone at another chest at and third one at the numchests parameter tells the function how many treasure chests to generate line ' for loop will iterate numchests number of timesand on each iteration line appends list of two random integers the coordinate can be anywhere from to and the coordinate can be from anywhere between and the expression [random randint( )random randint( )that is passed to the append method will evaluate to list value like [ or [ or [ this list value is appended to chests determining if move is valid def isvalidmove(xy) return true if the coordinates are on the boardotherwise false return > and and < when the player types in and coordinates of where they want to drop sonar devicethey may not type invalid coordinates the coordinate must be between and and the coordinate must be between and the isvalidmove(function uses simple expression that uses and operators to ensure that each part of the condition is true if even one part is falsethen the entire expression evaluates to false this function returns this boolean value placing move on the board def makemove(boardchestsxy) change the board data structure with sonar device character remove treasure chests from the chests list as they are found return false if this is an invalid move otherwisereturn the string of the result of this move