-\r
-\r
-:: Ops = {\r
- c :: Metre Metre -> Bool, \r
- a :: Metre Metre -> Metre, \r
- s :: Metre Metre -> Metre,\r
- g :: Position}\r
-\r
-getOps :: !FootballField !Home -> Ops\r
-getOps field West = {c=(<), a=(+), s=(-), g={px=scale 0.5 field.flength, py=(m 0.0)}}\r
-getOps field East = {c=(>), a=(-), s=(+), g={px= ~(scale 0.5 field.flength), py=(m 0.0)}}\r
-\r
-mind :: !Ops !(!BrainInput, !Bool) -> (!BrainOutput, !Bool)\r
-mind op (x=:{me,others}, mm)\r
-| mm || not (best (me team others) me bp) = halt (x, mm)\r
-| otherwise = (afterfix (((\f.(\(i, _).(f i, True))) o kick`) kickpos) bp (maxKickReach me)) (x, mm)\r
- where\r
- bp = (getBall x).ballPos.pxy\r
- \r
- kickpos = let f = nextPlayer others me in if (isNothing f) op.g (fromJust f).pos\r
- \r
- nextPlayer :: [Footballer] Footballer -> Maybe Footballer\r
- nextPlayer [] me = Nothing\r
- nextPlayer [x:xs] me\r
- | op.c x.pos.px me.pos.px = nextPlayer xs me\r
- | otherwise = Just x\r
- \r
- best :: [Footballer] Footballer Position -> Bool\r
- best [] _ _ = True\r
- best [x:xs] me bp\r
- | dist x.pos bp < dist me.pos bp = False\r
- | otherwise = best xs me bp\r
- \r
- afterfix after point diff (input=:{me}, m)\r
- | d < diff = after (input, m)\r
- | otherwise = (move, m)\r
- where\r
- d = dist me point\r
- a = bearing zero me point\r
- r = bearing me.nose me point\r
- v = ms (max 6.0 (toReal d))\r
- move = Move {direction=a, velocity=v} r
\ No newline at end of file