From b626e42416b8fbfdcc5c9422cf28d16973f2ddff Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Mon, 8 Jun 2015 16:14:06 +0200 Subject: [PATCH] initial team --- src/Game/Team.icl | 2 ++ src/MartLubbers.icl | 69 +++++++++++++++++++++++++++++++++++ src/SoccerFun.prj | 16 +++++++++ src/Team_MartLubbers.dcl | 5 +++ src/Team_MartLubbers.icl | 77 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 169 insertions(+) create mode 100644 src/MartLubbers.icl create mode 100644 src/Team_MartLubbers.dcl create mode 100644 src/Team_MartLubbers.icl diff --git a/src/Game/Team.icl b/src/Game/Team.icl index 3b5dcb7..bec99c0 100644 --- a/src/Game/Team.icl +++ b/src/Game/Team.icl @@ -13,6 +13,7 @@ import Team_Student_Slalom_Assignment import Team_Student_Passing_Assignment import Team_Student_DeepPass_Assignment import Team_Student_Keeper_Assignment +import Team_MartLubbers allAvailableTeams :: [Home FootballField -> Team] allAvailableTeams = [ Team_MiniEffies @@ -25,6 +26,7 @@ allAvailableTeams = [ Team_MiniEffies , Team_Opponent_Passing , Team_Opponent_DeepPass , Team_Opponent_Keeper + , Team_MartLubbers ] instance nameOf Team where nameOf players diff --git a/src/MartLubbers.icl b/src/MartLubbers.icl new file mode 100644 index 0000000..65e62bf --- /dev/null +++ b/src/MartLubbers.icl @@ -0,0 +1,69 @@ +implementation module Team_MartLubbers + +import Footballer + +Team_MartLubbers :: !Home !FootballField -> Team +Team_MartLubbers home field = +| home==West = westTeam +| otherwise = eastTeam +where + eastTeam = mirror field westTeam + westTeam = [keeper : fielders] + clubname = base_TeamName_MiniEffie +++ if (home == West) "W" "E" + keeper = MiniEffie clubname home field {zero & px=scale -0.5 field.flength} 1 + fielders = [ MiniEffie clubname home field {px=scale (-0.5*dx) field.flength,py=scale (0.5*dy) field.fwidth} nr + \\ (dx,dy) <- west_positions_fielders + & nr <- [2..] + ] + west_positions_fielders = [(0.20, 0.40) + ,(0.20,-0.40) + ,(0.23, 0.00) + ,(0.50, 0.45) + ,(0.50,-0.45) + ,(0.60, 0.00) + ,(0.70, 0.35) + ,(0.70,-0.35) + ,(0.90, 0.05) + ,(0.90,-0.05) + ] + +:: MiniMemory = { home :: !Home } + +MiniEffie :: !ClubName !Home !FootballField !Position !PlayersNumber -> Footballer +MiniEffie club home field position nr + = { playerID = {clubName=club,playerNr=nr} + , name = "MiniF." <+++ nr + , length = min_length + , pos = position + , nose = zero + , speed = zero + , skills = (Running, Kicking, Rotating) + , effect = Nothing + , stamina = max_stamina + , health = max_health + , brain = { memory = {home=home}, ai = minibrain field } + } + +minibrain :: !FootballField !(!BrainInput,!MiniMemory) -> (!BrainOutput,!MiniMemory) +minibrain field (input=:{referee,me}, memory=:{home}) +| i_am_close_to_the_ball + | i_can_see goal = (kick_the_ball, new_memory) + | otherwise = (turn_to_face goal, new_memory) +| i_can_see ball = (run_to_the_ball, new_memory) +| otherwise = (turn_to_face ball, new_memory) +where + new_memory = {home=if (any isEndHalf referee) (other home) home} + my_direction = me.nose + ball = getBall input + goal = centerOfGoal (other home) field + + i_am_close_to_the_ball = dist me ball < maxKickReach me + i_can_see pos = abs (bearing my_direction me pos) < rad (0.05*pi) + + run_to_the_ball = Move {direction=bearing zero me ball,velocity=speed_of_light} zero + turn_to_face pos = Move zero (bearing my_direction me pos) + kick_the_ball = KickBall {vxy={direction=my_direction,velocity=speed_of_light}, vz=ms 1.0} + speed_of_light = ms 299792458.0 + +base_TeamName_MiniEffie :: String +base_TeamName_MiniEffie = "Æsir" \ No newline at end of file diff --git a/src/SoccerFun.prj b/src/SoccerFun.prj index c1e0db6..bfb80ed 100644 --- a/src/SoccerFun.prj +++ b/src/SoccerFun.prj @@ -46,6 +46,8 @@ Global Path: {Project}\StdLibExt Path: {Project}\StdReferee Path: {Project}\StdTeam + Path: {Project} + Path: {Project} Precompile: Postlink: MainModule @@ -63,6 +65,20 @@ MainModule ReuseUniqueNodes: True Fusion: False OtherModules + Module + Name: Team_MartLubbers + Dir: {Project} + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False Module Name: Football Dir: {Project}\Game diff --git a/src/Team_MartLubbers.dcl b/src/Team_MartLubbers.dcl new file mode 100644 index 0000000..1b84fe8 --- /dev/null +++ b/src/Team_MartLubbers.dcl @@ -0,0 +1,5 @@ +definition module Team_MartLubbers + +import Footballer + +Team_MartLubbers :: !Home !FootballField -> Team \ No newline at end of file diff --git a/src/Team_MartLubbers.icl b/src/Team_MartLubbers.icl new file mode 100644 index 0000000..37db883 --- /dev/null +++ b/src/Team_MartLubbers.icl @@ -0,0 +1,77 @@ +implementation module Team_MartLubbers + +import Footballer +import FootballerFunctions + +Names:: [String] +Names = [ + "Balder", + "Njord", +// "Freyr", + "Freyja", + "Tyr", + "Bragi", + "Heimdall", + "Hoder", + "Vidar", + "Vale", + "Ullr", + "Forseti"] + +Team_MartLubbers :: !Home !FootballField -> Team +Team_MartLubbers home field +| home==West = westTeam +| otherwise = eastTeam +where + eastTeam = mirror field westTeam + westTeam = [keeper : fielders] + clubname = base_TeamName_MartLubbers +++ if (home == West) "_W" "_E" + keeper = Aesir clubname home field {zero & px=scale -0.5 field.flength} 1 "Thor" + fielders = [Aesir clubname home field {px=scale (-0.5*dx) field.flength,py=scale (0.5*dy) field.fwidth} nr name + \\ (dx,dy) <- west_positions_fielders + & nr <- [2..] + & name <- Names + ] + west_positions_fielders = [(0.20, 0.40) + ,(0.20,-0.40) + ,(0.23, 0.00) + ,(0.50, 0.45) + ,(0.50,-0.45) + ,(0.60, 0.00) + ,(0.70, 0.35) + ,(0.70,-0.35) + ,(0.90, 0.05) + ,(0.90,-0.05) + ] + +:: Mem :== Void + +Aesir :: !ClubName !Home !FootballField !Position !PlayersNumber !String -> Footballer +Aesir club home field position nr name + = { playerID = {clubName=club,playerNr=nr} + , name = name +++ "_" <+++ nr + , length = min_length + , pos = position + , nose = zero + , speed = zero + , skills = (Running, Kicking, Rotating) + , effect = Nothing + , stamina = max_stamina + , health = max_health + , brain = {memory = zero, ai = mind field } + } + +mind :: !FootballField !(!BrainInput, !Mem) -> (!BrainOutput, !Mem) +mind field (input, mm) + +afterfix after point diff (input=:{me}, m) +| d < diff = after (input, m) +| otherwise = (move, m) + where + d = dist me point + a = bearing zero me point + r = bearing me.nose me point + v = ms (max 6.0 (toReal d)) + +base_TeamName_MartLubbers :: String +base_TeamName_MartLubbers = "Æsir" \ No newline at end of file -- 2.20.1