本文整理汇总了Python中simulation.Simulation.advance_cars_and_record方法的典型用法代码示例。如果您正苦于以下问题:Python Simulation.advance_cars_and_record方法的具体用法?Python Simulation.advance_cars_and_record怎么用?Python Simulation.advance_cars_and_record使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulation.Simulation
的用法示例。
在下文中一共展示了Simulation.advance_cars_and_record方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_matrix_updates_from_cars
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import advance_cars_and_record [as 别名]
def test_matrix_updates_from_cars():
with mock.patch('random.random', return_value=.50):
sim = Simulation(4)
sim.create_cars(4)
sim.create_empty_data_matrix()
sim.give_cars_starting_places()
sim.advance_cars_and_record()
sim.decide_speed_and_record()
assert sim.cars[0].speed == 2
示例2: test_decide_speed_sets_new_speed_for_cars
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import advance_cars_and_record [as 别名]
def test_decide_speed_sets_new_speed_for_cars():
with mock.patch("random.random", return_value=.5):
sim = Simulation(4)
sim.create_cars(4)
sim.create_empty_data_matrix()
sim.give_cars_starting_places()
sim.advance_cars_and_record()
sim.decide_speed_and_record()
assert sim.cars[0].speed ==2
assert sim.turn_count ==1
示例3: test_advance_cars_and_record_adds_speed_to_car_location_over_1000
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import advance_cars_and_record [as 别名]
def test_advance_cars_and_record_adds_speed_to_car_location_over_1000():
sim = Simulation(4)
sim.create_cars(4)
sim.create_empty_data_matrix()
sim.give_cars_starting_places()
sim.advance_cars_and_record()
sim.turn_count +=1
sim.data_matrix[1][1] = [10, 10, 10, 10]
sim.advance_cars_and_record()
assert np.array_equal(sim.data_matrix[0][2], [15, 345, 675, 5])
示例4: test_advance_cars_and_record_adds_speed_to_car_location
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import advance_cars_and_record [as 别名]
def test_advance_cars_and_record_adds_speed_to_car_location():
sim = Simulation(4)
sim.create_cars(4)
sim.create_empty_data_matrix()
sim.give_cars_starting_places()
sim.advance_cars_and_record()
assert np.array_equal(sim.data_matrix[0][1], sim.data_matrix[0][0])
sim.turn_count +=1
sim.data_matrix[1][1] = [2, 2, 2, 2]
sim.advance_cars_and_record()
assert np.array_equal(sim.data_matrix[0][2], [7, 337, 667, 997])
示例5: test_matrix_updates_from_cars
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import advance_cars_and_record [as 别名]
def test_matrix_updates_from_cars():
with mock.patch("random.random", return_value=.5):
sim = Simulation(4)
sim.create_cars(4)
sim.create_empty_data_matrix()
sim.give_cars_starting_places()
sim.advance_cars_and_record()
sim.decide_speed_and_record()
sim.turn_count +=1
sim.advance_cars_and_record()
sim.decide_speed_and_record()
assert sim.data_matrix[1][sim.turn_count][0] == sim.cars[0].speed
assert sim.cars[3].speed == 4