def fireTorpedos(mineField, xyzDeltas):
     """ Given a MineField instance and a list of (x,y,z) ship offsets, fire a volley of torpedos.
     """
     shipPosition = mineField.getShipPosition()
     for xyzDelta in xyzDeltas:
         torpedoPosition = MineField.addCoordinates(shipPosition, xyzDelta)
         mineField.setMinePositions(
             [ mp for mp in mineField.getMinePositions() if mp[0] != torpedoPosition[0] or mp[1] != torpedoPosition[1]]
         )
 def buildMoveFunction(xyzDelta):
     """ Provided an (x,y,z) delta for a given move, return a function to execute that move.
     """
     return lambda mineField, xyzDelta=xyzDelta: \
         mineField.setShipPosition(MineField.addCoordinates(mineField.getShipPosition(), xyzDelta))