1 implementation module Team
5 /* Import all standard teams: */
7 import Team_Opponent_Slalom_Assignment
8 import Team_Opponent_Passing_Assignment
9 import Team_Opponent_DeepPass_Assignment
10 import Team_Opponent_Keeper_Assignment
11 import Team_Student_Rounds_Assignment
12 import Team_Student_Slalom_Assignment
13 import Team_Student_Passing_Assignment
14 import Team_Student_DeepPass_Assignment
15 import Team_Student_Keeper_Assignment
16 import Team_MartLubbers
19 allAvailableTeams :: [Home FootballField -> Team]
20 allAvailableTeams = [ Team_MartLubbers
24 , Team_Student_Passing
25 , Team_Student_DeepPass
27 , Team_Opponent_Slalom
28 , Team_Opponent_Passing
29 , Team_Opponent_DeepPass
30 , Team_Opponent_Keeper
31 ] ++ [MostlyHarmless (11, Level n) \\ n <- [0..10]]
33 instance nameOf Team where nameOf players
35 [fb:_] = nameOf fb.playerID
36 none = abort "nameOf[Team]: applied to empty team.\n"
38 validateTeam :: !Team -> Team
39 validateTeam team = map validateFootballer team
41 validateFootballer :: !Footballer -> Footballer
42 validateFootballer fb=:{length} = {fb & length = setbetween length min_length max_length
43 , stamina = max_stamina
47 isValidTeam :: !Team -> Bool
48 isValidTeam team = length clubNames == 1
50 (isEmpty keepers || isValidKeeper (hd keepers))
52 all isValidPlayer players
54 sort (map nrOf players) == sort (removeDup (map nrOf players))
56 not (isMember 1 (map nrOf fielders))
58 (keepers,fielders) = spanfilter isKeeper team
59 clubNames = removeDup (map clubOf players)
60 clubName = hd clubNames
61 players = keepers ++ fielders
62 clubOf fb = fb.playerID.clubName
63 nrOf fb = fb.playerID.playerNr
64 isValidKeeper fb = fb.playerID == {clubName=clubName,playerNr=1}
65 isValidPlayer fb = clubOf fb == clubName
67 allPlayersAtHome :: !FootballField !Home !Team -> Bool
68 allPlayersAtHome field home team = all atHome team
70 atHome = if (home == West) (\player -> player.Footballer.pos.px <= zero)
71 (\player -> player.Footballer.pos.px >= zero)
73 replaceInTeam :: ![Footballer] !Team -> Team
74 replaceInTeam fbs team = removeMembers team fbs ++ fbs
76 getTeam :: !ClubName ![Team] -> Team
77 getTeam cn teams = case [team \\ team<-teams | nameOf team==cn] of
79 _ = abort ("Team " <+++ cn <+++ " does not seem to exist.\n")
81 instance mirror [a] | mirror a where mirror field as = map (mirror field) as
82 instance mirror Footballer where mirror field fb = {fb & pos = mirror field fb.pos
83 , nose = mirror field fb.nose
84 , speed = mirror field fb.speed
86 instance mirror Position where mirror field pos = {pos & px = ~pos.px}
87 instance mirror Speed where mirror field speed = {speed & direction = mirror field speed.direction}
88 instance mirror Angle where mirror field angle = rad pi - angle