-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAI2.hs
More file actions
32 lines (27 loc) · 1.01 KB
/
Copy pathAI2.hs
File metadata and controls
32 lines (27 loc) · 1.01 KB
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
module AI2 where
import Robot
import Entities
import Geometry
import Data.Map
import Data.Maybe
import Data.List
import Prelude
import GameState
import Debug.Trace
-- Reescritura del modulo AI debido a la complejidad a la hora de arreglar errores (por ahora se sigue usando AI.hs)
-- ============================================================================
-- DSL PARA ACCIONES DEL BOT
-- ============================================================================
move :: Robot -> Scalar -> Robot
move robot v = robot {robotVelocity = updatedVelocity}
where
(normal,angulo) = comp2Polar (robotVelocity robot)
updNormal = normal + v
updatedVelocity = polar2Comp updNormal angulo
rotate :: Robot -> Angle -> Robot
rotate robot angle = robot {robotVelocity = updatedVelocity, robotOrientation = updatedAngle}
where
anguloIn = robotOrientation robot
updatedAngle = anguloIn + angle
velocidadIn = robotVelocity robot
updatedVelocity = rotateVector velocidadIn angle