本文整理汇总了Python中simulation.Simulation.give_cars_starting_places方法的典型用法代码示例。如果您正苦于以下问题:Python Simulation.give_cars_starting_places方法的具体用法?Python Simulation.give_cars_starting_places怎么用?Python Simulation.give_cars_starting_places使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulation.Simulation
的用法示例。
在下文中一共展示了Simulation.give_cars_starting_places方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_matrix_updates_from_cars
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import give_cars_starting_places [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 give_cars_starting_places [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 give_cars_starting_places [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 give_cars_starting_places [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 give_cars_starting_places [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
示例6: test_cars_get_starting_places
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import give_cars_starting_places [as 别名]
def test_cars_get_starting_places():
sim = Simulation(4)
sim.create_cars(4)
sim.create_empty_data_matrix()
start_setup = sim.give_cars_starting_places()
assert sim.cars[0].location == 5
assert sim.cars[1].location == 335
assert np.array_equal(start_setup, [5, 335, 665, 995])
assert sim.data_matrix.shape == (2, 121, 4)
assert sim.data_matrix[0].shape == (121, 4)
assert sim.data_matrix[0][0].shape == (4,)