closerToGoal West = (>)\r
\r
mind :: !FootballField !(!BrainInput, !Mem) -> (!BrainOutput, !Mem)\r
-mind field (x=:{referee,football,others,me}, mm=:{home})\r
-# others = (me team others)\r
-| isClosest others me (getBall x).ballPos.pxy = (afterfix (kick nextPos) (getBall x).ballPos.pxy (maxKickReach me)) (x, mm)\r
-| otherwise = halt (x, mm)\r
+mind field (x=:{referee,football,others,me}, mm=:{home,origpos})\r
+| ballIsGainedBy me.playerID football\r
+ | me.stamina > 0.5 = fix nextPos (m 1.0) (x, mm)\r
+ | otherwise = kick nextPos (x, mm)\r
+| isClosest others me ballPos.pxy = afterfix (\(_, m).(GainBall, m)) ballPos.pxy (scale 0.5 (maxKickReach me)) (x, mm)\r
+| otherwise\r
+ | we_have_ball = fix {px=min ballPos.pxy.px (field.flength-me.pos.px), py=me.pos.py} (m 1.0) (x, mm)\r
+ | otherwise = fix origpos (m 1.0) (x, mm)\r
where\r
- nextPos = let np = nextPlayer home others me.pos in if (isNothing np) (centerOfGoal (other home) field) (fromJust np)\r
+ us = me team others\r
+ ballPos = (getBall x).ballPos\r
+ nextPos = let np = nextPlayer home us me.pos in if (isNothing np) (centerOfGoal (other home) field) (fromJust np)\r
+ we_have_ball = or (map (\x.ballIsGainedBy x.playerID football) us)\r
\r
nextPlayer :: !Home [Footballer] Position -> Maybe Position\r
nextPlayer home xs pos\r