本文整理汇总了Python中Simulator.Simulator.create_tank方法的典型用法代码示例。如果您正苦于以下问题:Python Simulator.create_tank方法的具体用法?Python Simulator.create_tank怎么用?Python Simulator.create_tank使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Simulator.Simulator
的用法示例。
在下文中一共展示了Simulator.create_tank方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from Simulator import Simulator [as 别名]
# 或者: from Simulator.Simulator import create_tank [as 别名]
def main():
logging.basicConfig(level = logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
simulator = Simulator()
manager = Manager(simulator)
ticker = Ticker(1.0, manager)
xmlrpcserver = XMLRPCServer(manager)
pbrpcserver = PBRPCServer(manager)
# Add some random tanks
for team in range(4):
for tank in range(100):
retry = True
while retry:
pos = (random.randint(-100, 100), random.randint(-100, 100))
if pos not in simulator.position:
simulator.create_tank(Tank(team, pos))
retry = False
logging.info("Starting main threads")
ticker.start()
# The XML-RPC server isn't maintained at the moment
#xmlrpcserver.start()
pbrpcserver.start()
# To stop the system with Ctrl-C
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
ticker.self_destruct()