Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data LaserRay a = LaserRay {
- _laserRayDir :: !Direction
- _laserRaySeg :: !(Ray a)
- newtype Ray a = Ray Segment
- data Theoretical
- data Actual
- data LaserReach = Infinite
- shootLaser :: Coords Pos -> Direction -> LaserReach -> (Coords Pos -> Location) -> Maybe (Ray Theoretical)
- shootLaserWithOffset :: Coords Pos -> Direction -> LaserReach -> (Coords Pos -> Location) -> Maybe (Ray Theoretical)
- data LaserPolicy
- computeActualLaserShot :: [a] -> (a -> Coords Pos) -> LaserRay Theoretical -> LaserPolicy -> (([a], [a]), Maybe (LaserRay Actual))
- afterEnd :: LaserRay Actual -> Coords Pos
Laser representations
LaserRay
and Ray
are parametrized by phantom types
Theoretical
and Actual
to indicate if the ray was computed taking
obstacles into account or not:
A laser ray and the direction in which the laser was shot.
LaserRay | |
|
data Theoretical Source #
The laser ray was computed ignoring obstacles
Laser reach
Create a Theoretical Ray
shootLaser
and shootLaserWithOffset
create a Theoretical
ray, i.e it doesn't
stop at obstacles:
shootLaser :: Coords Pos -> Direction -> LaserReach -> (Coords Pos -> Location) -> Maybe (Ray Theoretical) Source #
:: Coords Pos | Start coordinates |
-> Direction | Direction of the shot |
-> LaserReach | |
-> (Coords Pos -> Location) | Collision function |
-> Maybe (Ray Theoretical) |
Same as shootLaser
but offsets the start Coords
by one in the shot Direction
.
Create an Actual Ray
computeActualLaserShot
converts a Theoretical
ray to an Actual
ray, i.e
it stops at obstacles (or not), according to LaserPolicy
:
data LaserPolicy Source #
Tells which obstacles are destroyed on the Segment
of Ray
Theoretical
DestroyFirstObstacle | The first obstacle is destroyed. |
DestroyAllObstacles | All obstacles are destroyed. |
computeActualLaserShot Source #
:: [a] | Obstacles. |
-> (a -> Coords Pos) | Obstacle to |
-> LaserRay Theoretical | The |
-> LaserPolicy | |
-> (([a], [a]), Maybe (LaserRay Actual)) |
Converts a Theoretical
laser ray to an Actual
one,
taking obstacles and a LaserPolicy
into account.
Returns a partition of obstacles between the remaining and the destroyed ones.