1 definition module Football
3 /** The Football data type and a number of access functions.
6 import Footballer, randomstream
8 :: FootballState = Free !Football
9 | GainedBy !FootballerID
10 :: Football = { ballPos :: !Position3D
11 , ballSpeed :: !Speed3D
13 :: BounceDirection = Down | Up | Forward | Back
15 instance zero Football
16 instance toPosition Football
17 instance toPosition3D Football
19 /* mkFootball returns a football with 3D dimensions.
21 mkFootball :: !Position !Speed -> Football
23 /* ballIsFree yields True iff argument is (Free ...).
25 ballIsFree :: !FootballState -> Bool
27 /* ballIsGainedBy yields True iff the ball is in possession by the given player.
29 ballIsGainedBy :: !FootballerID !FootballState -> Bool
31 /* getFootball returns the football (containing its position and speed-information)
32 that is either free or gained by a footballer.
33 For this reason, the list of footballers must contain all footballers, otherwise
34 this function may fail.
36 getFootball :: !FootballState !.[Footballer] -> Football
38 radius_football :== m 0.113 // radius of football
39 surface_resistance :== 0.85 // maximum speed of ball when moving over surface
40 air_resistance :== 0.95 // maximum speed of ball when moving through air (should depend on velocity)
41 accelleration_sec :== ms 9.81 // acceleration difference per square second