harbor run -t openthoughts/tasktrove-exp-flat25-pseudocode-v2-5k-pseudocode-1672harbor download openthoughts/tasktrove-exp-flat25-pseudocode-v2-5k-pseudocode-1672PSEUDOCODE TASK DESCRIPTION
Module: engine/physics/line.py Class Line Data p1 : (x1, y1) p2 : (x2, y2) Constructor init(endpoints) endpoints is a list/tuple: [(x1, y1), (x2, y2)] set p1 and p2 from endpoints Properties x1, y1 retrieve from p1 x2, y2 retrieve from p2 Methods set_position_rotation(dx, dy, rotation_deg) p1 := (p1.x + dx, p1.y + dy) p2 := (p2.x + dx, p2.y + dy) if rotation_deg != 0 θ := rotation_deg * (pi / 180) c := cos(θ) s := sin(θ) p1 := (p1.x * c - p1.y * s, p1.x * s + p1.y * c) p2 := (p2.x * c - p2.y * s, p2.x * s + p2.y * c) update internal endpoints to p1, p2 freeze() // No-op for tests; interface must exist
Module: engine/geometry/bounding_box.py Class BoundingBox Data owner // object with 2D position attribute: [x, y, z] half_size // scalar half-width/half-height moving_right // numeric velocity indicator along x-axis lines // list[Line] representing 4 edges (in world coords) _moving_points // list[(x, y)] of 4 corner points in world coords Constructor init(owner, half_size, moving_right) store owner, half_size, moving_right lines := empty list _moving_points := empty list call rebuild(owner.position[0:2]) Methods iter() -> iterable yield self // allow: for bb in some_ship.bounding_box: ... rebuild(owner_position) // owner_position is (x, y) cx, cy := owner_position hs := half_size c1 := (cx - hs, cy - hs) // bottom-left c2 := (cx + hs, cy - hs) // bottom-right c3 := (cx + hs, cy + hs) // top-right c4 := (cx - hs, cy + hs) // top-left lines := [ Line([c1, c2]), Line([c2, c3]), Line([c3, c4]), Line([c4, c1]) ] _moving_points := [c1, c2, c3, c4] store lines and _moving_points Notes The bounding box is axis-aligned; rotation does not affect _moving_points unless explicit rotation handling is added. Initial bounding box is built from the owner's initial position.
Module: engine/models/factories.py Class ShipModelFactory Methods manufacture(kind, position=[10, 0, 0]) if kind == "ship" return Ship(position=position) else return None or raise error Class AsteroidModelFactory Methods manufacture(position=[-50, 0, 0], rotation=(0, 0, 0)) return Asteroid(position=position, rotation=rotation)
Class Ship Data position : [x, y, z] bounding_box : BoundingBox Constructor init(position=[10, 0, 0]) self.position := list(position) self.bounding_box := BoundingBox(owner=self, half_size=5, moving_right=-1) Methods set_position(x, y, z) self.position := [x, y, z] set_position_and_rotation(x, y, z, rx, ry, rz) self.position := [x, y, z] // rotation is ignored for tests update_bounding_box() self.bounding_box.rebuild(self.position[0:2]) intersection_point(other) bb1 := self.bounding_box bb2 := other.bounding_box xmin1, xmax1 := min(p.x for p in bb1._moving_points), max(p.x for p in bb1._moving_points) ymin1, ymax1 := min(p.y for p in bb1._moving_points), max(p.y for p in bb1._moving_points) xmin2, xmax2 := min(p.x for p in bb2._moving_points), max(p.x for p in bb2._moving_points) ymin2, ymax2 := min(p.y for p in bb2._moving_points), max(p.y for p in bb2._moving_points) overlap_x := max(xmin1, xmin2) overlap_x_other_bound := min(xmax1, xmax2) overlap_y := max(ymin1, ymin2) overlap_y_other_bound := min(ymax1, ymax2) collides := (overlap_x <= overlap_x_other_bound) and (overlap_y <= overlap_y_other_bound) if collides return (True, overlap_x, overlap_y) else return (False, 0, 0) polygons_in_order_of_collision(other) collides, x, y := self.intersection_point(other) if not collides return ([], []) else my_parts := ["my_part"] asteroid_parts := ["asteroid_part"] return (my_parts, asteroid_parts)
Class Asteroid Data position : [x, y, z] rotation : (rx, ry, rz) bounding_box : BoundingBox Constructor init(position=[-50, 0, 0], rotation=None) self.position := list(position) self.rotation := rotation if rotation is not None else (0, 0, 0) self.bounding_box := BoundingBox(owner=self, half_size=5, moving_right=-1) Methods set_position(x, y, z) self.position := [x, y, z] set_position_and_rotation(x, y, z, rx, ry, rz) self.position := [x, y, z] self.rotation := (rx, ry, rz) // rotation is ignored for collision tests update_bounding_box() self.bounding_box.rebuild(self.position[0:2]) intersection_point(other) // same logic as Ship.intersection_point polygons_in_order_of_collision(other) // same logic as Ship.polygons_in_order_of_collision
Notes for tests and behavior