initial team
[fp1415-soccerfun.git] / src / MartLubbers.icl
1 implementation module Team_MartLubbers
2
3 import Footballer
4
5 Team_MartLubbers :: !Home !FootballField -> Team
6 Team_MartLubbers home field =
7 | home==West = westTeam
8 | otherwise = eastTeam
9 where
10 eastTeam = mirror field westTeam
11 westTeam = [keeper : fielders]
12 clubname = base_TeamName_MiniEffie +++ if (home == West) "W" "E"
13 keeper = MiniEffie clubname home field {zero & px=scale -0.5 field.flength} 1
14 fielders = [ MiniEffie clubname home field {px=scale (-0.5*dx) field.flength,py=scale (0.5*dy) field.fwidth} nr
15 \\ (dx,dy) <- west_positions_fielders
16 & nr <- [2..]
17 ]
18 west_positions_fielders = [(0.20, 0.40)
19 ,(0.20,-0.40)
20 ,(0.23, 0.00)
21 ,(0.50, 0.45)
22 ,(0.50,-0.45)
23 ,(0.60, 0.00)
24 ,(0.70, 0.35)
25 ,(0.70,-0.35)
26 ,(0.90, 0.05)
27 ,(0.90,-0.05)
28 ]
29
30 :: MiniMemory = { home :: !Home }
31
32 MiniEffie :: !ClubName !Home !FootballField !Position !PlayersNumber -> Footballer
33 MiniEffie club home field position nr
34 = { playerID = {clubName=club,playerNr=nr}
35 , name = "MiniF." <+++ nr
36 , length = min_length
37 , pos = position
38 , nose = zero
39 , speed = zero
40 , skills = (Running, Kicking, Rotating)
41 , effect = Nothing
42 , stamina = max_stamina
43 , health = max_health
44 , brain = { memory = {home=home}, ai = minibrain field }
45 }
46
47 minibrain :: !FootballField !(!BrainInput,!MiniMemory) -> (!BrainOutput,!MiniMemory)
48 minibrain field (input=:{referee,me}, memory=:{home})
49 | i_am_close_to_the_ball
50 | i_can_see goal = (kick_the_ball, new_memory)
51 | otherwise = (turn_to_face goal, new_memory)
52 | i_can_see ball = (run_to_the_ball, new_memory)
53 | otherwise = (turn_to_face ball, new_memory)
54 where
55 new_memory = {home=if (any isEndHalf referee) (other home) home}
56 my_direction = me.nose
57 ball = getBall input
58 goal = centerOfGoal (other home) field
59
60 i_am_close_to_the_ball = dist me ball < maxKickReach me
61 i_can_see pos = abs (bearing my_direction me pos) < rad (0.05*pi)
62
63 run_to_the_ball = Move {direction=bearing zero me ball,velocity=speed_of_light} zero
64 turn_to_face pos = Move zero (bearing my_direction me pos)
65 kick_the_ball = KickBall {vxy={direction=my_direction,velocity=speed_of_light}, vz=ms 1.0}
66 speed_of_light = ms 299792458.0
67
68 base_TeamName_MiniEffie :: String
69 base_TeamName_MiniEffie = "Æsir"