From: Mart Lubbers Date: Wed, 17 Jun 2015 13:55:21 +0000 (+0200) Subject: they walk with me X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=2d35e081d8964032974423e16882f4ee985feb2f;p=fp1415-soccerfun.git they walk with me --- diff --git a/src/StdTeam/Team_Student_Rounds_Assignment.icl b/src/StdTeam/Team_Student_Rounds_Assignment.icl old mode 100755 new mode 100644 diff --git a/src/Team_MartLubbers.icl b/src/Team_MartLubbers.icl index b1fbd41..58be5ed 100644 --- a/src/Team_MartLubbers.icl +++ b/src/Team_MartLubbers.icl @@ -69,12 +69,19 @@ closerToGoal East = (<) closerToGoal West = (>) mind :: !FootballField !(!BrainInput, !Mem) -> (!BrainOutput, !Mem) -mind field (x=:{referee,football,others,me}, mm=:{home}) -# others = (me team others) -| isClosest others me (getBall x).ballPos.pxy = (afterfix (kick nextPos) (getBall x).ballPos.pxy (maxKickReach me)) (x, mm) -| otherwise = halt (x, mm) +mind field (x=:{referee,football,others,me}, mm=:{home,origpos}) +| ballIsGainedBy me.playerID football + | me.stamina > 0.5 = fix nextPos (m 1.0) (x, mm) + | otherwise = kick nextPos (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) where - nextPos = let np = nextPlayer home others me.pos in if (isNothing np) (centerOfGoal (other home) field) (fromJust np) + 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) + we_have_ball = or (map (\x.ballIsGainedBy x.playerID football) us) nextPlayer :: !Home [Footballer] Position -> Maybe Position nextPlayer home xs pos