From: Mart Lubbers Date: Thu, 18 Jun 2015 16:35:08 +0000 (+0200) Subject: added harmless teams and keeper v1.0 X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=85a64a052d9d9a29c0f182c8862a530a2163c2c3;p=fp1415-soccerfun.git added harmless teams and keeper v1.0 --- diff --git a/src/Game/Team.icl b/src/Game/Team.icl index f7817b9..21c0286 100644 --- a/src/Game/Team.icl +++ b/src/Game/Team.icl @@ -19,7 +19,6 @@ import Team_Harmless allAvailableTeams :: [Home FootballField -> Team] allAvailableTeams = [ Team_MartLubbers , Team_MiniEffies - , Harmless , Team_Student_Rounds , Team_Student_Slalom , Team_Student_Passing @@ -29,7 +28,7 @@ allAvailableTeams = [ Team_MartLubbers , Team_Opponent_Passing , Team_Opponent_DeepPass , Team_Opponent_Keeper - ] + ] ++ [MostlyHarmless (11, Level n) \\ n <- [0..10]] instance nameOf Team where nameOf players = case players of diff --git a/src/SoccerFun_options.txt b/src/SoccerFun_options.txt index 787224a..2342c9c 100644 --- a/src/SoccerFun_options.txt +++ b/src/SoccerFun_options.txt @@ -1 +1 @@ -{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=Slower,showReferee=True,playingTime=4:00 min,renderStyle=Fixed camera} \ No newline at end of file diff --git a/src/Team_MartLubbers.icl b/src/Team_MartLubbers.icl index 9fa5a09..42dfda7 100644 --- a/src/Team_MartLubbers.icl +++ b/src/Team_MartLubbers.icl @@ -99,25 +99,31 @@ nextRandomNumber mm=:{seed} = let (i, newseed) = random seed in (i rem 100, {mm mind :: !FootballField !(!BrainInput, !Mem) -> (!BrainOutput, !Mem) mind field (x=:{referee,football,others,me}, mm=:{home,origpos,role}) +# (i, mm) = nextRandomNumber mm // In case of the end of the half, mirror memory | any (isEndHalf) referee = mind field ({x & referee=filter (\x.not (isEndHalf x)) referee}, mirrorMem mm field) // In case of a pause or end, just halt | any (isPauseGame) referee || any (isGameOver) referee = halt (x, mm) -// If I'm a keeper | isKeep role - // Ball is in the other half of the field - | closerToGoal home ballPos zero = halt (x, mm) - // Ball gained by us - | we_have_ball - // Ball not in penalty area - | closerToGoal home ballPos {px=penalty_area_depth, py=zero} = halt (x, mm) - // Ball in penalty area + | i_have_the_ball = kick kicktarget_keeper (x, mm) + | (dist me.pos ballPos) < (maxCatchReach me) = (CatchBall, mm) + | closerToHome home zero ballPos.pxy.px = halt (x, mm) + | ball_within_16 + | ballIsFree football + | isClosest others me ballPos.pxy = halt (x, mm) + | otherwise = stayInGoal (x, mm) + | we_have_ball = stayInGoal (x, mm) | otherwise - // Ball gained by them - | otherwise = halt (x, mm) + | length (filter player_within_16 them) == 1 + | (dist me.pos ballPos.pxy) < (maxCatchReach me)= (CatchBall, mm) + | otherwise = fix ballPos.pxy (maxCatchReach me) (x, mm) + | otherwise = stayInGoal (x, mm) + | otherwise + | we_have_ball = halt (x, mm) + | otherwise = stayInGoal (x, mm) // If I'm a field player -| otherwise - // TODO:: The ball is free +| otherwise = halt (x, mm) +/* // TODO:: The ball is free | ballIsFree football // I'm closest to the ball | isClosest us me ballPos.pxy = afterfix (\(_,_).(GainBall, mm)) ballPos.pxy prec (x, mm) @@ -126,27 +132,38 @@ mind field (x=:{referee,football,others,me}, mm=:{home,origpos,role}) // TODO: We have the ball | we_have_ball = halt (x, mm) // TODO: I have the ball - | ballIsGainedBy me.playerID football + | ballIsGainedBy me.playerID football = halt (x, mm) // TODO: Someone else has the ball | otherwise = halt (x, mm) // TODO: The ball is with the others - | otherwise = halt (x, mm) + | otherwise = halt (x, mm)*/ where + stayInGoal = fix (attract goal_area_depth our_goal ballPos.pxy) prec + our_goal = (centerOfGoal home field) + their_goal = (centerOfGoal (other home) field) + kicktarget_keeper = their_goal //TODO + i_have_the_ball = ballIsGainedBy me.playerID football + player_within_16 p = inPenaltyArea field home p.pos + ball_within_16 = inPenaltyArea field home ballPos.pxy we_have_ball = any (\x.ballIsGainedBy x.playerID football) us + they_have_ball = any (\x.ballIsGainedBy x.playerID football) them ballPos = (getBall x).ballPos them = me opponents others us = me team others prec = scale 0.5 (maxKickReach me) - + closest :: [Footballer] Position -> Footballer closest xs p = minListBy (\x y.(dist x.pos p) < (dist y.pos p)) xs isClosest :: [Footballer] Footballer Position -> Bool isClosest xs x p = closest [x:xs] p == x -closerToGoal :: !Home -> Metre Metre -> Bool -closerToGoal East = (<) -closerToGoal West = (>) +closerToHome :: !Home -> a a -> Bool | Ord a +closerToHome East = (>) +closerToHome West = (<) + +closerToGoal :: !Home -> a a -> Bool | Ord a +closerToGoal h = closerToHome (other h) distToLine :: Position Position Position -> Metre distToLine a b c = (abs (((b.px-a.px)*(a.py-c.py))-((a.px-c.px)*(b.py-a.py))))/d @@ -157,14 +174,10 @@ distToLine a b c = (abs (((b.px-a.px)*(a.py-c.py))-((a.px-c.px)*(b.py-a.py))))/d afterfix :: (FootballerAI Mem) !Position !Metre !(!BrainInput, !Mem) -> (BrainOutput, !Mem) afterfix after point diff (input=:{me,others}, mm) -# (i, mm) = nextRandomNumber mm | d < diff = after (input, mm) -// There is a enemy standing in the way and I feel like it -| (dist closestOpp me.pos) < (maxTackleReach me) && i < 15 = (Tackle closestOpp.playerID (ms 6.0), mm) // There is no enemy standing in the way | otherwise = (move, mm) where - closestOpp = closest (me opponents others) me.pos d = dist me point a = bearing zero me point r = bearing me.nose me point