-
Notifications
You must be signed in to change notification settings - Fork 0
/
Drone.hs
38 lines (29 loc) · 873 Bytes
/
Drone.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module Drone where -- the simulation of one drone
import Env
import MoveCosts
data DronePosition = DronePos Env.Position Env.Altitude
deriving (Eq, Show)
data VerticalDirection = Ascend | Descend
deriving (Eq, Show)
data Action =
MoveCardinal Env.CardinalDir
| MoveIntercardinal Env.IntercardinalDir
| MoveVertical VerticalDirection
| Hover
deriving (Eq, Show)
class Timed t where
duration :: t -> Integer
instance Timed Action where
duration Hover = 1
duration (MoveCardinal _) = 10
duration (MoveIntercardinal _ ) = 14
duration (MoveVertical _ ) = 10
viewableFrom :: DronePosition -> [Position]
viewableFrom (DronePos pos Low) = [pos]
viewableFrom (DronePos pos High) = pos : (Env.neighborsOf pos)
type StepsRemaining = Integer
data DroneStatus =
Unassigned
| Assigned Action
| Acting Action StepsRemaining
deriving (Eq, Show)