initial team
[fp1415-soccerfun.git] / src / MartLubbers.icl
diff --git a/src/MartLubbers.icl b/src/MartLubbers.icl
new file mode 100644 (file)
index 0000000..65e62bf
--- /dev/null
@@ -0,0 +1,69 @@
+implementation module Team_MartLubbers\r
+\r
+import Footballer\r
+\r
+Team_MartLubbers :: !Home !FootballField -> Team\r
+Team_MartLubbers home field = \r
+|      home==West                              = westTeam\r
+|      otherwise                               = eastTeam\r
+where\r
+       eastTeam                                = mirror field westTeam\r
+       westTeam                                = [keeper : fielders]\r
+       clubname                                = base_TeamName_MiniEffie +++ if (home == West) "W" "E"\r
+       keeper                                  = MiniEffie clubname home field {zero & px=scale -0.5 field.flength} 1\r
+       fielders                                = [  MiniEffie clubname home field {px=scale (-0.5*dx) field.flength,py=scale (0.5*dy) field.fwidth} nr\r
+                                                         \\ (dx,dy) <- west_positions_fielders\r
+                                                          & nr      <- [2..]\r
+                                                         ]\r
+       west_positions_fielders = [(0.20, 0.40)\r
+                                                         ,(0.20,-0.40)\r
+                                                         ,(0.23, 0.00) \r
+                                                         ,(0.50, 0.45)\r
+                                                         ,(0.50,-0.45)\r
+                                                         ,(0.60, 0.00)\r
+                                                         ,(0.70, 0.35)\r
+                                                         ,(0.70,-0.35)\r
+                                                         ,(0.90, 0.05)\r
+                                                         ,(0.90,-0.05)\r
+                                                         ]                                                       \r
+\r
+:: MiniMemory                          = { home :: !Home }\r
+\r
+MiniEffie :: !ClubName !Home !FootballField !Position !PlayersNumber -> Footballer\r
+MiniEffie club home field position nr\r
+       = { playerID                    = {clubName=club,playerNr=nr}\r
+         , name                                = "MiniF." <+++ nr\r
+         , length                              = min_length\r
+         , pos                                 = position\r
+         , nose                                = zero\r
+         , speed                               = zero\r
+         , skills                              = (Running, Kicking, Rotating)\r
+         , effect                              = Nothing\r
+         , stamina                             = max_stamina\r
+         , health                              = max_health\r
+         , brain                               = { memory = {home=home}, ai = minibrain field }\r
+         }       \r
+\r
+minibrain :: !FootballField !(!BrainInput,!MiniMemory) -> (!BrainOutput,!MiniMemory)\r
+minibrain field (input=:{referee,me}, memory=:{home})\r
+| i_am_close_to_the_ball\r
+       | i_can_see goal                = (kick_the_ball,     new_memory)\r
+       | otherwise                             = (turn_to_face goal, new_memory)\r
+| i_can_see ball                       = (run_to_the_ball,   new_memory)\r
+| otherwise                                    = (turn_to_face ball, new_memory)       \r
+where\r
+       new_memory                              = {home=if (any isEndHalf referee) (other home) home}\r
+       my_direction                    = me.nose\r
+       ball                                    = getBall input\r
+       goal                                    = centerOfGoal (other home) field\r
+       \r
+       i_am_close_to_the_ball  = dist me ball < maxKickReach me\r
+       i_can_see pos                   = abs (bearing my_direction me pos) < rad (0.05*pi)\r
+\r
+       run_to_the_ball                 = Move {direction=bearing zero me ball,velocity=speed_of_light} zero\r
+       turn_to_face pos                = Move zero (bearing my_direction me pos)\r
+       kick_the_ball                   = KickBall {vxy={direction=my_direction,velocity=speed_of_light}, vz=ms 1.0}\r
+       speed_of_light                  = ms 299792458.0\r
+\r
+base_TeamName_MiniEffie                :: String\r
+base_TeamName_MiniEffie                = "Æsir"        
\ No newline at end of file