in data/task_scripts/main/task00274.py [0:0]
def build_task(C, h0, w1, w2, w3, w4, w5, angle):
scene_width = C.scene.width
scene_height = C.scene.height
# h0 = 0.6
# w1 = 0.1
# w2 = 0.15
# w3 = 0.1
# w4 = 0.25
# w5 = 0.1
# w6 = 0.1
eps = 0.005 * scene_width
# angle = 15
ramp1 = C.add('static bar', angle=360 - angle,
scale=w1 / cos(angle),
left=0,
bottom=h0 * scene_height)
teeter1 = C.add('dynamic bar', scale=w2,
left=ramp1.right + eps,
bottom=ramp1.bottom)
fulcrum1 = C.add('static ball', scale=0.05,
center_x=teeter1.center_x,
top=teeter1.bottom)
fulcrum1b = C.add('static ball', scale=0.05,
right=teeter1.right,
top=teeter1.bottom)
floor1 = C.add('static bar', scale=w2,
left=teeter1.left,
top=fulcrum1.bottom)
ramp2 = C.add('static bar', angle=360-angle,
scale=w3 / cos(angle),
left=teeter1.right + eps,
top=teeter1.top)
teeter2 = C.add('dynamic bar', scale=w4,
left=ramp2.right + eps,
bottom=ramp2.bottom)
fulcrum2 = C.add('static ball', scale=0.05,
center_x=teeter2.center_x,
top=teeter2.bottom)
fulcrum2b = C.add('static ball', scale=0.05,
right=teeter2.right,
top=teeter2.bottom)
floor2 = C.add('static bar', scale=w4,
left=teeter2.left,
top=fulcrum2.bottom)
ramp3 = C.add('static bar', angle=360-angle,
scale=w5 / cos(angle),
left=teeter2.right + eps,
top=teeter2.top)
w6 = 1.0 - w1 - w2 - w3 - w4 - w5 - 5 * eps / scene_width
if w6 < 0.2:
raise creator_lib.SkipTemplateParams
target = C.add('static bar', scale=w6,
left=ramp3.right + eps,
bottom=ramp3.bottom)
ball = C.add('dynamic ball', scale=0.05,
left=0,
bottom=ramp1.top)
ceil = C.add('static bar', scale=1.0,
left=0,
top=ball.top + 0.1 * scene_height)
if ceil.top > scene_height or target.bottom < 0:
raise creator_lib.SkipTemplateParams
C.update_task(
body1=ball,
body2=target,
relationships=[C.SpatialRelationship.TOUCHING],
)
C.set_meta(C.SolutionTier.PRE_TWO_BALLS)