-{closeReferee=True,showSplash=False,displaySpeed=Normal,showReferee=True,playingTime=4:00 min,renderStyle=Fixed camera}
\ No newline at end of file
+{closeReferee=True,showSplash=False,displaySpeed=Faster,showReferee=True,playingTime=4:00 min,renderStyle=Fixed camera}
\ No newline at end of file
where\r
theBall = getFootball ballState (team1 ++ team2)\r
(compTeam,(studentTeam,studentHome)) = if (stringStarts (nameOf team1) base_TeamName_Opponent_Passing) (team1,(team2,East)) (team2,(team1,West))\r
- ballKickoff = {zero & px = if (studentHome == West) (scale -0.5 field.flength + penalty_area_depth) (scale 0.5 field.flength - penalty_area_depth)}\r
+ ballKickoff = {zero & px = if (studentHome == West) (scale -0.5 field.flength + scale 2.0 penalty_area_depth) (scale 0.5 field.flength - scale 2.0 penalty_area_depth)}\r
+// ballKickoff = {zero & px = if (studentHome == West) (scale -0.5 field.flength + penalty_area_depth) (scale 0.5 field.flength - penalty_area_depth)}\r
getMessagesForTooFarPlayers = map (\fb -> TellMessage ("Your player with number " <+++ fb.playerID.playerNr <+++ " moved further than 10 meters"))\r
(north_pole,south_pole) = goal_poles field\r
\r
*/\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
+\r
implementation module Team_Student_Slalom_Assignment\r
\r
/** Implement a solution to the slalom assignment.\r
base_TeamName_Student_Slalom = "Student Slalom"\r
\r
mind :: !FootballField !Home !(!BrainInput, !Void) -> (!BrainOutput, !Void)\r
-mind field home (x=:{me,others}, mm) = (fix {px=pp2 cp.px (m 2.5), py=up cp.py (m 3.5)} (m 1.0)) (x, mm)\r
+mind field home (x=:{me,others}, mm)\r
+| dist (getBall x).ballPos me.pos < (maxKickReach me) = (kick {px=sig (scale 0.5 field.flength), py=m 0.0}) (x, mm)\r
+| otherwise = (fix {px=pp2 cp.px (m 2.5), py=up cp.py (m 3.5)} (maxKickReach me)) (x, mm)\r
where\r
- (comparator, pp1, pp2, targetsig) = if (home == West) ((<), (-), (+), (\w.w)) ((>), (+), (-), (~))\r
- sf = sortBy (\x y.comparator x.pos.px y.pos.px) others\r
- (cp, up) = closestPos (zip2 [1..] sf) (pp1 me.pos.px xWidthFootballer) {px=targetsig (scale 0.5 field.flength), py=(m 0.0)} comparator\r
+ (comparator, pp1, pp2, sig) = if (home == West) ((<), (-), (+), (\w.w)) ((>), (+), (-), (~))\r
+ sf2 = sortBy (\x y.comparator x.pos.px y.pos.px) others\r
+ sf = sf2 % (0, (length sf2) - 2)\r
+ (cp, up) = closestPos (zip2 [1..] sf) (pp1 me.pos.px xWidthFootballer) (getBall x).ballPos.pxy comparator\r
\r
closestPos :: [(Int, Footballer)] Metre Position (Metre Metre -> Bool) -> (Position, (Metre Metre -> Metre))\r
-closestPos [] _ d _ = (d, (+))\r
+closestPos [] _ d _ = (d, (\x y.x))\r
closestPos [(i, x):xs] p d c\r
| c p x.pos.px = (x.pos, if (i rem 2 == 0) (+) (-))\r
| otherwise = closestPos xs p d c\r
+\r
+\r
+\r