\r
Names:: [String]\r
Names = [\r
+ "Odin",\r
+ "Frigg",\r
+ "Thor",\r
"Balder",\r
"Njord",\r
-// "Freyr",\r
+ "Freyr",\r
"Freyja",\r
"Tyr",\r
"Bragi",\r
,(0.90,-0.05)\r
] \r
\r
-:: Mem :== Void\r
+:: Mem = {home :: !Home, origpos :: Position}\r
\r
Aesir :: !ClubName !Home !FootballField !Position !PlayersNumber !String -> Footballer\r
Aesir club home field position nr name\r
, effect = Nothing\r
, stamina = max_stamina\r
, health = max_health\r
- , brain = {memory = zero, ai = mind field }\r
- } \r
+ , brain = {memory = {home=home, origpos=position}, ai = mind field }\r
+ }\r
+ \r
+closerToGoal :: !Home -> Metre Metre -> Bool\r
+closerToGoal East = (<)\r
+closerToGoal West = (>)\r
\r
mind :: !FootballField !(!BrainInput, !Mem) -> (!BrainOutput, !Mem)\r
-mind field (input, mm) \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
+ where\r
+ nextPos = let np = nextPlayer home others me.pos in if (isNothing np) (centerOfGoal (other home) field) (fromJust np)\r
+\r
+nextPlayer :: !Home [Footballer] Position -> Maybe Position\r
+nextPlayer home xs pos\r
+# xs = filter (\x.closerToGoal home x.pos.px pos.px) xs\r
+| xs == [] = Nothing\r
+| otherwise = Just (minListBy (\x y.(dist x.pos pos) < (dist y.pos pos)) xs).pos\r
+\r
+closest :: [Footballer] Position -> Footballer\r
+closest xs p = minListBy (\x y.(dist x.pos p) < (dist y.pos p)) xs\r
+\r
+isClosest :: [Footballer] Footballer Position -> Bool\r
+isClosest xs x p = closest [x:xs] p == x\r
\r
+afterfix :: (FootballerAI m) !Position !Metre !(!BrainInput, m) -> (BrainOutput, m)\r
afterfix after point diff (input=:{me}, m)\r
| d < diff = after (input, m)\r
| otherwise = (move, m)\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\r
\r
base_TeamName_MartLubbers :: String\r
base_TeamName_MartLubbers = "Æsir"
\ No newline at end of file