*/\r
\r
import Footballer\r
+import FootballerFunctions\r
+import StdMaybe\r
\r
Team_Student_Passing :: !Home FootballField -> Team\r
Team_Student_Passing home field = if (home == West) team (mirror field team)\r
where\r
- team = [ {footballer {clubName=club,playerNr=nr} & pos = toPosition (scale (0.5*x) field.flength,scale (0.5*y) field.fwidth),nose = rad (dir*pi)}\r
+ team = [ {footballer {clubName=club,playerNr=nr} nr & pos = toPosition (scale (0.5*x) field.flength,scale (0.5*y) field.fwidth),nose = rad (dir*pi)}\r
\\ (x,y) <- positions\r
& nr <- [2..]\r
& dir <- noses\r
,( 0.43,-0.05)\r
]\r
noses = [1.8,0.0,1.5,0.5,1.2,0.2]\r
- footballer playerID = defaultFootballer playerID // implement your footballer here\r
-\r
+ footballer playerID nr = {defaultFootballer playerID & name = "Peter88_" +++ toString nr, brain = {memory=False, ai=mind (getOps field home)}}\r
+ \r
base_TeamName_Student_Passing :: String\r
base_TeamName_Student_Passing = "Student Passing"\r
+\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