本文整理汇总了Python中model.Model.move方法的典型用法代码示例。如果您正苦于以下问题:Python Model.move方法的具体用法?Python Model.move怎么用?Python Model.move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Model
的用法示例。
在下文中一共展示了Model.move方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import move [as 别名]
class Controller:
def __init__(self):
self.model = Model()
self.view = View(self.model.WORLD_SIZE)
self.view.main_menu = True
# self.model.robot.image=self.model.robot.image.convert(pygame.Surface((20, 20)))
# self.model.robot.image=self.model.robot.image.convert_alpha(pygame.Surface((20, 20)))
# self.model.robot.image.set_colorkey((255,255,255))
def Run(self, ):
main = self.model.get_keyboard() # checking if QUIT has been pressed
if self.view.new_game:
self.model.restart()
self.view.new_game = False
if (not self.view.game_over) and (not self.view.main_menu):
self.model.get_position_agents() # analyzing social situation
self.model.update_won_towers()
self.model.get_targets()
self.model.get_outcome_matrices()
self.model.map_outcome_matrices_in_interdependence_space()
self.model.check_for_deception()
self.model.move(self.view.dt) # moving the agents
self.view.display(self.model)
if not main:
return False
else:
return True
示例2: makemove
# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import move [as 别名]
def makemove(self):
if self.move >= 4:
return
model = Model()
model.grid = self.grid.copy()
model.move(self.move)
if (self.grid == model.grid).all():
self.invalid = True
self.grid = model.grid.copy()
示例3: zip
# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import move [as 别名]
for row, col in zip(*np.where(node.grid == 0)):
newnode = Node(move = 4, grid = node.grid)
newnode.grid[row, col] = 2
node.children.append(decide(newnode, depth - 1))
node.getScore()
return node
if __name__ == "__main__":
# pygame.init()
while True:
current_model = Model()
# view = View(current_model)
while True:
grid = current_model.grid.copy()
if len(np.where(grid != 0)[0]) > 8:
depth = 5
else:
depth = 3
node = decide(Node(5, grid), depth = depth)
move = node.bestMove()
if move == None:
print "GAMEOVER"
break
current_model.move(move)
# view.draw()
current_model.update()
# view.draw()
print np.max(node.grid)