From 27de4a1e16c36ce943c53362117f899f4f36fa84 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Wed, 17 Jun 2015 19:29:20 +0200 Subject: [PATCH] update before reboot --- src/Game/Team.icl | 4 ++-- src/Team_MartLubbers.icl | 28 +++++++++++++++++++--------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/Game/Team.icl b/src/Game/Team.icl index bec99c0..d41af0b 100644 --- a/src/Game/Team.icl +++ b/src/Game/Team.icl @@ -16,7 +16,8 @@ import Team_Student_Keeper_Assignment import Team_MartLubbers allAvailableTeams :: [Home FootballField -> Team] -allAvailableTeams = [ Team_MiniEffies +allAvailableTeams = [ Team_MartLubbers + , Team_MiniEffies , Team_Student_Rounds , Team_Student_Slalom , Team_Student_Passing @@ -26,7 +27,6 @@ allAvailableTeams = [ Team_MiniEffies , Team_Opponent_Passing , Team_Opponent_DeepPass , Team_Opponent_Keeper - , Team_MartLubbers ] instance nameOf Team where nameOf players diff --git a/src/Team_MartLubbers.icl b/src/Team_MartLubbers.icl index 58be5ed..ee0de18 100644 --- a/src/Team_MartLubbers.icl +++ b/src/Team_MartLubbers.icl @@ -68,26 +68,36 @@ closerToGoal :: !Home -> Metre Metre -> Bool closerToGoal East = (<) closerToGoal West = (>) +getMin :: !Home -> Metre Metre -> Metre +getMin h = getMax (other h) + +getMax :: !Home -> Metre Metre -> Metre +getMax East = (max) +getMax West = (min) + mind :: !FootballField !(!BrainInput, !Mem) -> (!BrainOutput, !Mem) mind field (x=:{referee,football,others,me}, mm=:{home,origpos}) +# mm=:{home,origpos} = if (any isEndHalf referee) {home=other home, origpos=mirror field origpos} mm | ballIsGainedBy me.playerID football - | me.stamina > 0.5 = fix nextPos (m 1.0) (x, mm) - | otherwise = kick nextPos (x, mm) + | dist nextPos me.pos < (m 10.0) = kick nextPos (x, mm) + | otherwise = fix nextPos (m 1.0) (x, mm) | isClosest others me ballPos.pxy = afterfix (\(_, m).(GainBall, m)) ballPos.pxy (scale 0.5 (maxKickReach me)) (x, mm) | otherwise - | we_have_ball = fix {px=min ballPos.pxy.px (field.flength-me.pos.px), py=me.pos.py} (m 1.0) (x, mm) - | otherwise = fix origpos (m 1.0) (x, mm) + | we_have_ball = fix {px=getMin home ballPos.pxy.px (field.flength-me.pos.px), py=me.pos.py} (m 1.0) (x, mm) + | otherwise + | me.stamina > 0.5 = fix origpos (m 1.0) (x, mm) + | otherwise = halt (x, mm) where us = me team others ballPos = (getBall x).ballPos - nextPos = let np = nextPlayer home us me.pos in if (isNothing np) (centerOfGoal (other home) field) (fromJust np) + nextPos = nextPlayer home field us me.pos we_have_ball = or (map (\x.ballIsGainedBy x.playerID football) us) -nextPlayer :: !Home [Footballer] Position -> Maybe Position -nextPlayer home xs pos +nextPlayer :: !Home !FootballField [Footballer] Position -> Position +nextPlayer home field 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 +| xs == [] = centerOfGoal (other home) field +| otherwise = (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 -- 2.20.1