-1
def cleanTileAtPosition(self, pos):
x = math.floor(pos.getX())
y = math.floor(pos.getY())
self.tiles[(x, y)] = True
def getRandomPosition(self):
return Position(random.random() * self.width,
random.random() * self.height)
我的问题:内置python的函数。如何使用它?
在第一个功能是什么
pos
?pos
不是任何类别或字典的一部分。我们如何从中获得x
和y
?在第二个函数中,是
Position
是python的一个内置函数吗?如果是这样,为什么我们乘以width
和random.random
?它有什么意义?另外,pos
用于第一个功能这个position
的对象?帮帮我。
完整的代码来自这里似乎可以[这里](http://assets.openstudy.com/updates/attachments/4fd2fee3e4b057e7d221f7a8-chribonn-1339228071101-ps11.py)。当您了解类和实例时(请参阅Martijn Pieters的答案),可能需要阅读完整的代码以了解发生了什么。 'Position'是开头定义的类,'pos'是传递给函数'cleanTileAtPosition'的'Position'的一个实例作为参数。 – Stuart