本文整理汇总了Python中engine.Engine.quit方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.quit方法的具体用法?Python Engine.quit怎么用?Python Engine.quit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类engine.Engine
的用法示例。
在下文中一共展示了Engine.quit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Engine
# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import quit [as 别名]
#!/usr/bin/python
from engine import Engine
engine = Engine()
engine.load()
engine.loop()
engine.quit()
quit()
示例2: Player
# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import quit [as 别名]
#.........这里部分代码省略.........
delta = self.desk_coords
from_position = self.desk.get_field_coord(_from)
to_position = self.desk.get_field_coord(_to)
# Двигает мышку
subprocess.call('xdotool mousemove %d %d' %(from_position[0] + delta[0], from_position[1] + delta[1]), shell=True)
subprocess.call('xdotool mousedown 1', shell=True)
subprocess.call('xdotool mousemove %d %d' %(to_position[0] + delta[0], to_position[1] + delta[1]), shell=True)
subprocess.call('xdotool mouseup 1', shell=True)
subprocess.call('xdotool mousemove %d %d' %(0, 0), shell=True)
def play(self):
while True:
time.sleep(STEP_TIME)
move = self.get_move()
print u'ход %s' %move
if move == self.steps[-1]:
continue
if move is not None:
self.change_position(move)
self.change_step_side()
self.steps.append(move)
moves = ' '.join(self.steps)
self.engine.move(moves)
our_move = self.engine.calulate()
self.steps.append(our_move)
print u'мы ходим %s' %our_move
self.go(our_move)
self.change_step_side()
self.change_position(our_move)
def get_move(self):
old_position = self.position
d = Desk(self.side, self.desk_coords)
position = d.get_position()
diff = position.symmetric_difference(old_position)
print '#'*10
print 'old'
print old_position
print '#'*10
print 'new'
print position
print '#'*10
print 'diff'
print diff
print '#'*10
from_move = None
to_move = None
figure = ''
if len(diff) == 2:
# Просто ход фигуры и пешка дошла до края
from_figure = None
to_figure = None
for i in diff:
if {i}.issubset(old_position):
from_move = i[0]
from_figure = i[1]
else:
to_move = i[0]
to_figure = i[1]
if to_figure != from_figure:
figure = to_figure[0]
elif len(diff) == 3:
# Срубили фигуру и взятие на проходе
fig = None
for i in diff:
if {i}.issubset(position):
to_move = i[0]
fig = i[1]
for i in diff:
if i[1] == fig and i[0] != to_move:
from_move = i[0]
elif len(diff) == 4:
# Рокировка
for i in diff:
if i[1][0] == 'k':
if {i}.issubset(old_position):
from_move = i[0]
else:
to_move = i[0]
# elif len(diff) == 0:
# return None
# else:
# print diff
# plot(d.desk)
if from_move is None:
return None
else:
step = '%s%s%s' %(from_move, to_move, figure)
return step
def __del__(self):
self.engine.quit()