From: Mart Lubbers Date: Tue, 9 Jun 2015 10:45:56 +0000 (+0200) Subject: update team X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=dd9ada451a6d3a64293eaa8c6fae58d85d720a0d;p=fp1415-soccerfun.git update team --- diff --git a/src/Team_MartLubbers.icl b/src/Team_MartLubbers.icl index 37db883..b1fbd41 100644 --- a/src/Team_MartLubbers.icl +++ b/src/Team_MartLubbers.icl @@ -5,9 +5,12 @@ import FootballerFunctions Names:: [String] Names = [ + "Odin", + "Frigg", + "Thor", "Balder", "Njord", -// "Freyr", + "Freyr", "Freyja", "Tyr", "Bragi", @@ -44,7 +47,7 @@ where ,(0.90,-0.05) ] -:: Mem :== Void +:: Mem = {home :: !Home, origpos :: Position} Aesir :: !ClubName !Home !FootballField !Position !PlayersNumber !String -> Footballer Aesir club home field position nr name @@ -58,12 +61,34 @@ Aesir club home field position nr name , effect = Nothing , stamina = max_stamina , health = max_health - , brain = {memory = zero, ai = mind field } - } + , brain = {memory = {home=home, origpos=position}, ai = mind field } + } + +closerToGoal :: !Home -> Metre Metre -> Bool +closerToGoal East = (<) +closerToGoal West = (>) mind :: !FootballField !(!BrainInput, !Mem) -> (!BrainOutput, !Mem) -mind field (input, mm) +mind field (x=:{referee,football,others,me}, mm=:{home}) +# others = (me team others) +| isClosest others me (getBall x).ballPos.pxy = (afterfix (kick nextPos) (getBall x).ballPos.pxy (maxKickReach me)) (x, mm) +| otherwise = halt (x, mm) + where + nextPos = let np = nextPlayer home others me.pos in if (isNothing np) (centerOfGoal (other home) field) (fromJust np) + +nextPlayer :: !Home [Footballer] Position -> Maybe Position +nextPlayer home xs pos +# xs = filter (\x.closerToGoal home x.pos.px pos.px) xs +| xs == [] = Nothing +| otherwise = Just (minListBy (\x y.(dist x.pos pos) < (dist y.pos pos)) xs).pos + +closest :: [Footballer] Position -> Footballer +closest xs p = minListBy (\x y.(dist x.pos p) < (dist y.pos p)) xs + +isClosest :: [Footballer] Footballer Position -> Bool +isClosest xs x p = closest [x:xs] p == x +afterfix :: (FootballerAI m) !Position !Metre !(!BrainInput, m) -> (BrainOutput, m) afterfix after point diff (input=:{me}, m) | d < diff = after (input, m) | otherwise = (move, m) @@ -72,6 +97,7 @@ afterfix after point diff (input=:{me}, m) a = bearing zero me point r = bearing me.nose me point v = ms (max 6.0 (toReal d)) + move = Move {direction=a, velocity=v} r base_TeamName_MartLubbers :: String base_TeamName_MartLubbers = "Æsir" \ No newline at end of file