-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTypes.hs
85 lines (71 loc) · 1.71 KB
/
Types.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
module Types where
-- Messages are what we get from the server
data Message = Init Initialization
| Telem Telemetry
| Bounce
| CraterKill
| MartianKill
| Success
| End
deriving (Show, Eq)
-- ADT For Initialization data
data Initialization = I {
dx :: Double,
dy :: Double,
timeLimit :: Int,
minSensor :: Double,
maxSensor :: Double,
maxSpeed :: Double,
maxTurn :: Double,
maxHardTurn :: Double
}
deriving (Show, Eq)
-- ADT For Telemetry data
data Telemetry = T {
timeStamp :: Int,
vehicleState :: VehicleState,
objects :: [Object],
martians :: [Martian]
}
deriving (Show, Eq)
data VehicleState = VS {
vehicleCtl :: VehicleControl,
vehicleX :: Double,
vehicleY :: Double,
vehicleDir :: Double,
vehicleSpeed :: Double
}
deriving (Show, Eq)
data VehicleControl = VC {
vcAcc :: Acceleration,
vcDir :: Direction
}
deriving (Show, Eq)
data Acceleration = Accelerate | Brake | Roll
deriving (Show, Eq)
data Direction = HardLeft | Left | Straight | Right | HardRight
deriving (Show, Eq)
-- Stationary things in the terain
data Object =
Object {
objectKind :: ObjectKind,
objectX :: Double,
objectY :: Double,
objectR :: Double
}
deriving (Show, Eq, Ord)
data ObjectKind = Boulder | Crater | Home
deriving (Show, Eq, Ord)
data Martian = Martian {
martianX :: Double,
martianY :: Double,
martianDir :: Double,
martianSpeed :: Double
}
deriving (Show, Eq, Ord)
type Point = (Double, Double)
defaultVS = VS defaultVC 0 0 0 0
-- Default values
emptyInit = I 0 0 0 0 0 0 0 0
emptyTelem = T 0 defaultVS [] []
defaultVC = VC Roll Straight