implementation module Team_Student_Slalom_Assignment /** Implement a solution to the slalom assignment. Your team consists of one field player, with player's number 2. Below you should only change the definition of footballer to your solution. Do not change the position and player identification. Do not change the implementation of base_TeamName_Student_Slalom. */ import Footballer import FootballerFunctions Team_Student_Slalom :: !Home FootballField -> Team Team_Student_Slalom home field = team where team = [{footballer {clubName=club,playerNr=2} & pos = if (home == West) position (mirror field position)}] club = base_TeamName_Student_Slalom +++ if (home == West) "_W" "_E" position = {zero & px = scale -0.5 field.flength + penalty_area_depth} footballer player_id = {defaultFootballer player_id & name = "Peter88", brain = {memory = Void, ai = mind field home}} base_TeamName_Student_Slalom :: String base_TeamName_Student_Slalom = "Student Slalom" mind :: !FootballField !Home !(!BrainInput, !Void) -> (!BrainOutput, !Void) mind field home (x=:{me,others}, mm) | dist (getBall x).ballPos me.pos < (maxKickReach me) = (kick {px=sig (scale 0.5 field.flength), py=m 0.0}) (x, mm) | otherwise = (fix {px=pp2 cp.px (m 2.5), py=up cp.py (m 3.5)} (maxKickReach me)) (x, mm) where (comparator, pp1, pp2, sig) = if (home == West) ((<), (-), (+), (\w.w)) ((>), (+), (-), (~)) sf2 = sortBy (\x y.comparator x.pos.px y.pos.px) others sf = sf2 % (0, (length sf2) - 2) (cp, up) = closestPos (zip2 [1..] sf) (pp1 me.pos.px xWidthFootballer) (getBall x).ballPos.pxy comparator closestPos :: [(Int, Footballer)] Metre Position (Metre Metre -> Bool) -> (Position, (Metre Metre -> Metre)) closestPos [] _ d _ = (d, (\x y.x)) closestPos [(i, x):xs] p d c | c p x.pos.px = (x.pos, if (i rem 2 == 0) (+) (-)) | otherwise = closestPos xs p d c