本文整理汇总了Python中vector.Vector.update方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.update方法的具体用法?Python Vector.update怎么用?Python Vector.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector.Vector
的用法示例。
在下文中一共展示了Vector.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Entity
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import update [as 别名]
class Entity(pygame.sprite.Sprite):
def __init__(self, bounds=[0,600,0,800], size=(4,4)):
pygame.sprite.Sprite.__init__(self)
self.__update_surface_size(size) #creates scope variable "image", which is a pygame surface
self.alive = True
self.bounds = bounds
self.vector = Vector()
def die(self):
self.alive = False
self.vector.dx = 0
self.vector.dy = 0
def update(self, timestep = 1):
self.update_position(timestep)
def __update_position(self, timestep = 1):
self.vector.update(timestep)
def __update_surface_size(self, size=(1,1)):
self.image = pygame.Surface(size)
def set_size(self, size=(1,1)):
self.update_surface_size(size)
@property
def orientation(self):
return self.vector.orientation()
@property
def rect(self):
return self.image.get_rect(topleft=(self.vector.x,self.vector.y))
示例2: train
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import update [as 别名]
def train():
print
print "---Training---"
print
queryUser()
my_vector = Vector()
s = Song(root,mode,title)
for i in range(num_measures):
# Generate a vector and build a measure from it.
training_vector = Vector("user")
s.addMeasure(training_vector)
s.playMeasure(title,i)
# Get feedback
user_opinion = raw_input("What did you think of that measure? (scale from 0-10): ")
while user_opinion.isdigit() == False or int(user_opinion) < 0 or int(user_opinion) > 10:
print "Invalid Response (please select a number from 0-10)"
user_opinion = raw_input("What did you think of that measure? (scale from 0-10): ")
user_opinion = int(user_opinion)
training_vector = s.measures[i].getVector() # update in the case that we repeated
my_vector.update(training_vector,.2,user_opinion)
# Get opinion on whole song
print "Here is your song!\n"
s.playSong()
song_opinion = int(raw_input("How much did you like that song? (scale from 0-10): "))
while song_opinion < 0 or song_opinion > 10:
print "Please enter an integer between 0 and 10: "
song_opinion = raw_input("How much did you like that song? (scale from 0-10): ")
while song_opinion.isdigit() != False or int(song_opinion) < 0 or int(song_opinion) > 10:
print "Invalid Response (please select a number from 0-10)"
song_opinion = raw_input("How much did you like that song? (scale from 0-10): ")
song_opinion = int(song_opinion)
# Update master based on user opinion
master = Vector("master")
master.update(my_vector,.05,song_opinion)
master.normalize()
master.writeToFile(".master.vct")
if user_opinion > 6 and num_measures > 7:
my_vector.writeToFile(".user_vectors.vct")