From 7c9859686e954e497b998b2bbc3149c99907f019 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Thu, 18 Jun 2015 21:40:57 +0200 Subject: [PATCH] started with the attackers --- src/SoccerFun_options.txt | 2 +- src/Team_MartLubbers.icl | 120 ++++++++++++++++---------------------- 2 files changed, 50 insertions(+), 72 deletions(-) diff --git a/src/SoccerFun_options.txt b/src/SoccerFun_options.txt index 2342c9c..787224a 100644 --- a/src/SoccerFun_options.txt +++ b/src/SoccerFun_options.txt @@ -1 +1 @@ -{closeReferee=True,showSplash=False,displaySpeed=Slower,showReferee=True,playingTime=4:00 min,renderStyle=Fixed camera} \ No newline at end of file +{closeReferee=True,showSplash=False,displaySpeed=Normal,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 42dfda7..83aa336 100644 --- a/src/Team_MartLubbers.icl +++ b/src/Team_MartLubbers.icl @@ -47,32 +47,8 @@ where ,(0.90,-0.05) ] -:: Role = Attack | Mid | Defense | Keeper -isAttack :: Role -> Bool -isAttack Attack = True -isAttack _ = False - -isMid :: Role -> Bool -isMid Mid = True -isMid _ = False - -isDefense :: Role -> Bool -isDefense Defense = True -isDefense _ = False - -isKeep :: Role -> Bool -isKeep Keeper = True -isKeep _ = False - -fromNumber :: Int -> Role -fromNumber 1 = Keeper -fromNumber i -| i < 4 = Attack -| i < 10 = Mid -| otherwise = Defense - -:: Mem = {home :: !Home, origpos :: Position, seed :: !RandomSeed, role :: Role} +:: Mem = {home :: !Home, origpos :: Position, seed :: !RandomSeed} mirrorMem :: !Mem !FootballField -> Mem mirrorMem mm field = {mm & home=other mm.home, origpos=mirror field mm.origpos} @@ -85,72 +61,89 @@ Aesir club home field position nr name , pos = position , nose = zero , speed = zero - , skills = (Running, Kicking, Rotating) + , skills = (Running, Kicking, Tackling) , effect = Nothing , stamina = max_stamina , health = max_health , brain = {memory=if (home == West) mm (mirrorMem mm field), ai = mind field} } where - mm = {home=West, origpos=position, seed=nullRandomSeed, role=fromNumber nr} + mm = {home=West, origpos=position, seed=nullRandomSeed} nextRandomNumber :: !Mem -> (Int, !Mem) nextRandomNumber mm=:{seed} = let (i, newseed) = random seed in (i rem 100, {mm & seed=newseed}) mind :: !FootballField !(!BrainInput, !Mem) -> (!BrainOutput, !Mem) -mind field (x=:{referee,football,others,me}, mm=:{home,origpos,role}) +mind field (x=:{referee,football,others,me}, mm=:{home,origpos}) # (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) -| isKeep role - | 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) +// Keeper +| me.playerID.playerNr == 1 + | i_have_ball = kickTarget (x, mm) + | ball_in_reach maxCatchReach = (CatchBall, mm) + | ball_their_half = halt (x, mm) | ball_within_16 + | we_have_ball = stayInGoal (x, mm) | ballIsFree football | isClosest others me ballPos.pxy = halt (x, mm) | otherwise = stayInGoal (x, mm) - | we_have_ball = stayInGoal (x, mm) | otherwise | length (filter player_within_16 them) == 1 - | (dist me.pos ballPos.pxy) < (maxCatchReach me)= (CatchBall, mm) + | (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 = 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) - // TODO: Some other player is the closest to the ball +// Defense +| me.playerID.playerNr > 7 + | ball_their_half = fix {origpos & px=origpos.px + (scale 0.5 ballPos.pxy.px)} prec (x, mm) + | otherwise + // TODO I have the ball + | i_have_ball = halt (x, mm) + // TODO we have the ball + | we_have_ball = halt (x, mm) + // TODO they have the ball | otherwise = halt (x, mm) - // TODO: We have the ball - | we_have_ball = halt (x, mm) - // TODO: I have the ball - | ballIsGainedBy me.playerID football = halt (x, mm) - // TODO: Someone else has the ball +// Attacker +| otherwise + | i_have_ball = kickTarget (x, mm) + | ballIsFree football + | ball_in_reach maxGainReach = (GainBall, mm) + | isClosest us me ballPos.pxy = fix ballPos.pxy prec (x, mm) + | otherwise = fix {px=ballPos.pxy.px + (m 10.0), py=origpos.py} prec (x, mm) + | we_have_ball = fix {px=ballPos.pxy.px + (m 10.0), py=origpos.py} prec (x, mm) + | otherwise + | ball_in_reach maxTackleReach + | i<15 = (Tackle (hd has_ball).playerID (ms 6.0), mm) + | otherwise = (GainBall, mm) + | isClosest us me ballPos.pxy = fix ballPos.pxy prec (x, mm) + // TODO get to a free player | otherwise = halt (x, mm) - // TODO: The ball is with the others - | 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 + kickTarget = kick their_goal //TODO + 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 + + has_ball = filter (\x.ballIsGainedBy x.playerID football) others + we_have_ball = any (\x.sameClub me x) has_ball + they_have_ball = any (\x.not (sameClub me x)) has_ball + i_have_ball = ballIsGainedBy me.playerID football + + ball_their_half = closerToHome home zero ballPos.pxy.px + ball_in_reach distfunc = (dist me.pos ballPos) < (distfunc me) + + our_goal = (centerOfGoal home field) + their_goal = (centerOfGoal (other home) field) ballPos = (getBall x).ballPos them = me opponents others us = me team others - prec = scale 0.5 (maxKickReach me) + prec = maxGainReach me closest :: [Footballer] Position -> Footballer closest xs p = minListBy (\x y.(dist x.pos p) < (dist y.pos p)) xs @@ -162,27 +155,12 @@ 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 where (*) m1 m2 = (m (toReal m1)/(toReal m2)) (/) m1 m2 = (m (toReal m1)/(toReal m2)) d = sqrt(((b.px-a.px)*(b.px-a.px))+((b.py-a.py)*(b.py-a.py))) - -afterfix :: (FootballerAI Mem) !Position !Metre !(!BrainInput, !Mem) -> (BrainOutput, !Mem) -afterfix after point diff (input=:{me,others}, mm) -| d < diff = after (input, mm) -// There is no enemy standing in the way -| otherwise = (move, mm) - where - d = dist me point - a = bearing zero me point - r = bearing me.nose me point - v = ms (max 6.0 (toReal d)) - move = Move {direction=a, velocity=v} r - + base_TeamName_MartLubbers :: String base_TeamName_MartLubbers = "Æsir" \ No newline at end of file -- 2.20.1