,(0.90,-0.05)\r
] \r
\r
-:: Role = Attack | Mid | Defense | Keeper\r
\r
-isAttack :: Role -> Bool\r
-isAttack Attack = True\r
-isAttack _ = False\r
-\r
-isMid :: Role -> Bool\r
-isMid Mid = True\r
-isMid _ = False\r
-\r
-isDefense :: Role -> Bool\r
-isDefense Defense = True\r
-isDefense _ = False\r
-\r
-isKeep :: Role -> Bool\r
-isKeep Keeper = True\r
-isKeep _ = False\r
-\r
-fromNumber :: Int -> Role\r
-fromNumber 1 = Keeper\r
-fromNumber i\r
-| i < 4 = Attack\r
-| i < 10 = Mid\r
-| otherwise = Defense\r
-\r
-:: Mem = {home :: !Home, origpos :: Position, seed :: !RandomSeed, role :: Role}\r
+:: Mem = {home :: !Home, origpos :: Position, seed :: !RandomSeed}\r
\r
mirrorMem :: !Mem !FootballField -> Mem\r
mirrorMem mm field = {mm & home=other mm.home, origpos=mirror field mm.origpos}\r
, pos = position\r
, nose = zero\r
, speed = zero\r
- , skills = (Running, Kicking, Rotating)\r
+ , skills = (Running, Kicking, Tackling)\r
, effect = Nothing\r
, stamina = max_stamina\r
, health = max_health\r
, brain = {memory=if (home == West) mm (mirrorMem mm field), ai = mind field}\r
}\r
where\r
- mm = {home=West, origpos=position, seed=nullRandomSeed, role=fromNumber nr}\r
+ mm = {home=West, origpos=position, seed=nullRandomSeed}\r
\r
nextRandomNumber :: !Mem -> (Int, !Mem)\r
nextRandomNumber mm=:{seed} = let (i, newseed) = random seed in (i rem 100, {mm & seed=newseed})\r
\r
mind :: !FootballField !(!BrainInput, !Mem) -> (!BrainOutput, !Mem)\r
-mind field (x=:{referee,football,others,me}, mm=:{home,origpos,role})\r
+mind field (x=:{referee,football,others,me}, mm=:{home,origpos})\r
# (i, mm) = nextRandomNumber mm\r
// In case of the end of the half, mirror memory\r
| any (isEndHalf) referee = mind field ({x & referee=filter (\x.not (isEndHalf x)) referee}, mirrorMem mm field)\r
// In case of a pause or end, just halt\r
| any (isPauseGame) referee || any (isGameOver) referee = halt (x, mm)\r
-| isKeep role\r
- | i_have_the_ball = kick kicktarget_keeper (x, mm)\r
- | (dist me.pos ballPos) < (maxCatchReach me) = (CatchBall, mm)\r
- | closerToHome home zero ballPos.pxy.px = halt (x, mm)\r
+// Keeper\r
+| me.playerID.playerNr == 1\r
+ | i_have_ball = kickTarget (x, mm)\r
+ | ball_in_reach maxCatchReach = (CatchBall, mm)\r
+ | ball_their_half = halt (x, mm)\r
| ball_within_16\r
+ | we_have_ball = stayInGoal (x, mm)\r
| ballIsFree football\r
| isClosest others me ballPos.pxy = halt (x, mm)\r
| otherwise = stayInGoal (x, mm)\r
- | we_have_ball = stayInGoal (x, mm)\r
| otherwise \r
| length (filter player_within_16 them) == 1\r
- | (dist me.pos ballPos.pxy) < (maxCatchReach me)= (CatchBall, mm)\r
+ | (dist me.pos ballPos.pxy) < (maxCatchReach me) = (CatchBall, mm)\r
| otherwise = fix ballPos.pxy (maxCatchReach me) (x, mm)\r
| otherwise = stayInGoal (x, mm)\r
| otherwise\r
| we_have_ball = halt (x, mm)\r
| otherwise = stayInGoal (x, mm)\r
-// If I'm a field player\r
-| otherwise = halt (x, mm)\r
-/* // TODO:: The ball is free\r
- | ballIsFree football\r
- // I'm closest to the ball\r
- | isClosest us me ballPos.pxy = afterfix (\(_,_).(GainBall, mm)) ballPos.pxy prec (x, mm)\r
- // TODO: Some other player is the closest to the ball\r
+// Defense\r
+| me.playerID.playerNr > 7\r
+ | ball_their_half = fix {origpos & px=origpos.px + (scale 0.5 ballPos.pxy.px)} prec (x, mm)\r
+ | otherwise\r
+ // TODO I have the ball\r
+ | i_have_ball = halt (x, mm)\r
+ // TODO we have the ball\r
+ | we_have_ball = halt (x, mm)\r
+ // TODO they have the ball\r
| otherwise = halt (x, mm)\r
- // TODO: We have the ball\r
- | we_have_ball = halt (x, mm)\r
- // TODO: I have the ball\r
- | ballIsGainedBy me.playerID football = halt (x, mm)\r
- // TODO: Someone else has the ball\r
+// Attacker\r
+| otherwise\r
+ | i_have_ball = kickTarget (x, mm)\r
+ | ballIsFree football\r
+ | ball_in_reach maxGainReach = (GainBall, mm)\r
+ | isClosest us me ballPos.pxy = fix ballPos.pxy prec (x, mm)\r
+ | otherwise = fix {px=ballPos.pxy.px + (m 10.0), py=origpos.py} prec (x, mm) \r
+ | we_have_ball = fix {px=ballPos.pxy.px + (m 10.0), py=origpos.py} prec (x, mm)\r
+ | otherwise\r
+ | ball_in_reach maxTackleReach\r
+ | i<15 = (Tackle (hd has_ball).playerID (ms 6.0), mm)\r
+ | otherwise = (GainBall, mm)\r
+ | isClosest us me ballPos.pxy = fix ballPos.pxy prec (x, mm)\r
+ // TODO get to a free player\r
| otherwise = halt (x, mm)\r
- // TODO: The ball is with the others\r
- | otherwise = halt (x, mm)*/\r
where\r
stayInGoal = fix (attract goal_area_depth our_goal ballPos.pxy) prec\r
- our_goal = (centerOfGoal home field)\r
- their_goal = (centerOfGoal (other home) field)\r
- kicktarget_keeper = their_goal //TODO\r
- i_have_the_ball = ballIsGainedBy me.playerID football\r
+ kickTarget = kick their_goal //TODO\r
+\r
player_within_16 p = inPenaltyArea field home p.pos\r
ball_within_16 = inPenaltyArea field home ballPos.pxy\r
- we_have_ball = any (\x.ballIsGainedBy x.playerID football) us\r
- they_have_ball = any (\x.ballIsGainedBy x.playerID football) them\r
+ \r
+ has_ball = filter (\x.ballIsGainedBy x.playerID football) others\r
+ we_have_ball = any (\x.sameClub me x) has_ball\r
+ they_have_ball = any (\x.not (sameClub me x)) has_ball\r
+ i_have_ball = ballIsGainedBy me.playerID football\r
+ \r
+ ball_their_half = closerToHome home zero ballPos.pxy.px\r
+ ball_in_reach distfunc = (dist me.pos ballPos) < (distfunc me)\r
+ \r
+ our_goal = (centerOfGoal home field)\r
+ their_goal = (centerOfGoal (other home) field)\r
ballPos = (getBall x).ballPos\r
them = me opponents others\r
us = me team others\r
- prec = scale 0.5 (maxKickReach me)\r
+ prec = maxGainReach me\r
\r
closest :: [Footballer] Position -> Footballer\r
closest xs p = minListBy (\x y.(dist x.pos p) < (dist y.pos p)) xs\r
closerToHome East = (>)\r
closerToHome West = (<)\r
\r
-closerToGoal :: !Home -> a a -> Bool | Ord a\r
-closerToGoal h = closerToHome (other h)\r
-\r
distToLine :: Position Position Position -> Metre\r
distToLine a b c = (abs (((b.px-a.px)*(a.py-c.py))-((a.px-c.px)*(b.py-a.py))))/d\r
where\r
(*) m1 m2 = (m (toReal m1)/(toReal m2))\r
(/) m1 m2 = (m (toReal m1)/(toReal m2))\r
d = sqrt(((b.px-a.px)*(b.px-a.px))+((b.py-a.py)*(b.py-a.py)))\r
-\r
-afterfix :: (FootballerAI Mem) !Position !Metre !(!BrainInput, !Mem) -> (BrainOutput, !Mem)\r
-afterfix after point diff (input=:{me,others}, mm)\r
-| d < diff = after (input, mm)\r
-// There is no enemy standing in the way\r
-| otherwise = (move, mm)\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\r
-\r
+ \r
base_TeamName_MartLubbers :: String\r
base_TeamName_MartLubbers = "Æsir"
\ No newline at end of file