本文整理汇总了Python中car.Car.new方法的典型用法代码示例。如果您正苦于以下问题:Python Car.new方法的具体用法?Python Car.new怎么用?Python Car.new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类car.Car
的用法示例。
在下文中一共展示了Car.new方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: move
# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import new [as 别名]
def move(self, steps: int) -> 'MegaCar':
"""
Move car "step" amount of places.
"""
if self.horizontal:
return Car.new(self.start + Position.new(steps, 0), self.horizontal,
self.length)
else:
return Car.new(self.start + Position.new(0, steps), self.horizontal,
self.length)
示例2: Board
# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import new [as 别名]
from board import Board
from car import Car
from position import Position
level1 = Board(cars=[
Car.new(Position.new(2, 2), True, 2),
Car.new(Position.new(3, 3), False, 2),
Car.new(Position.new(4, 0), False, 3),
Car.new(Position.new(4, 4), True, 2)
], goal=(0, Position.new(5, 2)),
board_height=6,
board_width=6
)
game1 = Board(goal=(0, Position.new(5, 2)),
board_height=6,
board_width=6,
cars=[
Car.new(length=2, horizontal=True, start=Position.new(3, 2)),
Car.new(length=3, horizontal=False, start=Position.new(2, 0)),
Car.new(length=2, horizontal=True, start=Position.new(3, 0)),
Car.new(length=3, horizontal=False, start=Position.new(5, 0)),
Car.new(length=2, horizontal=True, start=Position.new(4, 3)),
Car.new(length=2, horizontal=False, start=Position.new(0, 4)),
Car.new(length=2, horizontal=True, start=Position.new(1, 4)),
Car.new(length=2, horizontal=False, start=Position.new(3, 3)),
Car.new(length=2, horizontal=True, start=Position.new(4, 5)),
]
)
game2 = Board(goal=(0, Position.new(5, 2)),