本文整理汇总了Python中simulator.Simulator.step方法的典型用法代码示例。如果您正苦于以下问题:Python Simulator.step方法的具体用法?Python Simulator.step怎么用?Python Simulator.step使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulator.Simulator
的用法示例。
在下文中一共展示了Simulator.step方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_simulate
# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import step [as 别名]
def test_simulate():
state = State(regions, routes)
state.set_outbreak('Paris', 1000)
sim = Simulator(state)
total_population_pre = sim.state.total_sir().total_pop
sim.step()
total_population_post = sim.state.total_sir().total_pop
# check that transfers and disease spread didn't change the world
# population'
assert_equal(total_population_pre, total_population_post)
示例2: while
# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import step [as 别名]
lastSentBoatData = 0
lastAISSent = 0
try:
while( net.connected() ):
deb = time.time()
(command_rudder, command_sheet) = net.readActuatorData()
(delta_r, delta_s) = order_to_deg(command_rudder, command_sheet)
simulatedBoat.physicsModel().setActuators( delta_s, delta_r )
# TODO - Jordan: Make this a variable step, so we aren't at a fixed rate of simulation
simulator.step( 0.05 )
millis = getMillis();
# Send the boat data
if millis > lastSentBoatData + BOAT_UPDATE_MS:
net.sendBoatData( simulatedBoat )
lastSentBoatData = millis
# Send AIS data
if millis > lastAISSent + AIS_UPDATE_MS:
for i in range( 1, len(vessels) ):
if vessels[i].id() < 100000000 and boatInVisualRange(vessels[0], vessels[i]):
net.sendVisualContact( vessels[i] )
else:
net.sendAISContact( vessels[i] )
示例3: Simulator
# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import step [as 别名]
from simulator import Simulator
from window import Window
from anchor import Anchor
from free_joint import FreeJoint
sim = Simulator()
win = Window(sim)
cA = Anchor((70,110))
cB = FreeJoint((100,110))
cC = Anchor((130,110))
cD = FreeJoint((85,90))
cE = FreeJoint((115,90))
sim.create_segment(cA, cB)
sim.create_segment(cA, cD)
sim.create_segment(cB, cD)
sim.create_segment(cB, cC)
sim.create_segment(cB, cE)
sim.create_segment(cC, cE)
sim.create_segment(cD, cE)
raw_input("Created. Press key")
while True:
sim.step()
if raw_input("Stepped. Presss key") == 'q':
break
示例4: AppWindow
# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import step [as 别名]
class AppWindow(object):
def __init__(self):
self._is_playing = False
self._images = {}
self._create_layout()
def run(self):
self._root.mainloop()
def _get_image(self, name):
image = self._images.get(name)
if image is None:
image = ImageTk.PhotoImage(Image.open(os.path.join('resources/icons', name)))
self._images[name] = image
return image
def _create_simulator(self):
world = World()
world.build_from_file('settings.xml')
self._simulator = Simulator(world, timedelta(milliseconds=10))
self._target = None
def _render(self):
self._view.delete(tk.ALL)
# TODO: Grid lines
for obstacle in self._simulator._world.obstacles:
self._view.create_polygon(obstacle.geometry, fill='#ff6666')
for robot in self._simulator._world.robots:
for surface in robot.get_surfaces():
self._view.create_polygon(surface[0].geometry, fill=surface[1])
if self._target is not None:
size = 0.03
bbox = [
self._target[0] - size / 2,
self._target[1] - size / 2,
self._target[0] + size / 2,
self._target[1] + size / 2
]
self._view.create_oval(bbox, fill='green')
self._view.tag_bind('robot', '<Button-1>', self._focus_view)
self._view.scale(tk.ALL, 0, 0, self._zoom, self._zoom)
if self._bounds is None:
self._update_bounds()
self._scroll_to(0.0, 0.0)
def _update(self):
self._simulator.step()
self._set_time(self._simulator.time)
self._render()
if self._simulator.has_crashed:
self._is_playing = False
self._status_icon.config(image=self._get_image('ui_status_error.png'))
if self._is_playing:
self._root.after(1, self._update)
def _create_layout(self):
self._root = tk.Tk()
self._root.title('Sim.I.am')
self._root.geometry('800x800')
self._zoom = 200
self._bounds = None
rows = [
{ 'minsize': 24 },
{ 'weight': 1},
{ 'weight': 1},
{ 'minsize': 36 }
]
columns = [
{ 'minsize': 48 },
{ 'minsize': 48 },
{ 'minsize': 48 },
{ 'weight': 1},
{ 'minsize': 64 },
{ 'minsize': 96 },
{ 'minsize': 64 },
{ 'weight': 1},
{ 'minsize': 48 },
{ 'minsize': 48 },
{ 'minsize': 48 }
]
for row, options in enumerate(rows):
self._root.rowconfigure(row, **options)
#.........这里部分代码省略.........