import random
class OceanTreasure:
def __init__(self):
self.__board = [['~'] * 60 for row in range(15)]
self.__chests = []
while len(self.__chests) < 3:
coord = [str(random.randint(0, 59)), str(random.randint(0, 14))]
if coord not in self.__chests:
self.__chests.append(coord)
def getChests(self):
# returns the list of coordinates of the chests still to be found.
return self.__chests
def getTreasuresLeft(self):
# returns the number of treasure chests still to be found.
return len(self.__chests)
def dropSonar(self, x, y, sonar):
distance = self.checkDistance(x, y)
if distance == None:
sonar = 'O'
elif distance == 0:
self.__chests.remove([x, y])
sonar = 'X'
elif distance > 0:
sonar = str(distance)
elif distance < 0:
if distance == -1:
sonar = 'a'
elif distance == -2:
sonar = 'b'
elif distance == -3
Python代码:声呐搜索
最新推荐文章于 2023-05-19 16:56:00 发布

最低0.47元/天 解锁文章
871

被折叠的 条评论
为什么被折叠?



