initial framework added
authorMart Lubbers <mart@martlubbers.net>
Tue, 2 Jun 2015 11:30:38 +0000 (13:30 +0200)
committerMart Lubbers <mart@martlubbers.net>
Tue, 2 Jun 2015 11:30:38 +0000 (13:30 +0200)
117 files changed:
doc/Installing SoccerFun on Windows.txt [new file with mode: 0644]
doc/Over SoccerFun.pptx [new file with mode: 0644]
doc/images/appel_en_peer.jpg [new file with mode: 0644]
doc/images/appel_en_peer_2.jpg [new file with mode: 0644]
doc/images/fixed_camera.bmp [new file with mode: 0644]
doc/images/flatland.bmp [new file with mode: 0644]
doc/images/player_and_ball.bmp [new file with mode: 0644]
doc/quickstart_SoccerFun.pdf [new file with mode: 0644]
src/Game/Football.dcl [new file with mode: 0644]
src/Game/Football.icl [new file with mode: 0644]
src/Game/Footballer.dcl [new file with mode: 0644]
src/Game/Footballer.icl [new file with mode: 0644]
src/Game/FootballerFunctions.dcl [new file with mode: 0644]
src/Game/FootballerFunctions.icl [new file with mode: 0644]
src/Game/GamePicture.dcl [new file with mode: 0644]
src/Game/GamePicture.icl [new file with mode: 0644]
src/Game/Geometry.dcl [new file with mode: 0644]
src/Game/Geometry.icl [new file with mode: 0644]
src/Game/Referee.dcl [new file with mode: 0644]
src/Game/Referee.icl [new file with mode: 0644]
src/Game/Team.dcl [new file with mode: 0644]
src/Game/Team.icl [new file with mode: 0644]
src/Game/matchControl.dcl [new file with mode: 0644]
src/Game/matchControl.icl [new file with mode: 0644]
src/Game/matchGame.dcl [new file with mode: 0644]
src/Game/matchGame.icl [new file with mode: 0644]
src/Game/matchLog.dcl [new file with mode: 0644]
src/Game/matchLog.icl [new file with mode: 0644]
src/Game/randomstream.dcl [new file with mode: 0644]
src/Game/randomstream.icl [new file with mode: 0644]
src/Gui/Gui2D.dcl [new file with mode: 0644]
src/Gui/Gui2D.icl [new file with mode: 0644]
src/Gui/digitdisplay.dcl [new file with mode: 0644]
src/Gui/digitdisplay.icl [new file with mode: 0644]
src/Gui/guiInterface.dcl [new file with mode: 0644]
src/Gui/guiInterface.icl [new file with mode: 0644]
src/Gui/render.dcl [new file with mode: 0644]
src/Gui/render.icl [new file with mode: 0644]
src/Gui/renderGameFixCamera.dcl [new file with mode: 0644]
src/Gui/renderGameFixCamera.icl [new file with mode: 0644]
src/Gui/renderGameFlatlandish.dcl [new file with mode: 0644]
src/Gui/renderGameFlatlandish.icl [new file with mode: 0644]
src/Gui/textdisplay.dcl [new file with mode: 0644]
src/Gui/textdisplay.icl [new file with mode: 0644]
src/SoccerFun.env [new file with mode: 0644]
src/SoccerFun.icl [new file with mode: 0644]
src/SoccerFun.prj [new file with mode: 0644]
src/SoccerFun64.env [new file with mode: 0644]
src/SoccerFun_options.txt [new file with mode: 0644]
src/StdLibExt/RandomExt.dcl [new file with mode: 0644]
src/StdLibExt/RandomExt.icl [new file with mode: 0644]
src/StdLibExt/RangeSlider.dcl [new file with mode: 0644]
src/StdLibExt/RangeSlider.icl [new file with mode: 0644]
src/StdLibExt/StdEnvExt.dcl [new file with mode: 0644]
src/StdLibExt/StdEnvExt.icl [new file with mode: 0644]
src/StdLibExt/StdIOExt.dcl [new file with mode: 0644]
src/StdLibExt/StdIOExt.icl [new file with mode: 0644]
src/StdLibExt/fileIO.dcl [new file with mode: 0644]
src/StdLibExt/fileIO.icl [new file with mode: 0644]
src/StdReferee/RefereeCoach_DeepPass_Assignment.dcl [new file with mode: 0644]
src/StdReferee/RefereeCoach_DeepPass_Assignment.icl [new file with mode: 0644]
src/StdReferee/RefereeCoach_Keeper_Assignment.dcl [new file with mode: 0644]
src/StdReferee/RefereeCoach_Keeper_Assignment.icl [new file with mode: 0644]
src/StdReferee/RefereeCoach_Passing_Assignment.dcl [new file with mode: 0644]
src/StdReferee/RefereeCoach_Passing_Assignment.icl [new file with mode: 0644]
src/StdReferee/RefereeCoach_Rounds_Assignment.dcl [new file with mode: 0644]
src/StdReferee/RefereeCoach_Rounds_Assignment.icl [new file with mode: 0644]
src/StdReferee/RefereeCoach_Slalom_Assignment.dcl [new file with mode: 0644]
src/StdReferee/RefereeCoach_Slalom_Assignment.icl [new file with mode: 0644]
src/StdReferee/RefereeFunctions.dcl [new file with mode: 0644]
src/StdReferee/RefereeFunctions.icl [new file with mode: 0644]
src/StdReferee/Umpire.dcl [new file with mode: 0644]
src/StdReferee/Umpire.icl [new file with mode: 0644]
src/StdTeam/Buffer.dcl [new file with mode: 0644]
src/StdTeam/Buffer.icl [new file with mode: 0644]
src/StdTeam/KeeperChallenger.dcl [new file with mode: 0644]
src/StdTeam/KeeperChallenger.icl [new file with mode: 0644]
src/StdTeam/TeamMiniEffie.dcl [new file with mode: 0644]
src/StdTeam/TeamMiniEffie.icl [new file with mode: 0644]
src/StdTeam/Team_Opponent_DeepPass_Assignment.dcl [new file with mode: 0644]
src/StdTeam/Team_Opponent_DeepPass_Assignment.icl [new file with mode: 0644]
src/StdTeam/Team_Opponent_Keeper_Assignment.dcl [new file with mode: 0644]
src/StdTeam/Team_Opponent_Keeper_Assignment.icl [new file with mode: 0644]
src/StdTeam/Team_Opponent_Passing_Assignment.dcl [new file with mode: 0644]
src/StdTeam/Team_Opponent_Passing_Assignment.icl [new file with mode: 0644]
src/StdTeam/Team_Opponent_Slalom_Assignment.dcl [new file with mode: 0644]
src/StdTeam/Team_Opponent_Slalom_Assignment.icl [new file with mode: 0644]
src/StdTeam/Team_Student_DeepPass_Assignment.dcl [new file with mode: 0644]
src/StdTeam/Team_Student_DeepPass_Assignment.icl [new file with mode: 0644]
src/StdTeam/Team_Student_Keeper_Assignment.dcl [new file with mode: 0644]
src/StdTeam/Team_Student_Keeper_Assignment.icl [new file with mode: 0644]
src/StdTeam/Team_Student_Passing_Assignment.dcl [new file with mode: 0644]
src/StdTeam/Team_Student_Passing_Assignment.icl [new file with mode: 0644]
src/StdTeam/Team_Student_Rounds_Assignment.dcl [new file with mode: 0644]
src/StdTeam/Team_Student_Rounds_Assignment.icl [new file with mode: 0644]
src/StdTeam/Team_Student_Slalom_Assignment.dcl [new file with mode: 0644]
src/StdTeam/Team_Student_Slalom_Assignment.icl [new file with mode: 0644]
src/afbeeldingen/AmsterdamArenA.bmp [new file with mode: 0644]
src/afbeeldingen/Thumbs.db [new file with mode: 0644]
src/afbeeldingen/hands.bmp [new file with mode: 0644]
src/afbeeldingen/ivanov_badluck.bmp [new file with mode: 0644]
src/afbeeldingen/ivanov_fluit.bmp [new file with mode: 0644]
src/afbeeldingen/ivanov_look.bmp [new file with mode: 0644]
src/afbeeldingen/ivanov_red.bmp [new file with mode: 0644]
src/afbeeldingen/ivanov_theater.bmp [new file with mode: 0644]
src/afbeeldingen/ivanov_warning.bmp [new file with mode: 0644]
src/afbeeldingen/ivanov_wijst_links.bmp [new file with mode: 0644]
src/afbeeldingen/ivanov_wijst_rechts.bmp [new file with mode: 0644]
src/afbeeldingen/ivanov_yellow.bmp [new file with mode: 0644]
src/sound/CenterKick.wav [new file with mode: 0644]
src/sound/ballOut.wav [new file with mode: 0644]
src/sound/callToTossCoin.wav [new file with mode: 0644]
src/sound/endGameOrHalf.wav [new file with mode: 0644]
src/sound/offside.wav [new file with mode: 0644]
src/sound/stopBecauseOfFoul.wav [new file with mode: 0644]
src/sound/tackles_ed.wav [new file with mode: 0644]
src/sound/wrongPosition2restartFrom.wav [new file with mode: 0644]

diff --git a/doc/Installing SoccerFun on Windows.txt b/doc/Installing SoccerFun on Windows.txt
new file mode 100644 (file)
index 0000000..2eab777
--- /dev/null
@@ -0,0 +1,72 @@
+To install SoccerFun on a Windows machine:\r
+\r
+(1) You need a Clean 2.3 distribution. You can download this for \r
+    free at:\r
+\r
+        http://wiki.clean.cs.ru.nl/Clean\r
+\r
+(2) Unpack the Clean 2.3 distribution. \r
+\r
+(3) In the Clean 2.3 distribution you find the CleanIDE.exe and a number \r
+    of directories: Config, Examples, Help, Libraries, Temp, and Tools.\r
+    \r
+    Move the unpacked SoccerFun distribution to Examples. \r
+\r
+    After this action the Examples folder of your Clean distribution should\r
+    contain a SoccerFun folder with the following content:\r
+\r
+    Examples\\r
+        ...\r
+        SoccerFun\\r
+            doc\\r
+                quickstart_SoccerFun\\r
+                    quickstart_SoccerFun.pdf\r
+                Installing SoccerFun on Windows.txt  // the document you're reading right now\r
+            src\\r
+                afbeeldingen\\r
+                Game\\r
+                Gui\\r
+                sound\\r
+                StdLibExt\\r
+                StdReferee\\r
+                StdTeam\\r
+                SoccerFun.env                        // see step 5 below\r
+                SoccerFun64.env                      // see step 5 below\r
+                SoccerFun.icl\r
+                SoccerFun.prj                        // see step 6 below\r
+    \r
+\r
+(4) Run the CleanIDE. If it is the first time that you run it, it will ask you \r
+    if it can integrate itself in the Windows system. \r
+    Choose "Yes" if you want this, "No" if you want to defer. \r
+    Note: choose "Never" only if you are very certain about this, \r
+          because it means truely never.\r
+\r
+(5) In the CleanIDE choose the command "Environment:Import...".\r
+    On a 32bit Windows machine, direct the file selector dialog to \r
+       SoccerFun\src\SoccerFun.env \r
+    and import the environment.\r
+    On a 64bit Windows machine, direct the file selector dialog to\r
+       SoccerFun\src\SoccerFun64.env\r
+    and import the environment.\r
+\r
+    This will set the default paths for the compiler.\r
+\r
+    You need to do this only once for your Clean distribution. \r
+\r
+    This step was successful if the CleanIDE has added "SoccerFun" to its list of\r
+    environments (command "Environment").\r
+\r
+(6) Now you can open (command "File:Open...") the project file at \r
+    Examples\SoccerFun\src\SoccerFun.prj.\r
+\r
+(7) Make sure the Environment of the CleanIDE is set to "SoccerFun".\r
+    Do this with the command "Environment:SoccerFun".\r
+\r
+(8) Bring the project up to date with "Project:Bring Up To Date".\r
+    Now all modules are compiled and an executable is created.\r
+    The executable can be launched with "Project:Run".\r
+\r
+    Note that "Project:Update and Run" combines the latter commands.\r
+\r
+(9) If all went well, Soccer-Fun should have started. Have fun!\r
diff --git a/doc/Over SoccerFun.pptx b/doc/Over SoccerFun.pptx
new file mode 100644 (file)
index 0000000..fbf7f75
Binary files /dev/null and b/doc/Over SoccerFun.pptx differ
diff --git a/doc/images/appel_en_peer.jpg b/doc/images/appel_en_peer.jpg
new file mode 100644 (file)
index 0000000..e265a01
Binary files /dev/null and b/doc/images/appel_en_peer.jpg differ
diff --git a/doc/images/appel_en_peer_2.jpg b/doc/images/appel_en_peer_2.jpg
new file mode 100644 (file)
index 0000000..f7d32e0
Binary files /dev/null and b/doc/images/appel_en_peer_2.jpg differ
diff --git a/doc/images/fixed_camera.bmp b/doc/images/fixed_camera.bmp
new file mode 100644 (file)
index 0000000..a00894e
Binary files /dev/null and b/doc/images/fixed_camera.bmp differ
diff --git a/doc/images/flatland.bmp b/doc/images/flatland.bmp
new file mode 100644 (file)
index 0000000..7908b66
Binary files /dev/null and b/doc/images/flatland.bmp differ
diff --git a/doc/images/player_and_ball.bmp b/doc/images/player_and_ball.bmp
new file mode 100644 (file)
index 0000000..01de090
Binary files /dev/null and b/doc/images/player_and_ball.bmp differ
diff --git a/doc/quickstart_SoccerFun.pdf b/doc/quickstart_SoccerFun.pdf
new file mode 100644 (file)
index 0000000..c844efc
Binary files /dev/null and b/doc/quickstart_SoccerFun.pdf differ
diff --git a/src/Game/Football.dcl b/src/Game/Football.dcl
new file mode 100644 (file)
index 0000000..d4b89e1
--- /dev/null
@@ -0,0 +1,41 @@
+definition module Football\r
+\r
+/**    The Football data type and a number of access functions.\r
+*/\r
+\r
+import Footballer, randomstream\r
+\r
+::     FootballState   = Free     !Football\r
+                                       | GainedBy !FootballerID\r
+::     Football                = { ballPos             :: !Position3D\r
+                                         , ballSpeed   :: !Speed3D\r
+                                         }\r
+::     BounceDirection = Down | Up | Forward | Back\r
+\r
+instance zero         Football\r
+instance toPosition   Football\r
+instance toPosition3D Football\r
+\r
+/*     mkFootball returns a football with 3D dimensions.\r
+*/\r
+mkFootball                     :: !Position !Speed -> Football\r
+\r
+/*     ballIsFree yields True iff argument is (Free ...).\r
+*/\r
+ballIsFree                     :: !FootballState -> Bool\r
+\r
+/*     ballIsGainedBy yields True iff the ball is in possession by the given player.\r
+*/\r
+ballIsGainedBy         :: !FootballerID !FootballState -> Bool\r
+\r
+/*     getFootball returns the football (containing its position and speed-information)\r
+       that is either free or gained by a footballer.\r
+       For this reason, the list of footballers must contain all footballers, otherwise\r
+       this function may fail.\r
+*/\r
+getFootball                    :: !FootballState !.[Footballer] -> Football\r
+\r
+radius_football                :== m 0.113                                     // radius of football\r
+surface_resistance     :== 0.85                                        // maximum speed of ball when moving over surface\r
+air_resistance         :== 0.95                                        // maximum speed of ball when moving through air (should depend on velocity)\r
+accelleration_sec      :== ms 9.81                                     // acceleration difference per square second\r
diff --git a/src/Game/Football.icl b/src/Game/Football.icl
new file mode 100644 (file)
index 0000000..528091c
--- /dev/null
@@ -0,0 +1,25 @@
+implementation module Football\r
+\r
+import Footballer, randomstream\r
+\r
+instance zero         Football where zero                                      = {ballPos=zero, ballSpeed=zero}\r
+instance toPosition   Football where toPosition   {ballPos} = ballPos.pxy\r
+instance toPosition3D Football where toPosition3D {ballPos}    = ballPos\r
+\r
+mkFootball :: !Position !Speed -> Football\r
+mkFootball pos2D speed2D                       = {ballPos = toPosition3D pos2D, ballSpeed = toSpeed3D speed2D}\r
+\r
+ballIsFree :: !FootballState -> Bool\r
+ballIsFree (Free _)                                    = True\r
+ballIsFree _                                           = False\r
+\r
+ballIsGainedBy :: !FootballerID !FootballState -> Bool\r
+ballIsGainedBy id (GainedBy id`)       = id == id`\r
+ballIsGainedBy _ _                                     = False\r
+\r
+getFootball :: !FootballState !.[Footballer] -> Football\r
+getFootball (Free ball) _                      = ball\r
+getFootball (GainedBy playerID) allPlayers\r
+       = case filter (identify_player playerID) allPlayers of\r
+               []                                                      = abort "getFootball: no player found with requested identifier."\r
+               [{pos,speed}:_]                         = mkFootball pos speed\r
diff --git a/src/Game/Footballer.dcl b/src/Game/Footballer.dcl
new file mode 100644 (file)
index 0000000..5cba703
--- /dev/null
@@ -0,0 +1,277 @@
+definition module Footballer\r
+\r
+/**    This module defines the part of the SoccerFun API that is concerned with the footballer data types.\r
+*/\r
+import StdMaybe, StdEnvExt\r
+from   StdIOCommon import :: Void(..)\r
+import Football, Geometry, Team\r
+\r
+::     Footballer                              = E. memory:                                                                                    // The memory of a footballer is a black box\r
+                                                               { playerID      :: !FootballerID                                                // The identification of a player: this must be unique\r
+                                                               , name          :: !String                                                              // The name of a player: this need not be unique\r
+                                                               , length        :: !Length                                                              // The length of a player: should be in range [min_length..max_length]\r
+                                                               , pos           :: !Position                                                    // The position of a player: should be on the football field\r
+                                                               , speed         :: !Speed                                                               // The speed of a player: absolute direction and velocity with which player is moving\r
+                                                               , nose          :: !Angle                                                               // The bearing of a player: absolute direction in which player is looking\r
+                                                               , skills        :: !MajorSkills                                                 // The major skills of a player: these improve performance of affected actions\r
+                                                               , effect        :: !Maybe FootballerEffect                              // The effect(s) of the previous action\r
+                                                               , stamina       :: !Stamina                                                             // The current stamina of a player: 1.0 is optimal, 0.0 is worst\r
+                                                               , health        :: !Health                                                              // The current health  of a player: 1.0 is optimal, 0.0 is worst\r
+                                                               , brain         :: !Brain (FootballerAI memory) memory  // The precious asset: use and update the memory and compute an action\r
+                                                               }\r
+::     FootballerID                    =       { clubName      :: !ClubName                                                    // Club name of team\r
+                                                               , playerNr      :: !PlayersNumber                                               // Number of player (1 for keeper, other for fielders)\r
+                                                               }\r
+instance ==       FootballerID\r
+instance toString FootballerID\r
+instance nameOf   FootballerID\r
+\r
+class sameClub a                       :: !a !a -> Bool                                                                                // belong to same club\r
+instance sameClub FootballerID\r
+instance sameClub Footballer\r
+\r
+::     ClubName                                :== String\r
+::     Length                                  :== Metre\r
+::     MajorSkills                             :== (!Skill,!Skill,!Skill)\r
+::     Skill                                   =       Running                                                                                         // Faster running without ball in possession\r
+                                                       |       Dribbling                                                                                       // Faster running with ball in possession\r
+                                                       |       Rotating                                                                                        // Wider range of rotation\r
+                                                       |       Gaining                                                                                         // Better ball gaining ability\r
+                                                       |       Kicking                                                                                         // More accurate and wider ball kicking\r
+                                                       |       Heading                                                                                         // More accurate and wider ball heading\r
+                                                       |       Feinting                                                                                        // Wider range of feint manouvre\r
+                                                       |       Jumping                                                                                         // Further jumping\r
+                                                       |       Catching                                                                                        // Better catching\r
+                                                       |       Tackling                                                                                        // More effective tackling\r
+instance ==       Skill\r
+instance toString Skill\r
+::     PlayersNumber                   :== Int\r
+\r
+instance ==           Footballer                                                                                                       // two players are equal if their playerID's are equal\r
+instance toPosition   Footballer\r
+instance toPosition3D Footballer\r
+\r
+defaultFootballer                      :: !FootballerID -> Footballer\r
+\r
+inRadiusOfFootballer           :: !Position !Footballer -> Bool                                                // True iff position touches/hits footballer\r
+skillsAsList                           ::           !Footballer -> [Skill]                                             // Skills of the footballer as a list\r
+\r
+::     FootballerAI memory             :== (BrainInput,memory) -> (BrainOutput,memory)\r
+::     FootballerAI`                   :==  BrainInput         ->  BrainOutput\r
+::     BrainInput                              =       { referee       :: [RefereeAction]                                              // the referee actions\r
+                                                               , football      :: FootballState                                                // the state of the football\r
+                                                               , others        :: [Footballer]                                                 // all other football players\r
+                                                               , me            :: Footballer                                                   // the player himself\r
+                                                               }\r
+::     BrainOutput                             :== FootballerAction                                                                    // the footballer action\r
+\r
+::     Half                                    = FirstHalf | SecondHalf\r
+instance ==                                    Half\r
+instance toString                      Half\r
+instance other                         Half\r
+\r
+::     Home                                    = West | East\r
+instance ==                                    Home\r
+instance toString                      Home\r
+instance other                         Home\r
+\r
+xWidthFootballer                       :== m (0.7/2.0)                                                                                 // chest   size of footballer\r
+yWidthFootballer                       :== m (0.4/2.0)                                                                                 // stomach size of footballer\r
+\r
+identify_player                        :: !FootballerID !Footballer -> Bool\r
+player_identity                                :: !Footballer -> FootballerID\r
+\r
+class    nameOf a              :: !a -> String\r
+instance nameOf Footballer\r
+\r
+getClubName                                    :: !Footballer -> ClubName\r
+isKeeper                                       :: !Footballer -> Bool\r
+isFielder                                      :: !Footballer -> Bool\r
+\r
+\r
+::     Brain ai m                              =       { ai    :: !ai\r
+                                                               , memory:: !m\r
+                                                               }\r
+::     Stamina                                 :== Real\r
+::     Health                                  :== Real\r
+\r
+min_length                                     :== m 1.6                                                                                               // minimum length of a person. Advantages:  better gainball; better stamina at sprinting; better dribbling; less health damage when fall, better rotating.\r
+max_length                                     :== m 2.1                                                                                               // maximum length of a person. Advantages:      wider  gainball; better stamina at running;   higher headball;  improved catching; harder kicking.\r
+max_stamina                                    :== 1.0\r
+max_health                                     :== 1.0\r
+\r
+/**    Footballer attribute dependent abilities:\r
+               use these functions to make your player correctly dependent of abilities.\r
+*/\r
+maxGainReach                           :: !Footballer                          -> Metre\r
+maxJumpReach                           :: !Footballer                          -> Metre                                        // vertical jumping\r
+maxGainVelocityDifference      :: !Footballer !Metre           -> Velocity\r
+maxCatchVelocityDifference     :: !Footballer !Metre           -> Velocity\r
+maxKickReach                           :: !Footballer                          -> Metre\r
+maxHeadReach                           :: !Footballer                          -> Metre\r
+maxCatchReach                          :: !Footballer                          -> Metre                                        // includes horizontal jumping\r
+maxTackleReach                         :: !Footballer                          -> Metre\r
+maxVelocityBallKick                    :: !Footballer                          -> Velocity     \r
+maxVelocityBallHead                    :: !Footballer !Velocity        -> Velocity\r
+maxKickingDeviation                    :: !Footballer                          -> Angle\r
+maxHeadingDeviation                    :: !Footballer                          -> Angle\r
+maxRotateAngle                         :: !Footballer                          -> Angle                                        // maximum angle with which footballer can rotate\r
+maxFeintStep                           :: !Footballer                          -> Metre                                        // maximum side step of footballer for feint manouvre\r
+\r
+::     HealthStaminaFactor             :== Real                                                                                                // combination of stamina and health\r
+getHealthStaminaFactor         :: !Health !Stamina                     -> HealthStaminaFactor\r
+\r
+\r
+::     FootballField                   = { fwidth      :: !FieldWidth                                                          // width  of football field (64m <=width <=75m)\r
+                                                         , flength     :: !FieldLength                                                         // length of football field (100m<=length<=110m)\r
+                                                         }\r
+::     FieldWidth                              :== Metre\r
+::     FieldLength                             :== Metre\r
+\r
+getDefaultField                                :: FootballField\r
+inPenaltyArea                          :: !FootballField !Home !Position -> Bool\r
+\r
+/**    Official metrics of a football field:\r
+*/\r
+radius_centre_circle           :== m  9.15\r
+radius_centre_spot                     :== m  0.3                                                                                              // not official, taken for rendering\r
+goal_width                                     :== m  7.32                                                                                             // interior\r
+goal_height                                    :== m  2.44                                                                                             // interior\r
+goal_area_depth                                :== m  5.50\r
+penalty_area_depth                     :== m 16.50\r
+penalty_spot_depth                     :== m 11.00\r
+radius_penalty_spot                    :== m  0.3                                                                                              // not official, taken for rendering\r
+radius_penalty_area                    :== m  9.15\r
+radius_corner_kick_area                :== m  0.90\r
+goal_pole_width                                :== m  0.2                                                                                              // not official\r
+\r
+/** goal_poles yields the py coordinates of the interiors of (north pole, south pole) of the goal (note that north > 0 > south)\r
+*/     \r
+goal_poles                                     :: !FootballField       -> (!Metre,!Metre)\r
+\r
+repell_distance                                :== m 9.15                                                                                              // minimum distance of opponents from ball at (in)direct free kick\r
+\r
+::     FootballerAction                                                                                                                                // actions a player can intend to perform\r
+       =       Move                            !Speed !Angle                                                                                   // wish to rotate over given angle, and then move with given speed\r
+       |       Feint                           !FeintDirection                                                                                 // wish to make feint manouvre\r
+       |       KickBall                        !Speed3D                                                                                                // wish to kick ball with given speed\r
+       |       HeadBall                        !Speed3D                                                                                                // wish to head ball with given speed\r
+       |       GainBall                                                                                                                                        // wish to gain possession of the ball\r
+       |       CatchBall                                                                                                                                       // wish to catch the ball with his hands\r
+       |       Tackle                          !FootballerID !Velocity                                                                 // wish to tackle identified player, higher velocity is higher chance of succes AND injury\r
+\r
+isMove                                         :: !FootballerAction -> Bool\r
+isGainBall                                     :: !FootballerAction -> Bool\r
+isCatchBall                                    :: !FootballerAction -> Bool\r
+isKickBall                                     :: !FootballerAction -> Bool\r
+isHeadBall                                     :: !FootballerAction -> Bool\r
+isFeint                                                :: !FootballerAction -> Bool\r
+isFootballerTackle                     :: !FootballerAction -> Bool\r
+isActionOnBall                         :: !FootballerAction -> Bool\r
+\r
+instance ==                                    FootballerAction\r
+instance toString                      FootballerAction\r
+\r
+:: FeintDirection                      = FeintLeft | FeintRight\r
+instance ==                                    FeintDirection\r
+instance toString                      FeintDirection\r
+\r
+::     FootballerEffect                = Moved       !Speed !Angle                                                             // player has rotated with given angle, and then ran with given speed\r
+                                                       | Feinted     !FeintDirection                                                   // player had feinted\r
+                                                       | KickedBall  !(Maybe Speed3D)                                                  // player kicked ball (Just v) with velocity, or didn't (Nothing)\r
+                                                       | HeadedBall  !(Maybe Speed3D)                                                  // player headed ball (Just v) with velocity, or didn't (Nothing)\r
+                                                       | GainedBall  !Success                                                                  // player attempt to gain ball from other player\r
+                                                       | CaughtBall  !Success                                                                  // player caught the ball with his hands\r
+                                                       | Tackled     !FootballerID !Velocity !Success                  // player attempt to tackle an opponent\r
+                                                       | OnTheGround !FramesToGo                                                               // tackled by someone else; FramesToGo is the amount of frames that you will be on the ground\r
+::     Reprimand                               = Warning | YellowCard | RedCard                                                // If the referee gives a second yellow he should add red to it himself\r
+instance toString                      Reprimand\r
+instance ==                                    Reprimand\r
+::     Success                                 = Success | Fail\r
+instance toString                      Success\r
+instance ==                                    Success\r
+::     FramesToGo                              :== Int                                                                                                 // number of frames to go before event ends                             \r
+\r
+isMoved                                                :: !FootballerEffect -> Bool\r
+isGainedBall                           :: !FootballerEffect -> Bool\r
+isKickedBall                           :: !FootballerEffect -> Bool\r
+isHeadedBall                           :: !FootballerEffect -> Bool\r
+isFeinted                                      :: !FootballerEffect -> Bool\r
+isTackled                                      :: !FootballerEffect -> Bool\r
+isCaughtBall                           :: !FootballerEffect -> Bool\r
+isOnTheGround                          :: !FootballerEffect -> Bool\r
+\r
+failFootballerAction           :: !FootballerAction -> FootballerEffect\r
+\r
+::     RefereeAction                   = ReprimandPlayer   !FootballerID !Reprimand                    // player with given name receives reprimand\r
+                                                       | Hands                         !FootballerID                                           // person is seen for doing hands\r
+                                                       | TackleDetected        !FootballerID                                           // person is seen for doing tackle\r
+                                                       | DangerousPlay         !FootballerID                                           // person is seen for doing dangerous actions\r
+                                                       | GameOver                                                                                              // end of game\r
+                                                       | GameCancelled         !(Maybe Home)                                           // game is cancelled, (Just home) wins\r
+                                                       | PauseGame                                                                                             // game is paused\r
+                                                       | AddTime                       !ExtraTime                                                      // extra time is added to the game\r
+                                                       | EndHalf                                                                                               // first half is over, teams go for a second half\r
+                                                       | Goal                          !Home                                                           // team playing at home has scored\r
+                                                       | Offside                       !FootballerID                                           // player is offside\r
+                                                       | DirectFreeKick        !Home !Position                                         // a direct free kick is granted for team home at given position                                        \r
+                                                       | GoalKick              !Home                                                           // a goal kick is granted for team home\r
+                                                       | Corner                !Home !Edge                                                     // a corner kick is granted for team home\r
+                                                       | ThrowIn               !Home !Position                                         // a throw in ball is granted for team home at given position\r
+                                                       | Penalty                       !Home                                                           // penalty at homeside\r
+                                                       | CenterKick            !Home                                                           // team playing at home may start from the center\r
+                                                       | Advantage                     !Home                                                           // referee gives advantages to home-team\r
+                                                       | OwnBallIllegally  !FootballerID                                               // ball was for the other team\r
+                                                       | DisplacePlayers       !Displacements                                          // displaces all footballers at the provided position (used with free kicks)\r
+                                                       | ContinueGame\r
+                                                       | TellMessage           !String                                                         // no effect on match, message is displayed by referee\r
+showSuccintRefereeAction       :: !RefereeAction -> String                                                             // yield a concise string representation of the referee decision\r
+\r
+::     Edge                                    = North | South\r
+instance ==                                    Edge\r
+instance toString                      Edge\r
+instance other                         Edge\r
+\r
+::     Displacements                   :== AssocList FootballerID Displacement                                 // players that need to be displaced\r
+::     Displacement                    :== Position                                                                                    // new position\r
+\r
+displacements                          :: !Team -> Displacements\r
+\r
+::     ExtraTime                               :== Minutes\r
+::     Minutes\r
+instance zero                          Minutes\r
+instance <                                     Minutes\r
+instance ==                                    Minutes\r
+instance +                                     Minutes\r
+instance -                                     Minutes\r
+instance scale                         Minutes\r
+instance toString                      Minutes\r
+instance toReal                                Minutes\r
+\r
+class minutes a                                :: !a -> Minutes\r
+instance minutes                       Real                                                                                                    // (minutes m) interprets m as number of minutes\r
+\r
+isReprimandPlayer                      :: !RefereeAction -> Bool\r
+isHands                                                :: !RefereeAction -> Bool\r
+isTackleDetected                       :: !RefereeAction -> Bool\r
+isDangerousPlay                                :: !RefereeAction -> Bool\r
+isGameOver                                     :: !RefereeAction -> Bool\r
+isGameCancelled                                :: !RefereeAction -> Bool\r
+isPauseGame                                    :: !RefereeAction -> Bool\r
+isAddTime                                      :: !RefereeAction -> Bool\r
+isEndHalf                                      :: !RefereeAction -> Bool\r
+isGoal                                         :: !RefereeAction -> Bool\r
+isOffside                                      :: !RefereeAction -> Bool\r
+isDirectFreeKick                       :: !RefereeAction -> Bool\r
+isGoalKick                                     :: !RefereeAction -> Bool\r
+isCorner                                       :: !RefereeAction -> Bool\r
+isThrowIn                                      :: !RefereeAction -> Bool\r
+isPenalty                                      :: !RefereeAction -> Bool\r
+isCenterKick                           :: !RefereeAction -> Bool\r
+isAdvantage                                    :: !RefereeAction -> Bool\r
+isOwnBallIllegally                     :: !RefereeAction -> Bool\r
+isDisplacePlayers                      :: !RefereeAction -> Bool\r
+isContinueGame                         :: !RefereeAction -> Bool\r
+isTellMessage                          :: !RefereeAction -> Bool\r
+\r
+getKickPos                                     :: !FootballField !Half !RefereeAction -> Maybe Position\r
diff --git a/src/Game/Footballer.icl b/src/Game/Footballer.icl
new file mode 100644 (file)
index 0000000..ef8d800
--- /dev/null
@@ -0,0 +1,433 @@
+implementation module Footballer
+
+import StdEnvExt
+import Football, FootballerFunctions, Geometry
+
+instance == Edge                                       where == North                    North                                         = True
+                                                                             == South                    South                                         = True
+                                                                             == _                        _                                                     = False
+instance == FootballerID                       where == i1                       i2                                            = i1.clubName == i2.clubName && i1.playerNr == i2.playerNr
+instance == Half                                       where == FirstHalf                FirstHalf                                     = True
+                                                                             == SecondHalf               SecondHalf                            = True
+                                                                             == _                        _                                                     = False
+instance == Reprimand                          where == Warning                  Warning                                       = True
+                                                                             == YellowCard               YellowCard                            = True
+                                                                             == RedCard                  RedCard                                       = True
+                                                                             == _                        _                                                     = False
+instance == Skill                                      where == s1                       s2                                            = toString s1 == toString s2
+instance == Success                                    where == Success                  Success                                       = True
+                                                                             == Fail                     Fail                                          = True
+                                                                             == _                        _                                                     = False
+instance == Footballer                         where == fb1                      fb2                                           = fb1.playerID == fb2.playerID
+instance == Home                                       where == West                     West                                          = True
+                                                                             == East                     East                                          = True
+                                                                             == _                        _                                                     = False
+instance == FeintDirection                     where == FeintLeft                FeintLeft                                     = True
+                                                                             == FeintRight               FeintRight                            = True
+                                                                             == _                        _                                                     = False
+instance == FootballerAction           where == (Move     speed1 angle1) (Move     speed2 angle2)      = speed1 == speed2 && angle1 == angle2
+                                                                             == GainBall                 GainBall                                      = True
+                                                                             == (KickBall speed3D1)      (KickBall speed3D2)           = speed3D1 == speed3D2
+                                                                             == (HeadBall speed3D1)      (HeadBall speed3D2)           = speed3D1 == speed3D2
+                                                                             == (Feint    fd1)           (Feint    fd2)                        = fd1 == fd2
+                                                                             == (Tackle   tf1 v1)        (Tackle   tf2 v2)                     = tf1 == tf2 && v1 == v2
+                                                                             == CatchBall                CatchBall                                     = True
+                                                                             == _ _                                                                                            = False
+instance other    Edge                         where other North                                               = South
+                                                                             other South                                               = North
+instance other    Half                         where other FirstHalf                                   = SecondHalf
+                                                                             other SecondHalf                                  = FirstHalf
+instance other    Home                         where other West                                                = East
+                                                                             other East                                                = West
+instance toString Edge                         where toString North                                    = "North"
+                                                                             toString South                                    = "South"
+instance toString FootballerID         where toString i                                                = "{clubName=" <+++ i.clubName +++ ",playerNr=" <+++ i.playerNr +++ "}"
+instance toString Half                         where toString FirstHalf                                = "FirstHalf"
+                                                                             toString SecondHalf                               = "SecondHalf"
+instance toString Reprimand                    where toString Warning                                  = "Warning"
+                                                                             toString YellowCard                               = "YellowCard"
+                                                                             toString RedCard                                  = "RedCard"
+instance toString Skill                                where toString Running                                  = "Running"
+                                                                             toString Dribbling                                = "Dribbling"
+                                                                             toString Rotating                                 = "Rotating"
+                                                                             toString Gaining                                  = "Gaining"
+                                                                             toString Kicking                                  = "Kicking"
+                                                                             toString Heading                                  = "Heading"
+                                                                             toString Feinting                                 = "Feinting"
+                                                                             toString Jumping                                  = "Jumping"
+                                                                             toString Catching                                 = "Catching"
+                                                                             toString Tackling                                 = "Tackling"
+instance toString Success                      where toString Success                                  = "Success"
+                                                                             toString Fail                                             = "Fail"
+instance toString Home                         where toString West                                             = "West"
+                                                                             toString East                                             = "East"
+instance toString FeintDirection       where toString FeintLeft                                = "FeintLeft"
+                                                                             toString FeintRight                               = "FeintRight"
+instance toString FootballerAction     where toString (Move     speed angle)   = "(Move "     <+++ speed  <+++ " " <+++ angle <+++ ")"
+                                                                             toString  GainBall                                = "GainBall"
+                                                                             toString (KickBall speed)                 = "(KickBall " <+++ speed  <+++ ")"
+                                                                             toString (HeadBall speed)                 = "(HeadBall " <+++ speed  <+++ ")"
+                                                                             toString (Feint    fd)                    = "(Feint "    <+++ fd     <+++ ")"
+                                                                             toString (Tackle   fbID v)                = "(Tackle "   <+++ fbID.playerNr <+++ " " <+++ v <+++ ")"
+                                                                             toString  CatchBall                               = "CatchBall"
+
+::     Minutes =   Minutes !Real
+
+instance zero         Minutes          where zero                                                              = Minutes zero
+instance <            Minutes          where <  (Minutes m1) (Minutes m2)              = m1 < m2
+instance ==           Minutes          where == (Minutes m1) (Minutes m2)              = m1 == m2
+instance +            Minutes          where +  (Minutes m1) (Minutes m2)              = Minutes (m1+m2)
+instance -            Minutes          where -  (Minutes m1) (Minutes m2)              = Minutes (m1-m2)
+instance scale        Minutes       where scale         k (Minutes m)       = Minutes (k * m)
+instance toString     Minutes          where toString        (Minutes m)               = toString (s/60) <+++ ":" <+++ if (s mod 60 < 10) "0" "" <+++ (s mod 60) <+++" min"
+                                          where s                                                      = toInt (((toReal (toInt (m * 100.0)))/100.0) * 60.0)
+instance toReal       Minutes          where toReal (Minutes m)                                = m
+instance minutes      Real                     where minutes m                                                 = Minutes m
+
+instance toPosition   Footballer       where toPosition   fb                                   = fb.pos
+instance toPosition3D Footballer       where toPosition3D fb                                   = toPosition3D fb.pos
+instance nameOf       Footballer       where nameOf {name,nose}                                = name
+instance nameOf       FootballerID     where nameOf {clubName}                                 = clubName
+instance sameClub     FootballerID     where sameClub id1 id2                                  = nameOf id1 == nameOf id2
+instance sameClub     Footballer       where sameClub fb1 fb2                                  = sameClub fb1.playerID fb2.playerID
+
+defaultFootballer                                                      :: !FootballerID -> Footballer
+defaultFootballer playerID                                     = { playerID    = playerID
+                                                                                         , name                = "default"
+                                                                                         , length              = m 1.6
+                                                                                         , pos                 = zero 
+                                                                                         , speed               = zero
+                                                                                         , nose                = zero
+                                                                                         , skills              = (Running, Kicking, Dribbling)
+                                                                                         , effect              = Nothing
+                                                                                         , stamina             = max_stamina
+                                                                                         , health              = max_health
+                                                                                         , brain               = {memory=Void, ai=returnAI (Move zero zero)}
+                                                                                         }
+
+inRadiusOfFootballer                                           :: !Position !Footballer -> Bool
+inRadiusOfFootballer pos player                                = isbetween pos.px (player.pos.px - xWidthFootballer) (player.pos.px + xWidthFootballer) &&
+                                                                                         isbetween pos.py (player.pos.py - yWidthFootballer) (player.pos.py + yWidthFootballer)
+
+skillsAsList                                                           :: !Footballer -> [Skill]
+skillsAsList fb                                                                = (\(a,b,c)->[a,b,c]) fb.skills
+
+identify_player                                                                :: !FootballerID !Footballer -> Bool
+identify_player id fb                                          = id == fb.playerID
+
+player_identity                                                                :: !Footballer -> FootballerID
+player_identity fb                                                     = fb.playerID
+
+getClubName                                                                    :: !Footballer -> ClubName
+getClubName fb                                                         = nameOf fb.playerID
+
+isKeeper                                                                       :: !Footballer -> Bool
+isKeeper fb                                                                    = fb.playerID.playerNr == 1
+
+isFielder                                                                      :: !Footballer -> Bool
+isFielder fb                                                           = not (isKeeper fb)
+
+/**    Footballer attribute dependent abilities:
+*/
+maxGainReach                                                           :: !Footballer -> Metre
+maxGainReach fb                                                                = scale (if (isMember Gaining (skillsAsList fb)) 0.5 0.3) fb.length
+
+maxJumpReach                                                           :: !Footballer -> Metre
+maxJumpReach fb                                                                = scale (if (isMember Jumping (skillsAsList fb)) 0.6 0.4) fb.length
+
+maxGainVelocityDifference                                      :: !Footballer !Metre -> Velocity
+maxGainVelocityDifference fb d_player_ball     = ms (if (isMember Gaining (skillsAsList fb)) 15.0 10.0 -  distanceDifficulty)
+where
+       length                                                                  = toReal fb.length
+       distanceDifficulty                                              = max zero ((0.8 * length)^4.0 * ((toReal d_player_ball)/length))
+
+maxCatchVelocityDifference                                     :: !Footballer !Metre -> Velocity
+maxCatchVelocityDifference fb d_player_ball    = ms (if (isMember Gaining (skillsAsList fb)) 20.0 17.0 - distanceDifficulty)
+where
+       length                                                                  = toReal fb.length
+       distanceDifficulty                                              = max zero ((0.8 * length)^4.0 * ((toReal d_player_ball)/length))
+
+maxKickReach                                                           :: !Footballer -> Metre
+maxKickReach fb                                                                = scale (if (isMember Kicking (skillsAsList fb)) 0.6 0.4) fb.length
+
+maxHeadReach                                                           :: !Footballer -> Metre
+maxHeadReach fb                                                                = scale (if (isMember Heading (skillsAsList fb)) 0.4 0.2) fb.length
+
+maxCatchReach                                                          :: !Footballer -> Metre         // includes horizontal jumping
+maxCatchReach fb                                                       = scale (if (isMember Catching (skillsAsList fb)) 1.8 1.5) fb.length
+
+maxTackleReach                                                         :: !Footballer -> Metre
+maxTackleReach fb                                                      = scale (if (isMember Tackling (skillsAsList fb)) 0.33 0.25) fb.length
+
+maxVelocityBallKick                                                    :: !Footballer -> Velocity      
+maxVelocityBallKick fb                                         = ms ((if (isMember Kicking (skillsAsList fb)) 27.0 25.0 + (toReal fb.length)/2.0) * (0.2*fatHealth+0.8))
+where
+       fatHealth                                                               = getHealthStaminaFactor fb.health fb.stamina
+
+maxVelocityBallHead                                                    :: !Footballer !Velocity -> Velocity
+maxVelocityBallHead fb ballSpeed                       = scale 0.7 ballSpeed + scale (0.1*fatHealth+0.9) (ms (if (isMember Heading (skillsAsList fb)) 7.0 5.0))
+where
+       fatHealth                                                               = getHealthStaminaFactor fb.health fb.stamina
+       
+maxKickingDeviation                                                    :: !Footballer -> Angle
+maxKickingDeviation skills                                     = rad (0.5*pi) //if (isMember Kicking skills) (pi/18.0) (pi/2.0)
+
+maxHeadingDeviation                                                    :: !Footballer -> Angle
+maxHeadingDeviation skills                                     = rad (0.25*pi) //if (isMember Heading skills) (pi/16.0) (pi/5.0)
+
+maxRotateAngle                                                         :: !Footballer -> Angle
+maxRotateAngle fb=:{speed,length}
+| velocity < 1.0                                                       = rad pi
+| otherwise                                                                    = rad (pi/18.0*((5.0/velocity)*((toReal length)/2.0)))
+where
+       velocity                                                                = abs (toReal speed.velocity)
+
+maxFeintStep                                                           :: !Footballer -> Metre
+maxFeintStep fb                                                                = m (if (isMember Feinting (skillsAsList fb)) 0.75 0.5)
+
+::     HealthStaminaFactor                                             :== Real                // combination of stamina and health
+
+getHealthStaminaFactor                                         :: !Health !Stamina -> HealthStaminaFactor
+getHealthStaminaFactor health stamina
+| stamina <= health                                                    = stamina
+| otherwise                                                                    = avg [stamina,health]
+
+isMove                                                                         :: !FootballerAction -> Bool
+isMove (Move _ _)                                                      = True
+isMove _                                                                       = False
+
+isGainBall                                                                     :: !FootballerAction -> Bool
+isGainBall GainBall                                                    = True
+isGainBall _                                                           = False
+
+isKickBall                                                                     :: !FootballerAction -> Bool
+isKickBall (KickBall _)                                                = True
+isKickBall _                                                           = False
+
+isHeadBall                                                                     :: !FootballerAction -> Bool
+isHeadBall (HeadBall _)                                                = True
+isHeadBall _                                                           = False
+
+isFeint                                                                                :: !FootballerAction -> Bool
+isFeint (Feint _)                                                      = True
+isFeint _                                                                      = False
+
+isFootballerTackle                                                     :: !FootballerAction -> Bool
+isFootballerTackle (Tackle _ _)                                = True
+isFootballerTackle _                                           = False
+
+isCatchBall                                                                    :: !FootballerAction -> Bool
+isCatchBall CatchBall                                          = True
+isCatchBall _                                                          = False
+
+isActionOnBall                                                         :: !FootballerAction -> Bool
+isActionOnBall GainBall                                                = True
+isActionOnBall CatchBall                                       = True
+isActionOnBall (KickBall _)                                    = True
+isActionOnBall (HeadBall _)                                    = True
+isActionOnBall _                                                       = False
+
+getDefaultField                                                                :: FootballField
+getDefaultField                                                                = { fwidth = m 75.0, flength = m 110.0 }
+
+inPenaltyArea                                                          :: !FootballField !Home !Position -> Bool
+inPenaltyArea field home pos                           = isbetween pos.py south_edge north_edge && if (home == West) (pos.px <= west_edge) (pos.px >= east_edge)
+where
+       north_edge                                                              = northPole + radius_penalty_area
+       south_edge                                                              = southPole - radius_penalty_area
+       (northPole,southPole)                                   = goal_poles field
+       half_length                                                             = scale 0.5 field.flength
+       west_edge                                                               = penalty_area_depth - half_length
+       east_edge                                                               = half_length - penalty_area_depth
+
+goal_poles                                                                     :: !FootballField -> (!Metre,!Metre)
+goal_poles field                                                       = (half_goal_width,~half_goal_width)
+where
+       half_goal_width                                                 = scale 0.5 goal_width
+
+isMoved                                                                                :: !FootballerEffect -> Bool
+isMoved (Moved _ _)                                                    = True
+isMoved _                                                                      = False
+
+isGainedBall                                                           :: !FootballerEffect -> Bool
+isGainedBall (GainedBall _)                                    = True
+isGainedBall _                                                         = False
+
+isKickedBall                                                           :: !FootballerEffect -> Bool
+isKickedBall (KickedBall _)                                    = True
+isKickedBall _                                                         = False
+
+isHeadedBall                                                           :: !FootballerEffect -> Bool
+isHeadedBall (HeadedBall _)                                    = True
+isHeadedBall _                                                         = False
+
+isFeinted                                                                      :: !FootballerEffect -> Bool
+isFeinted (Feinted _)                                          = True
+isFeinted _                                                                    = False
+
+isTackled                                                                      :: !FootballerEffect -> Bool
+isTackled (Tackled _ _ _)                                      = True
+isTackled _                                                                    = False
+
+isCaughtBall                                                           :: !FootballerEffect -> Bool
+isCaughtBall (CaughtBall _)                                    = True
+isCaughtBall _                                                         = False
+
+isOnTheGround                                                          :: !FootballerEffect -> Bool
+isOnTheGround (OnTheGround _)                          = True
+isOnTheGround _                                                                = False
+
+failFootballerAction                                           :: !FootballerAction -> FootballerEffect
+failFootballerAction (Move   s a)                      = Moved    s a
+failFootballerAction GainBall                          = GainedBall Fail
+failFootballerAction CatchBall                         = CaughtBall Fail
+failFootballerAction (KickBall v)                      = KickedBall Nothing
+failFootballerAction (HeadBall v)                      = HeadedBall Nothing
+failFootballerAction (Feint    d)                      = Feinted d
+failFootballerAction (Tackle p v)                      = Tackled p v Fail
+failFootballerAction _                                         = abort "failFootballerAction: unknown action failed"
+
+displacements                                                          :: !Team -> Displacements
+displacements team                                                     = [(playerID,pos) \\ {playerID,pos} <- team]
+
+showSuccintRefereeAction                                       :: !RefereeAction -> String
+showSuccintRefereeAction refAction
+       = case refAction of
+               (ReprimandPlayer  id r)                         = player id                     <+++ " receives " <+++ r
+               (Hands            id)                           = "Hands by "                   <+++ player id
+               (TackleDetected   id)                           = "Tackle by "                  <+++ player id
+               (DangerousPlay    id)                           = "Dangerous play by "          <+++ player id
+               GameOver                                                        = "Game ended"
+               (GameCancelled    mt)                           = "Game cancelled"              <+++ if (isJust mt) (" winner is " <+++ fromJust mt) ""
+               PauseGame                                                       = "Game paused"
+               (AddTime  t)                                            = "Extra time added: "          <+++ t
+               EndHalf                                                         = "First half ended"
+               (Goal     t)                                            = "Goal for "                   <+++ t
+               (Offside        id)                                     = "Offside by "                 <+++ player id
+               (DirectFreeKick t p)                            = "Direct free kick for "       <+++ t
+               (GoalKick t)                                            = "Goal kick for "              <+++ t
+               (Corner   t e)                                          = "Corner for "                 <+++ t
+               (ThrowIn  t p)                                          = "Throw in for "               <+++ t
+               (Penalty    t)                                          = "Penalty for "                <+++ t
+               (CenterKick t)                                          = "Center kick for "            <+++ t
+               (Advantage t)                                           = "Advantage for "              <+++ t
+               (OwnBallIllegally id)                           = "Illegal ball possession by " <+++ player id
+               (DisplacePlayers _)                                     = "Players displaced"
+               ContinueGame                                            = "Game continued"
+               (TellMessage txt)                                       = txt
+where
+       player {clubName,playerNr}                              = clubName <+++"[" <+++ playerNr <+++ "]"
+
+isReprimandPlayer                                                      :: !RefereeAction -> Bool
+isReprimandPlayer (ReprimandPlayer _ _)                = True
+isReprimandPlayer _                                                    = False
+
+isHands                                                                                :: !RefereeAction -> Bool
+isHands (Hands _)                                                      = True
+isHands _                                                                      = False
+
+isTackleDetected                                                       :: !RefereeAction -> Bool
+isTackleDetected (TackleDetected _)                    = True
+isTackleDetected _                                                     = False
+
+isDangerousPlay                                                                :: !RefereeAction -> Bool
+isDangerousPlay (DangerousPlay _)                      = True
+isDangerousPlay _                                                      = False
+
+isGameOver                                                                     :: !RefereeAction -> Bool
+isGameOver GameOver                                                    = True
+isGameOver _                                                           = False
+
+isGameCancelled                                                                :: !RefereeAction -> Bool
+isGameCancelled (GameCancelled _)                      = True
+isGameCancelled _                                                      = False
+
+isPauseGame                                                                    :: !RefereeAction -> Bool
+isPauseGame PauseGame                                          = True
+isPauseGame _                                                          = False
+
+isAddTime                                                                      :: !RefereeAction -> Bool
+isAddTime (AddTime _)                                          = True
+isAddTime _                                                                    = False
+
+isEndHalf                                                                      :: !RefereeAction -> Bool
+isEndHalf EndHalf                                                      = True
+isEndHalf _                                                                    = False
+
+isGoal                                                                         :: !RefereeAction -> Bool
+isGoal (Goal _)                                                                = True
+isGoal _                                                                       = False
+
+isOffside                                                                      :: !RefereeAction -> Bool
+isOffside (Offside _)                                          = True
+isOffside _                                                                    = False
+
+isDirectFreeKick                                                       :: !RefereeAction -> Bool
+isDirectFreeKick (DirectFreeKick _ _ )         = True
+isDirectFreeKick _                                                     = False
+
+isGoalKick                                                                     :: !RefereeAction -> Bool
+isGoalKick (GoalKick _)                                                = True
+isGoalKick _                                                           = False
+
+isCorner                                                                       :: !RefereeAction -> Bool
+isCorner (Corner _ _)                                          = True
+isCorner _                                                                     = False
+
+isThrowIn                                                                      :: !RefereeAction -> Bool
+isThrowIn (ThrowIn _ _)                                                = True
+isThrowIn _                                                                    = False
+
+isPenalty                                                                      :: !RefereeAction -> Bool
+isPenalty (Penalty _)                                          = True
+isPenalty _                                                                    = False
+
+isCenterKick                                                           :: !RefereeAction -> Bool
+isCenterKick (CenterKick _)                                    = True
+isCenterKick _                                                         = False
+
+isAdvantage                                                                    :: !RefereeAction -> Bool
+isAdvantage (Advantage _)                                      = True
+isAdvantage _                                                          = False
+
+isOwnBallIllegally                                                     :: !RefereeAction -> Bool
+isOwnBallIllegally (OwnBallIllegally _)                = True
+isOwnBallIllegally _                                           = False
+
+isDisplacePlayers                                                      :: !RefereeAction -> Bool
+isDisplacePlayers (DisplacePlayers _)          = True
+isDisplacePlayers _                                                    = False
+
+isContinueGame                                                         :: !RefereeAction -> Bool
+isContinueGame ContinueGame                                    = True
+isContinueGame _                                                       = False
+
+isTellMessage                                                          :: !RefereeAction -> Bool
+isTellMessage (TellMessage _)                          = True
+isTellMessage _                                                                = False
+
+getKickPos                                                                     :: !FootballField !Half !RefereeAction -> Maybe Position
+getKickPos field half (GoalKick home)          = Just { zero & px = if (home == West) (penalty_area_depth - half_length) (half_length - penalty_area_depth) }
+where
+       half_length                                                             = scale 0.5 field.flength
+getKickPos field half (Corner home edge)       = Just { px = if (home == West && half == SecondHalf || home == East && half == FirstHalf)
+                                                                                                        (half_radius_corner_kick_area - half_length)
+                                                                                                        (half_length - half_radius_corner_kick_area)
+                                                                                              , py = if (edge == North)
+                                                                                                        (half_radius_corner_kick_area - half_width)
+                                                                                                        (half_width - half_radius_corner_kick_area)
+                                                                                              }                
+where
+       half_width                                                              = scale 0.5 field.fwidth
+       half_length                                                             = scale 0.5 field.flength
+       half_radius_corner_kick_area                    = scale 0.5 radius_corner_kick_area
+getKickPos field half (Penalty home)           = Just { zero & px = if (home == West && half == SecondHalf || home == East && half == FirstHalf)
+                                                                                                               (penalty_spot_depth - half_length)
+                                                                                                               (half_length - penalty_spot_depth)
+                                                                                              }
+where
+       half_length                                                             = scale 0.5 field.flength
+getKickPos field _ (CenterKick _)                      = Just zero
+getKickPos _ _ (DirectFreeKick _ pos)          = Just pos
+getKickPos _ _ (ThrowIn _ pos)                         = Just pos
+getKickPos _ _ _                                                       = Nothing
diff --git a/src/Game/FootballerFunctions.dcl b/src/Game/FootballerFunctions.dcl
new file mode 100644 (file)
index 0000000..4f1e8f9
--- /dev/null
@@ -0,0 +1,32 @@
+definition module FootballerFunctions\r
+\r
+/**    Functions for creating miniscule brains:\r
+*/\r
+\r
+import Footballer\r
+\r
+//     The core functions that do not require a memory:\r
+returnAI`                      :: !FootballerAction -> FootballerAI`   // just return the action\r
+halt`                          ::                      FootballerAI`   // halt lets the footballer stand quite still\r
+rotate`                                :: !Angle            -> FootballerAI`   // rotate over given angle\r
+ahead`                         :: !Velocity         -> FootballerAI`   // follow your nose with given velocity/\r
+fix`                           :: !Position !Metre  -> FootballerAI`   // fix p d lets the footballer run to p, with a precision of d\r
+kick`                          :: !Position         -> FootballerAI`   // kick p lets the footballer kick the ball to position p, if in kicking range\r
+track_ball`                    :: !Metre            -> FootballerAI`   // track_ball` d lets the footballer move to the ball, with a precision of d\r
+\r
+amnesia                                :: FootballerAI`     -> FootballerAI m\r
+\r
+//     The derived functions that do not care about their memory (the amnesia versions of the above functions):\r
+returnAI                       :: (FootballerAction -> FootballerAI m)\r
+halt                           :: (                    FootballerAI m)\r
+rotate                         :: (Angle            -> FootballerAI m)\r
+ahead                          :: (Velocity         -> FootballerAI m)\r
+fix                                    :: (Position Metre   -> FootballerAI m)\r
+kick                           :: (Position         -> FootballerAI m)\r
+track_ball                     :: (Metre            -> FootballerAI m)\r
+\r
+centerOfGoal           :: !Home !FootballField -> Position\r
+(team)      infix 9    :: !Footballer ![Footballer] -> [Footballer]\r
+(opponents) infix 9    :: !Footballer ![Footballer] -> [Footballer]\r
+\r
+getBall                                :: !BrainInput -> Football\r
diff --git a/src/Game/FootballerFunctions.icl b/src/Game/FootballerFunctions.icl
new file mode 100644 (file)
index 0000000..2bcd55a
--- /dev/null
@@ -0,0 +1,95 @@
+implementation module FootballerFunctions\r
+\r
+import Footballer\r
+\r
+returnAI`                                      :: !FootballerAction -> FootballerAI`\r
+returnAI` action                       = const action\r
+\r
+move`                                          :: !Speed !Angle -> FootballerAI`\r
+move` speed angle                      = returnAI` (Move speed angle)\r
+\r
+halt`                                          :: FootballerAI`\r
+halt`                                          = move` zero zero\r
+\r
+rotate`                                                :: !Angle -> FootballerAI`\r
+rotate` angle                          = move` zero angle\r
+\r
+ahead`                                         :: !Velocity -> FootballerAI`\r
+ahead` v                                       = \input=:{me} -> move` {direction=me.nose,velocity=v} zero input\r
+\r
+fix`                                           :: !Position !Metre -> FootballerAI`\r
+fix` point eps                         = \input=:{me} ->\r
+  let distance                         = dist            me point\r
+      angle                                    = bearing zero    me point\r
+      rotate                           = bearing me.nose me point\r
+      v                                                = ms (max 6.0 (toReal distance))\r
+  in if (distance <= eps)\r
+        (halt` input)\r
+           (move` {direction=angle,velocity=v} rotate input)\r
+\r
+kick`                                          :: !Position -> FootballerAI`\r
+kick` point                            = \input=:{me} ->\r
+  let ball                                     = getBall input\r
+      angle                                    = bearing zero me point\r
+      v                                                = ms (2.0 * (toReal (dist me point)))\r
+  in if (dist me ball <= maxKickReach me)\r
+               (KickBall {vxy = {direction=angle,velocity=v},vz=ms 1.0})\r
+               (halt` input)\r
+\r
+track_ball`                                    :: !Metre -> FootballerAI`\r
+track_ball` eps                                = \input -> fix` (getBall input).ballPos.pxy eps input\r
+\r
+amnesia                                                :: FootballerAI` -> FootballerAI m\r
+amnesia f                   = \(input,m) -> (f input,m)\r
+\r
+returnAI                                       :: (FootballerAction -> FootballerAI m)\r
+returnAI                                       = amnesia o returnAI`\r
+\r
+move                                           :: (Speed Angle -> FootballerAI m)\r
+move                                           = \speed angle -> amnesia (move` speed angle)\r
+\r
+halt                                           :: (FootballerAI m)\r
+halt                                           = amnesia halt`\r
+\r
+rotate                                         :: (Angle -> FootballerAI m)\r
+rotate                                         = amnesia o rotate`\r
+\r
+ahead                                          :: (Velocity -> FootballerAI m)\r
+ahead                                          = amnesia o ahead`\r
+\r
+fix                                                    :: (Position Metre -> FootballerAI m)\r
+fix                                                    = \point eps -> amnesia (fix` point eps)\r
+\r
+kick                                           :: (Position -> FootballerAI m)\r
+kick                                           = amnesia o kick`\r
+\r
+track_ball                                     :: (Metre -> FootballerAI m)\r
+track_ball                                     = \eps -> amnesia (track_ball` eps)\r
+\r
+centerOfGoal                           :: !Home !FootballField -> Position\r
+centerOfGoal home field                = {zero & px = if (home==West) (~half_length) half_length}\r
+where\r
+       half_length                             = scale 0.5 field.flength\r
+\r
+(team) infix 9                         :: !Footballer ![Footballer] -> [Footballer]\r
+(team) player players          = filter (sameClub player) players\r
+\r
+(opponents) infix 9                    :: !Footballer ![Footballer] -> [Footballer]\r
+(opponents) player players     = filter (not o (sameClub player)) players\r
+\r
+getBall                                                :: !BrainInput -> Football\r
+getBall {football,me,others}= getFootball football [me : others]\r
+\r
+:: HomeM m                                     = { home :: !Home, mem :: !m }\r
+\r
+educate`                                       :: (Home -> FootballerAI`) -> FootballerAI (HomeM m)\r
+educate` home_ai                       = \(input=:{referee},memory) ->\r
+  let new_home                         = if (any isEndHalf referee) other id memory.home\r
+      action                           = home_ai new_home input\r
+  in  (action, {memory & home = new_home})\r
+\r
+educate                                                :: (Home -> FootballerAI m) -> FootballerAI (HomeM m)\r
+educate home_ai                                = \(input=:{referee},memory) ->\r
+  let new_home                         = if (any isEndHalf referee) other id memory.home\r
+      (action,new_memory)      = home_ai new_home (input,memory.mem)\r
+  in  (action, {memory & home = new_home, mem = new_memory})\r
diff --git a/src/Game/GamePicture.dcl b/src/Game/GamePicture.dcl
new file mode 100644 (file)
index 0000000..e08511d
--- /dev/null
@@ -0,0 +1,13 @@
+definition module GamePicture\r
+\r
+/**    Type definitions for handling bitmaps for referees (and footballers in the future).\r
+*/\r
+\r
+import StdBitmap\r
+\r
+::     Path                    :== String\r
+::     GamePicture             =       { img                   :: !Bitmap\r
+                                               , path                  :: !Path\r
+                                               }\r
+::     ActionPics              =       { refereePics   :: ![GamePicture]\r
+                                               }\r
diff --git a/src/Game/GamePicture.icl b/src/Game/GamePicture.icl
new file mode 100644 (file)
index 0000000..a68bddf
--- /dev/null
@@ -0,0 +1,3 @@
+implementation module GamePicture\r
+\r
+import StdBitmap\r
diff --git a/src/Game/Geometry.dcl b/src/Game/Geometry.dcl
new file mode 100644 (file)
index 0000000..ac456ad
--- /dev/null
@@ -0,0 +1,205 @@
+definition module Geometry\r
+\r
+/**    This module defines the part of the SoccerFun API that is concerned with the footballer dimensions.\r
+*/\r
+import StdEnvExt\r
+\r
+\r
+class    scale a               :: !Real !a -> a\r
+\r
+\r
+:: Metre\r
+m                                              :: !Real -> Metre                       // (m metre) is a distance in metres\r
+\r
+instance zero           Metre\r
+instance +              Metre\r
+instance -              Metre\r
+instance abs            Metre\r
+instance sign           Metre\r
+instance ~              Metre\r
+instance ==             Metre\r
+instance <              Metre\r
+instance toReal         Metre\r
+instance toString       Metre\r
+instance scale          Metre\r
+\r
+\r
+::     Position\r
+       =       {       px                      :: !Metre                                       // x-coordinate in plane\r
+               ,       py                      :: !Metre                                       // y-coordinate in plane\r
+               }\r
+::     Position3D\r
+       =       {       pxy                     :: !Position                            // position on plane\r
+               ,       pz                      :: !Metre                                       // height above plane\r
+               }\r
+\r
+instance zero           Position\r
+instance zero           Position3D\r
+instance ==             Position\r
+instance ==             Position3D\r
+instance toString       Position\r
+instance toString       Position3D\r
+\r
+class    toPosition     a :: !a -> Position\r
+class    fromPosition   a :: !Position -> a\r
+class    toPosition3D   a :: !a -> Position3D\r
+class    fromPosition3D a :: !Position3D -> a\r
+instance toPosition     (!Metre,!Metre)\r
+instance toPosition     Position\r
+instance toPosition     Position3D\r
+instance fromPosition   (!Metre,!Metre)\r
+instance fromPosition   Position\r
+instance fromPosition   Position3D\r
+instance toPosition3D   (!Metre,!Metre,!Metre)\r
+instance toPosition3D   Position\r
+instance toPosition3D   Position3D\r
+instance fromPosition3D (!Metre,!Metre,!Metre)\r
+instance fromPosition3D Position\r
+instance fromPosition3D Position3D\r
+\r
+dist                                   :: !a !b -> Metre | toPosition3D a & toPosition3D b\r
+\r
+\r
+::     Angle\r
+\r
+pi                                             :== 3.1415926535897932384       // (rad pi) is equivalant with (degree 180)\r
+\r
+rad                                            :: !Real -> Angle                       // (rad    x) is an angle of x radians (counter-clockwise)\r
+degree                                 :: !Int  -> Angle                       // (degree x) is an angle of x degrees (counter-clockwise)\r
+\r
+instance zero           Angle\r
+instance +              Angle\r
+instance -              Angle\r
+instance abs            Angle\r
+instance sign           Angle\r
+instance ~              Angle\r
+instance ==             Angle\r
+instance <              Angle\r
+instance toReal         Angle\r
+instance toInt          Angle\r
+instance toString       Angle\r
+instance scale          Angle\r
+instance sinus          Angle\r
+instance cosinus        Angle\r
+instance tangens        Angle\r
+instance arcsinus       Angle\r
+instance arccosinus     Angle\r
+instance arctangens     Angle\r
+\r
+/** orthogonal a\r
+               returns the left- and right- orthogonal angles to a\r
+*/\r
+orthogonal                             :: !Angle -> (!Angle,!Angle)\r
+\r
+/** bearing nose base target:\r
+               returns the smallest rotation angle needed for a player at @base having current direction @nose\r
+               to face @target.\r
+               The result is a value between ~pi and pi.\r
+*/\r
+bearing                                        :: !Angle !base !target -> Angle | toPosition base & toPosition target\r
+\r
+\r
+::     RVector\r
+       =       {       dx                      :: !Metre                                       // difference in px-coordinate\r
+               ,       dy                      :: !Metre                                       // difference in py-coordinate\r
+               }\r
+::     RVector3D\r
+       =       {       dxy                     :: !RVector\r
+               ,       dz                      :: !Metre\r
+               }\r
+\r
+class    toRVector a   :: !a -> RVector\r
+instance toRVector      Angle\r
+instance toRVector      Position\r
+\r
+/** size_vector   {dx, dy} = sqrt (    dx^2 +     dy^2)\r
+       size_vector3D {dxy,dz} = sqrt (dxy.dx^2 + dxy.dy^2 + dz^2)\r
+*/\r
+size_vector                            :: !RVector   -> Metre\r
+size_vector3D                  :: !RVector3D -> Metre\r
+\r
+instance +              RVector\r
+instance +              RVector3D\r
+instance -              RVector\r
+instance -              RVector3D\r
+instance zero           RVector\r
+instance zero           RVector3D\r
+instance one            RVector\r
+instance one            RVector3D\r
+instance ~              RVector\r
+instance ~              RVector3D\r
+instance scale          RVector\r
+instance scale          RVector3D\r
+\r
+\r
+/** move_point v p:\r
+               moves point p over vector v.\r
+       move_point3D v p:\r
+               moves point p over vector v.\r
+*/\r
+move_point                             :: !RVector   !Position   -> Position\r
+move_point3D                   :: !RVector3D !Position3D -> Position3D\r
+\r
+/** repell minimum_distance base pos:\r
+               if @pos is too close to @base, compute a new position that is at least @minimum_distance metres away from @base.\r
+       attract maximum_distance base pos:\r
+               if @pos is too far away from @base, compute a new position that is at most @maximum_distance metres away from @base.\r
+*/\r
+repell                                 :: !Metre !Position !Position -> Position\r
+attract                                        :: !Metre !Position !Position -> Position\r
+\r
+/**    point_to_rectangle (a,b) c\r
+               returns c if (point_in_rectangle (a,b) c) and the projected point c` of c that is exactly on the closest edge of \r
+               rectangle (a,b).\r
+*/\r
+point_to_rectangle             :: !(!Position,!Position) !Position -> Position\r
+\r
+/** point_in_rectangle (a,b) c\r
+               returns True iff point c is inside the rectangle determined by \r
+               the diagonal corner points a and b.\r
+*/\r
+point_in_rectangle             :: !(!Position,!Position) !Position -> Bool\r
+\r
+\r
+::     Velocity\r
+\r
+ms                                             :: !Real -> Velocity            // (ms metre-per-second) is a velocity\r
+\r
+instance zero           Velocity\r
+instance +              Velocity\r
+instance -              Velocity\r
+instance abs            Velocity\r
+instance sign           Velocity\r
+instance ~              Velocity\r
+instance ==             Velocity\r
+instance <              Velocity\r
+instance toReal         Velocity\r
+instance toString       Velocity\r
+instance scale          Velocity\r
+\r
+               \r
+::     Speed                                                                                   // speed of an object\r
+       =       {       direction       :: !Angle                                       // direction of object\r
+               ,       velocity        :: !Velocity                            // velocity of object\r
+               }\r
+::     Speed3D                                                                                 // speed of an object in space\r
+       =       {       vxy                     :: !Speed                                       // surface speed of object\r
+               ,       vz                      :: !Velocity                            // velocity in z-axis (positive: goes up; negative: goes down; zero: horizontally)\r
+               }\r
+\r
+instance zero           Speed\r
+instance zero           Speed3D\r
+instance ==             Speed\r
+instance ==             Speed3D\r
+instance toString       Speed\r
+instance toString       Speed3D\r
+\r
+class    toSpeed     a :: !a -> Speed\r
+class    fromSpeed   a :: !Speed -> a\r
+class    toSpeed3D   a :: !a -> Speed3D\r
+class    fromSpeed3D a :: !Speed3D -> a\r
+\r
+instance toSpeed        Speed3D\r
+instance fromSpeed      Speed3D\r
+instance toSpeed3D      Speed\r
+instance fromSpeed3D    Speed\r
diff --git a/src/Game/Geometry.icl b/src/Game/Geometry.icl
new file mode 100644 (file)
index 0000000..e9b29da
--- /dev/null
@@ -0,0 +1,223 @@
+implementation module Geometry
+
+import StdEnvExt
+
+:: Metre                               =   Metre !Real
+
+m                                              :: !Real -> Metre               // distance in metre
+m metre                                        = Metre metre
+
+instance zero           Metre                  where zero                          = Metre zero
+instance +              Metre                  where + (Metre m1)  (Metre m2)      = Metre (m1 + m2)
+instance -              Metre                  where - (Metre m1)  (Metre m2)      = Metre (m1 - m2)
+instance scale          Metre                  where scale k       (Metre m)       = Metre (k * m)
+instance abs            Metre                  where abs           (Metre m)       = Metre (abs m)
+instance sign           Metre                  where sign          (Metre m)       = sign m
+instance ~              Metre                  where ~             (Metre m)       = Metre (~m)
+instance ==             Metre                  where == (Metre m1) (Metre m2)      = m1 == m2
+instance <              Metre                  where <  (Metre m1) (Metre m2)      = m1 <  m2
+instance toReal         Metre                  where toReal        (Metre m)       = m
+instance toString       Metre                  where toString      (Metre m)       = m +++> " m."
+
+
+
+::     Velocity                        = MetrePerSecond !Real  // velocity in metre/second             
+
+ms                                             :: !Real -> Velocity
+ms v                                   = MetrePerSecond v
+
+instance zero           Velocity               where zero                                       = MetrePerSecond zero
+instance +              Velocity               where + (MetrePerSecond v1)  (MetrePerSecond v2) = MetrePerSecond (v1 + v2)
+instance -              Velocity               where - (MetrePerSecond v1)  (MetrePerSecond v2) = MetrePerSecond (v1 - v2)
+instance scale          Velocity               where scale k                (MetrePerSecond v)  = MetrePerSecond (k * v)
+instance abs            Velocity               where abs                    (MetrePerSecond v)  = MetrePerSecond (abs v)
+instance sign           Velocity               where sign                   (MetrePerSecond v)  = sign v
+instance ~              Velocity               where ~                      (MetrePerSecond v)  = MetrePerSecond (~v)
+instance ==             Velocity               where == (MetrePerSecond v1) (MetrePerSecond v2) = v1 == v2
+instance <              Velocity               where <  (MetrePerSecond v1) (MetrePerSecond v2) = v1 <  v2
+instance toReal         Velocity               where toReal                 (MetrePerSecond v)  = v
+instance toString       Velocity               where toString               (MetrePerSecond v)  = v +++> "m/s"
+
+instance zero           RVector                where zero                          = {dx = zero,             dy = zero}
+instance +              RVector                where + v1 v2                       = {dx = v1.dx + v2.dx,    dy = v1.dy + v2.dy}
+instance -              RVector                where - v1 v2                       = {dx = v1.dx - v2.dx,    dy = v1.dy - v2.dy}
+instance one            RVector                where one                           = {dx = m 1.0,            dy = m 1.0}
+instance scale          RVector                where scale k {dx, dy}              = {dx = scale k dx,       dy = scale k dy}
+instance ~              RVector                where ~ v                           = zero - v
+instance coords         RVector                where coords {dx,dy}                = [dx,dy]
+instance zero           RVector3D              where zero                          = {dxy = zero,            dz = zero}
+instance +              RVector3D              where + v1 v2                       = {dxy = v1.dxy + v2.dxy, dz = v1.dz + v2.dz}
+instance -              RVector3D              where - v1 v2                       = {dxy = v1.dxy - v2.dxy, dz = v1.dz - v2.dz}
+instance one            RVector3D              where one                           = {dxy = one,             dz = m 1.0}
+instance scale          RVector3D              where scale k {dxy,dz}              = {dxy = scale k dxy,     dz = scale k dz}
+instance ~              RVector3D              where ~ v                           = zero - v
+instance coords         RVector3D              where coords {dxy={dx,dy},dz}       = [dx,dy,dz]
+
+
+::     Angle                           = Radian !Real
+
+pi                                             :== 3.1415926535897932384
+
+rad                                            :: !Real -> Angle
+rad x                                  = Radian (normalize_radian x)
+
+degree                                 :: !Int -> Angle
+degree x                               = rad (toReal x * pi / 180.0)
+
+normalize_radian               :: !Real -> Real
+normalize_radian r
+| r < (~cycle)                 = normalize_radian (r + cycle)
+| r >   cycle                  = normalize_radian (r - cycle)
+| otherwise                            = r
+where
+       cycle                           = 2.0 * pi
+
+instance zero           Angle                  where zero                          = Radian zero
+instance +              Angle                  where + (Radian r1)  (Radian r2)    = Radian (normalize_radian (r1 + r2))
+instance -              Angle                  where - (Radian r1)  (Radian r2)    = Radian (normalize_radian (r1 - r2))
+instance scale          Angle                  where scale k        (Radian r)     = Radian (normalize_radian (k*r))
+instance abs            Angle                  where abs            (Radian r)     = Radian (abs r)
+instance sign           Angle                  where sign           (Radian r)     = sign r
+instance ~              Angle                  where ~              (Radian r)     = Radian (~r)
+instance ==             Angle                  where == (Radian r1) (Radian r2)    = r1 == r2
+instance <              Angle                  where <  (Radian r1) (Radian r2)    = r1 <  r2
+instance toReal         Angle                  where toReal         (Radian r)     = r
+instance toInt          Angle                  where toInt          (Radian r)     = toInt (r * 180.0 / pi)
+instance toString       Angle                  where toString       (Radian r)     = r +++> " rad"
+instance toRVector      Angle                  where toRVector      (Radian r)     = {dx = Metre (cos r), dy = Metre (sin r)}
+instance sinus          Angle                  where sinus          (Radian r)     = sin r
+instance cosinus        Angle                  where cosinus        (Radian r)     = cos r
+instance tangens        Angle                  where tangens        (Radian r)     = tan r
+instance arcsinus       Angle                  where arcsinus       x              = Radian (asin x)
+instance arccosinus     Angle                  where arccosinus     x              = Radian (acos x)
+instance arctangens     Angle                  where arctangens     x              = Radian (atan x)
+
+instance zero           Position               where zero                          = {px  = zero, py = zero}
+instance ==             Position               where == p1  p2                     = p1.px == p2.px && p1.py == p2.py
+instance coords         Position               where coords {px,py}                = [px,py]
+instance toString       Position               where toString {px, py}                    = "{px=" +++ toString px +++ ",py=" +++ toString py +++ "}"
+instance toRVector      Position               where toRVector p                   = {dx  = p.px, dy = p.py}
+instance zero           Position3D             where zero                          = {pxy = zero, pz = zero}
+instance ==             Position3D             where == p1  p2                     = p1.pxy == p2.pxy && p1.pz == p2.pz
+instance coords         Position3D             where coords {pxy={px,py},pz}       = [px,py,pz]
+instance toString       Position3D             where toString {pxy,pz}                    = "{pxy=" +++ toString pxy +++ ",pz=" +++ toString pz +++ "}"
+       
+instance toPosition     (!Metre,!Metre)        where toPosition     (x,y)          = {px=x,py=y}
+instance toPosition     Position               where toPosition     p2D            = p2D
+instance toPosition     Position3D             where toPosition     p3D            = p3D.pxy
+instance fromPosition   (!Metre,!Metre)        where fromPosition   p2D            = (p2D.px,p2D.py)
+instance fromPosition   Position               where fromPosition   p2D            = p2D
+instance fromPosition   Position3D             where fromPosition   p2D            = {zero & pxy=p2D}
+instance toPosition3D   (!Metre,!Metre,!Metre) where toPosition3D   (x,y,z)        = {pxy=toPosition (x,y),pz=z}
+instance toPosition3D   Position               where toPosition3D   p2D            = {zero & pxy=p2D}
+instance toPosition3D   Position3D             where toPosition3D   p3D            = p3D
+instance fromPosition3D (!Metre,!Metre,!Metre) where fromPosition3D p3D            = (p3D.pxy.px,p3D.pxy.py,p3D.pz)
+instance fromPosition3D Position               where fromPosition3D p3D            = p3D.pxy
+instance fromPosition3D Position3D             where fromPosition3D p3D            = p3D
+
+instance zero           Speed                  where zero                          = {direction=zero,velocity=zero}
+instance ==             Speed                  where == sp1 sp2                    = sp1.direction == sp2.direction && sp1.velocity == sp2.velocity
+instance toString       Speed                  where toString {direction,velocity} = "{direction=" +++ toString direction +++ ",velocity=" +++ toString velocity +++ "}"
+instance toSpeed3D      Speed                  where toSpeed3D   s                 = {zero & vxy=s}
+instance zero           Speed3D                where zero                          = {vxy=zero,vz=zero}
+instance ==             Speed3D                where == sp1 sp2                    = sp1.vxy == sp2.vxy && sp1.vz == sp2.vz
+instance toString       Speed3D                where toString {vxy,vz}                    = "{vxy=" +++ toString vxy +++ ",vz=" +++ toString vz +++ "}"
+instance toSpeed        Speed3D                where toSpeed     s                 = s.vxy
+instance fromSpeed      Speed3D                where fromSpeed   s                 = {zero & vxy=s}
+instance fromSpeed3D    Speed                  where fromSpeed3D s                 = s.vxy
+
+class    coords a                              :: !a -> [Metre]
+
+move_point                                             :: !RVector !Position -> Position
+move_point {dx,dy} {px,py}             = {px=px+dx,py=py+dy}
+
+move_point3D                                   :: !RVector3D !Position3D -> Position3D
+move_point3D {dxy,dz} {pxy,pz} = {pxy=move_point dxy pxy,pz=pz+dz}
+
+repell                                                 :: !Metre !Position !Position -> Position
+repell minimum_distance base pos
+| d == zero                                            = move_point {zero & dx=minimum_distance} pos
+| d < minimum_distance                 = move_point v` base //move_point (v` - v) pos
+| otherwise                                            = pos
+where
+       d                                                       = dist base pos
+       v                                                       = {dx = pos.px - base.px, dy = pos.py - base.py}
+       v`                                                      = scale ((toReal minimum_distance) / (toReal d)) v
+
+attract                                                        :: !Metre !Position !Position -> Position
+attract maximum_distance base pos
+| d > maximum_distance                 = move_point v` base
+| otherwise                                            = pos
+where
+       d                                                       = dist base pos
+       v                                                       = {dx = pos.px - base.px, dy = pos.py - base.py}
+       v`                                                      = scale ((toReal maximum_distance) / (toReal d)) v
+
+between_points                                 :: !(!Position,!Position) !Position -> Bool
+between_points (a,b) c                 = point_in_rectangle (a,b) c && (toReal dcx) / (toReal dcy) == (toReal dx) / (toReal dy)
+where
+       [min_x,max_x:_]                         = sort [a.px,b.px]
+       [min_y,max_y:_]                         = sort [a.py,b.py]
+       (dx, dy)                                        = (a.px - b.px, a.py - b.py)
+       (dcx,dcy)                                       = (a.px - c.px, a.py - c.py)
+
+point_in_rectangle                             :: !(!Position,!Position) !Position -> Bool
+point_in_rectangle (a,b) c             = isbetween c.px min_x max_x && isbetween c.py min_y max_y
+where
+       (min_x,max_x)                           = minmax (a.px,b.px)
+       (min_y,max_y)                           = minmax (a.py,b.py)
+
+point_to_rectangle                             :: !(!Position,!Position) !Position -> Position
+point_to_rectangle   (a,b) c
+| point_in_rectangle (a,b) c   = c
+| otherwise                                            = toPosition c`
+where
+       (min_x,max_x)                           = minmax (a.px,b.px)
+       (min_y,max_y)                           = minmax (a.py,b.py)
+       left                                            = c.px <= min_x
+       right                                           = c.px >= max_x
+       above                                           = c.py >= max_y
+       below                                           = c.py <= min_y
+       
+       c` | left  && above                     = (min_x,max_y)
+          | right && above                     = (max_x,max_y)
+          | left  && below                     = (min_x,min_y)
+          | right && below             = (max_x,min_y)
+          | above                                      = (c.px, max_y)
+          | below                                      = (c.px, min_y)
+          | left                                       = (min_x,c.py )
+          | right                                      = (max_x,c.py )
+          | otherwise                          = abort ("unsuspected error; please rotate with angles between pi and -pi\n")
+
+size_vector                                            :: !RVector -> Metre
+size_vector v                                  = Metre (dist` v z)
+where z :: RVector; z = zero
+
+size_vector3D                                  :: !RVector3D -> Metre
+size_vector3D v                                        = Metre (dist` v z)
+where z :: RVector3D; z = zero
+
+dist                                                   :: !a !b -> Metre | toPosition3D a & toPosition3D b
+dist a b                                               = Metre (dist` (toPosition3D a) (toPosition3D b))
+
+dist`                                                  :: !a !b -> Real | coords a & coords b
+dist` cs1 cs2                                  = sqrt (sum [ (toReal c1 - toReal c2)^2.0 \\ c1 <- coords cs1 & c2 <- coords cs2 ])
+
+orthogonal                                             :: !Angle -> (!Angle,!Angle)
+orthogonal a                                   = (a + rad (0.25*pi), a - rad (0.25*pi))
+
+px_bearing                                             :: !base !target -> Angle | toPosition base & toPosition target
+px_bearing base target
+| v.dx >= zero && v.dy >= zero = Radian base_angle                     // 1st quadrant
+| v.dx <= zero && v.dy >= zero = Radian (pi-base_angle)        // 2nd quadrant
+| v.dx <= zero && v.dy <= zero = Radian (base_angle-pi)        // 3rd quadrant
+| v.dx >= zero && v.dy <= zero = Radian (~base_angle)          // 4th quadrant
+where
+       pbase                                           = toPosition base
+       ptarget                                         = toPosition target
+       v                                                       = {dx = ptarget.px - pbase.px, dy = ptarget.py - pbase.py}
+       d                                                       = toReal (dist pbase ptarget)
+       base_angle                                      = acos ((toReal (abs v.dx)) / d)
+
+bearing                                                        :: !Angle !base !target -> Angle | toPosition base & toPosition target
+bearing angle base target              = px_bearing base target - angle
diff --git a/src/Game/Referee.dcl b/src/Game/Referee.dcl
new file mode 100644 (file)
index 0000000..fd965bf
--- /dev/null
@@ -0,0 +1,36 @@
+definition module Referee\r
+\r
+/**    The referee data type, and all available referees within Soccer-Fun.\r
+*/\r
+import Footballer, GamePicture, matchGame\r
+\r
+::     Referee                                 = E.memory:\r
+                                                               { name                  :: !String\r
+                                                               , brain                 :: !Brain (RefereeAI RefereeOutput (memory,RandomSeed)) memory\r
+                                                               , refActionPics :: ![Path]\r
+                                                               }\r
+::     RefereeAI  msg memory   :== (RefereeInput,memory) -> (msg,memory)\r
+::     RefereeAI` msg                  :== RefereeInput -> msg\r
+::     RefereeInput                    =       { playingTime   :: !PlayingTime                 // the duration of an entire match\r
+                                                               , unittime              :: !TimeUnit                    // the time unit of a single simulation step\r
+                                                               , theBall               :: !FootballState               // the whereabouts of the football\r
+                                                               , playingHalf   :: !Half                                // first or second half; team1 is team that starts game on West; team2 is other team\r
+                                                               , team1                 :: !Team                                // team1\r
+                                                               , team2                 :: !Team                                // team2\r
+                                                               , lastContact   :: !Maybe FootballerID  // last player who has played the ball\r
+                                                               }\r
+::     RefereeOutput                   :== [RefereeAction]\r
+\r
+instance nameOf Referee\r
+\r
+defaultReferee         :: Referee\r
+\r
+allAvailableReferees:: [FootballField -> Referee]\r
+defaultImage           :: !Match !RefereeAction !*env -> (!Bitmap,!*env)       | FileSystem env\r
+defaultSoundFile       :: !RefereeAction -> Maybe String\r
+\r
+/**    Wrapper functions for simpler referee brains:\r
+*/\r
+randomlessRefereeAI    :: (RefereeAI  msg memory)              -> RefereeAI msg (memory,RandomSeed)\r
+amnesiaRefereeAI       :: (RefereeAI  msg RandomSeed)  -> RefereeAI msg (memory,RandomSeed)\r
+witlessRefereeAI       :: (RefereeAI` msg)                             -> RefereeAI msg (memory,RandomSeed)\r
diff --git a/src/Game/Referee.icl b/src/Game/Referee.icl
new file mode 100644 (file)
index 0000000..2f88d83
--- /dev/null
@@ -0,0 +1,82 @@
+implementation module Referee
+
+import StdEnvExt
+import matchGame
+import Umpire
+//     When coding for all referees, include following modules:
+import RefereeCoach_Rounds_Assignment
+import RefereeCoach_Slalom_Assignment
+import RefereeCoach_Passing_Assignment
+import RefereeCoach_DeepPass_Assignment
+import RefereeCoach_Keeper_Assignment
+
+allAvailableReferees   :: [FootballField -> Referee]
+allAvailableReferees   = [ umpire ]
+//     When coding for all referees, use following list:
+                                                       ++
+                                                 [ RefereeCoach_Rounds
+                                                 , RefereeCoach_Slalom
+                                                 , RefereeCoach_Passing
+                                                 , RefereeCoach_DeepPass
+                                                 , RefereeCoach_Keeper
+                                                 ]
+
+instance nameOf Referee where nameOf {Referee | name} = name
+
+defaultReferee                 :: Referee
+defaultReferee                 = { name                        = "Default"
+                                                 , brain                       = {memory = Void,ai = \(_,st) -> ([ContinueGame],st)}
+                                                 , refActionPics       = []
+                                                 }
+
+defaultImage                   :: !Match !RefereeAction !*env -> (!Bitmap,!*env)       | FileSystem env
+defaultImage match action env
+# bitmapf                              = case action of
+                                                       (ReprimandPlayer  _ r)  = "ivanov_" +++ reprimandf r +++ ".bmp"
+                                                       (Hands            _)    = "hands.bmp"
+                                                       (OwnBallIllegally _)    = "ivanov_badluck.bmp"
+                                                       (TellMessage      _)    = "ivanov_look.bmp"
+                                                       (DirectFreeKick   _ p)  = ivanovf (p.px < zero)
+                                                       (GoalKick         h)    = ivanovf (h == West)
+                                                       (Corner           h _)  = ivanovf (h == West)
+                                                       (ThrowIn          h _)  = ivanovf (h == West)
+                                                       (Penalty          h)    = ivanovf (h == West)
+                                                       (Advantage        _)    = "ivanov_badluck.bmp"
+                                                       _                                               = "ivanov_fluit.bmp"
+= case openBitmap ("afbeeldingen\\" +++ bitmapf) env of
+       (Just bm,env)           = (bm,env)
+       nothing                         = abort "defaultImage: unable to load default picture.\n"
+where
+       reprimandf r            = case r of
+                                                       Warning    = "warning"
+                                                       YellowCard = "yellow"
+                                                       RedCard    = "red"
+       ivanovf left            = "ivanov_wijst_" +++ if left "links" "rechts" +++ ".bmp"
+
+defaultSoundFile               :: !RefereeAction -> Maybe String
+defaultSoundFile action        = if (soundfilename == "") Nothing (Just ("sound\\"+++soundfilename))
+where
+       soundfilename           = defaultSoundFileName action
+       
+       defaultSoundFileName (Hands _)                                  = "stopBecauseOfFoul.wav"
+       defaultSoundFileName (TackleDetected _)                 = "tackles_ed.wav"
+       defaultSoundFileName (DangerousPlay _)                  = "tackles_ed.wav"
+       defaultSoundFileName GameOver                                   = "endGameOrHalf.wav"
+       defaultSoundFileName (GameCancelled _)                  = "endGameOrHalf.wav"
+       defaultSoundFileName EndHalf                                    = "endGameOrHalf.wav"
+       defaultSoundFileName (Offside _)                                = "offside.wav"
+       defaultSoundFileName (GoalKick _)                               = "ballOut.wav"
+       defaultSoundFileName (Corner _ _)                               = "ballOut.wav"
+       defaultSoundFileName (ThrowIn _ _)                              = "ballOut.wav"
+       defaultSoundFileName (Goal _)                                   = "CenterKick.wav"
+       defaultSoundFileName (OwnBallIllegally _)               = "wrongPosition2restartFrom.wav"
+       defaultSoundFileName _                                                  = ""
+
+randomlessRefereeAI            :: (RefereeAI msg memory) -> RefereeAI msg (memory,RandomSeed)
+randomlessRefereeAI f  = \(input,(memory,seed))        = let (decisions,memory`) = f (input,memory) in (decisions,(memory`,seed))
+
+amnesiaRefereeAI               :: (RefereeAI msg RandomSeed) -> RefereeAI msg (memory,RandomSeed)
+amnesiaRefereeAI f             = \(input,(memory,seed))        = let (decisions,seed`) = f (input,seed) in (decisions,(memory,seed`))
+
+witlessRefereeAI               :: (RefereeAI` msg) -> RefereeAI msg (memory,RandomSeed)
+witlessRefereeAI f             = \(input,state)                        = (f input,state)
diff --git a/src/Game/Team.dcl b/src/Game/Team.dcl
new file mode 100644 (file)
index 0000000..5d9158d
--- /dev/null
@@ -0,0 +1,25 @@
+definition module Team\r
+\r
+/** This module defines the Soccer-Fun API that is concerned with teams.\r
+       All available teams are collected in this module (allAvailableTeams).\r
+*/\r
+import Footballer\r
+\r
+allAvailableTeams      :: [Home FootballField -> Team]\r
+\r
+::     Team                    :== [Footballer]                // the fielders are supposed to have different numbers, and all not equal to 1\r
+\r
+instance nameOf        Team\r
+\r
+validateTeam           :: !Team -> Team\r
+isValidTeam                    :: !Team -> Bool\r
+allPlayersAtHome       :: !FootballField !Home !Team -> Bool\r
+replaceInTeam          :: ![Footballer] !Team -> Team\r
+getTeam                                :: !ClubName ![Team] -> Team\r
+\r
+class mirror a         :: !FootballField !a -> a\r
+instance mirror [a] | mirror a\r
+instance mirror Footballer\r
+instance mirror Position\r
+instance mirror Speed\r
+instance mirror Angle\r
diff --git a/src/Game/Team.icl b/src/Game/Team.icl
new file mode 100644 (file)
index 0000000..3b5dcb7
--- /dev/null
@@ -0,0 +1,85 @@
+implementation module Team
+
+import StdEnvExt
+import Footballer
+/*     Import all standard teams: */
+import TeamMiniEffie
+import Team_Opponent_Slalom_Assignment
+import Team_Opponent_Passing_Assignment
+import Team_Opponent_DeepPass_Assignment
+import Team_Opponent_Keeper_Assignment
+import Team_Student_Rounds_Assignment
+import Team_Student_Slalom_Assignment
+import Team_Student_Passing_Assignment
+import Team_Student_DeepPass_Assignment
+import Team_Student_Keeper_Assignment
+
+allAvailableTeams                                      :: [Home FootballField -> Team]
+allAvailableTeams                                      = [ Team_MiniEffies
+                                                                         , Team_Student_Rounds
+                                                                         , Team_Student_Slalom
+                                                                         , Team_Student_Passing
+                                                                         , Team_Student_DeepPass
+                                                                         , Team_Student_Keeper
+                                                                         , Team_Opponent_Slalom
+                                                                         , Team_Opponent_Passing
+                                                                         , Team_Opponent_DeepPass
+                                                                         , Team_Opponent_Keeper
+                                                                         ]
+
+instance nameOf Team where     nameOf players
+                                                                       = case players of
+                                                                               [fb:_]          = nameOf fb.playerID
+                                                                               none            = abort "nameOf[Team]: applied to empty team.\n"
+
+validateTeam                                           :: !Team -> Team
+validateTeam team                                      = map validateFootballer team
+where
+       validateFootballer                              :: !Footballer -> Footballer
+       validateFootballer fb=:{length} = {fb & length  = setbetween length min_length max_length
+                                                                             , stamina = max_stamina
+                                                                             , health  = max_health
+                                                                         }
+
+isValidTeam :: !Team -> Bool
+isValidTeam team                                       = length clubNames == 1
+                                                                               &&
+                                                                         (isEmpty keepers || isValidKeeper (hd keepers))
+                                                                               &&
+                                                                         all isValidPlayer players
+                                                                           &&
+                                                                         sort (map nrOf players) == sort (removeDup (map nrOf players))
+                                                                           &&
+                                                                         not (isMember 1 (map nrOf fielders))
+where
+       (keepers,fielders)                              = spanfilter isKeeper team
+       clubNames                                               = removeDup (map clubOf players)
+       clubName                                                = hd clubNames
+       players                                                 = keepers ++ fielders
+       clubOf fb                                               = fb.playerID.clubName
+       nrOf   fb                                               = fb.playerID.playerNr
+       isValidKeeper fb                                = fb.playerID == {clubName=clubName,playerNr=1}
+       isValidPlayer fb                                = clubOf fb == clubName
+
+allPlayersAtHome                                       :: !FootballField !Home !Team -> Bool
+allPlayersAtHome field home team       = all atHome team
+where
+       atHome                                                  = if (home == West) (\player -> player.Footballer.pos.px <= zero)
+                                                                               (\player -> player.Footballer.pos.px >= zero)
+
+replaceInTeam                                          :: ![Footballer] !Team -> Team
+replaceInTeam fbs team                         = removeMembers team fbs ++ fbs
+
+getTeam                                                                :: !ClubName ![Team] -> Team
+getTeam cn teams                                       = case [team \\ team<-teams | nameOf team==cn] of
+                                                                               [team:_]                                = team
+                                                                               _                                               = abort ("Team " <+++ cn <+++ " does not seem to exist.\n")
+
+instance mirror [a] | mirror a         where mirror field as           = map (mirror field) as
+instance mirror Footballer                     where mirror field fb           = {fb & pos   = mirror field fb.pos
+                                                                             , nose  = mirror field fb.nose
+                                                                             , speed = mirror field fb.speed
+                                                                         }
+instance mirror Position                       where mirror field pos          = {pos & px = ~pos.px}
+instance mirror Speed                          where mirror field speed        = {speed & direction = mirror field speed.direction}
+instance mirror Angle                          where mirror field angle        = rad pi - angle
diff --git a/src/Game/matchControl.dcl b/src/Game/matchControl.dcl
new file mode 100644 (file)
index 0000000..7688634
--- /dev/null
@@ -0,0 +1,41 @@
+definition module matchControl
+
+/**    This module defines the logical behavior of Soccer-Fun. 
+       The core function is stepMatch, which computes a single, complete transition of a match.
+*/
+import Referee
+
+::     Match                   = { team1               :: !Team                                // team1
+                                         , team2               :: !Team                                // team2
+                                         , theBall             :: !FootballState               // the whereabouts of the football
+                                         , theField    :: !FootballField               // the football field
+                                         , theReferee  :: !Referee                             // the referee
+                                         , playingHalf :: !Half                                // first half or second half team1 plays West at first half and East at second half
+                                         , playingTime :: !PlayingTime                 // todo: add a boolean gameOver, playingtime will not walk back to zero and its up to the referee at which time he is to end the game
+                                         , score               :: !Score                               // the score
+                                         , nextRandomP :: !St RandomSeed P             // generate pseudo random value
+                                         , seed                :: !RandomSeed                  // random seed for generating pseudo random values
+                                         , unittime    :: !TimeUnit                    // the time unit of a single simulation step
+                                         , lastContact :: !Maybe FootballerID  // the player who has the ball the last time (ball can have bounced against this player)
+                                         }
+::     PlayingTime             :== Minutes
+::     Score                   :== (!NrOfGoals,!NrOfGoals)                             // (goals by Team1, goals by Team2)
+::     NrOfGoals               :== Int                                                                 // zero <= nr of goals
+
+::     TimeUnit                :== Seconds                                                             // time unit in sec.
+::     Seconds
+
+s                                      :: !Real -> Seconds                                             // (s x) represents x seconds of time
+instance zero          Seconds
+instance ==                    Seconds
+instance <                     Seconds
+instance +                     Seconds
+instance -                     Seconds
+instance minutes       Seconds
+instance toReal     Seconds
+instance scale      Seconds
+instance toString   Seconds
+
+doSoccerFun                    :: !*World -> *World
+setMatchStart          :: !Team !Team !FootballField !Referee !PlayingTime !RandomSeed -> Match
+stepMatch                      :: !Match -> (!(![RefereeAction],!AssocList FootballerID FootballerAction),!Match)
diff --git a/src/Game/matchControl.icl b/src/Game/matchControl.icl
new file mode 100644 (file)
index 0000000..e0505c0
--- /dev/null
@@ -0,0 +1,557 @@
+implementation module matchControl\r
+\r
+import StdEnvExt\r
+import Gui2D                           // we choose the 2D GUI version of SoccerFun\r
+import Referee\r
+\r
+::     Seconds = Seconds !Real\r
+\r
+s :: !Real -> Seconds                                          // (s x) represents x seconds of time\r
+s x                                                                                    = Seconds x\r
+\r
+instance zero      Seconds where zero                                                          = Seconds zero\r
+instance ==        Seconds where ==        (Seconds s1) (Seconds s2)= s1 == s2\r
+instance <         Seconds where <         (Seconds s1) (Seconds s2)= s1  < s2\r
+instance +         Seconds where +         (Seconds s1) (Seconds s2)= Seconds (s1  + s2)\r
+instance -         Seconds where -         (Seconds s1) (Seconds s2)= Seconds (s1  - s2)\r
+instance minutes   Seconds where minutes   (Seconds s)                         = minutes (s/60.0)\r
+instance toReal    Seconds where toReal    (Seconds s)              = s\r
+instance scale     Seconds where scale     k            (Seconds s) = Seconds (k * s)\r
+instance toString  Seconds where toString  (Seconds s)                         = s +++> " sec."\r
+\r
+doSoccerFun :: !*World -> *World\r
+doSoccerFun world                                                      = SoccerFunGUI2D world\r
+\r
+setMatchStart :: !Team !Team !FootballField !Referee !PlayingTime !RandomSeed -> Match\r
+setMatchStart fstTeam sndTeam field referee time rs\r
+       = { team1                                                               = validateTeam fstTeam\r
+         , team2                                                               = validateTeam sndTeam\r
+         , theBall                                                             = Free zero\r
+         , theField                                                    = field\r
+         , theReferee                                                  = referee\r
+         , playingHalf                                                 = FirstHalf\r
+         , playingTime                                                 = time\r
+         , unittime                                                    = s 0.05\r
+         , score                                                               = (0,0)\r
+         , nextRandomP                                                 = nextRandomP\r
+         , seed                                                                = rs\r
+         , lastContact                                                 = Nothing\r
+         }\r
+\r
+stepMatch :: !Match -> (!(![RefereeAction],!AssocList FootballerID FootballerAction),!Match)\r
+stepMatch match\r
+# (refereeActions,  match)                                     = refereeTurn                                     match\r
+# match                                                                                = performRefereeActions refereeActions            match\r
+# (intendedActions, match)                                     = playersThink          refereeActions            match\r
+# (okActions,       match)                                     = successfulActions     intendedActions           match\r
+# match                                                                                = doFootballerActions   intendedActions okActions match\r
+# match                                                                                = moveFootball                                    match\r
+# match                                                                                = advanceTime                                     match\r
+= ((refereeActions,okActions),match)\r
+where\r
+/*     refereeTurn match\r
+               determines whether the rules of soccer are adhered to and yields a list of referee actions.\r
+*/     refereeTurn :: !Match -> (![RefereeAction],!Match)\r
+       refereeTurn match=:{theReferee=referee=:{Referee | brain=brain=:{ai,memory}},theBall,playingHalf,team1,team2,playingTime,unittime,seed,lastContact}\r
+                                                                                       = (refereeActions,{match & theReferee=new_referee,seed=new_seed})\r
+       where\r
+               (refereeActions,(memory`,new_seed))     = ai ({RefereeInput | playingTime = playingTime\r
+                                                                       , unittime    = unittime\r
+                                                                       , theBall     = theBall\r
+                                                                       , playingHalf = playingHalf\r
+                                                                       , team1       = team1\r
+                                                                       , team2       = team2\r
+                                                                       , lastContact = lastContact\r
+                                                         }\r
+                                                        ,(memory,seed)\r
+                                                        )\r
+               new_referee                                                     = {Referee | referee & brain={Brain | brain & memory=memory`}}\r
+               \r
+/*     performRefereeActions refereeActions match\r
+               performs for each football player in match his succeededAction, informs them about the referee actions, and moves the ball. \r
+*/     performRefereeActions :: ![RefereeAction] !Match -> Match\r
+       performRefereeActions refActions match  = foldl doRefereeEvent match refActions\r
+       where\r
+               doRefereeEvent :: !Match !RefereeAction -> Match\r
+               doRefereeEvent theMatch=:{Match | playingHalf,theField,team1,team2} refereeAction\r
+               | isAlterMatchBallAndTeams                      = {Match | theMatch & theBall=Free (mkFootball pos zero),lastContact=Nothing}\r
+               | isProgressEvent                                       = gameProgress theMatch\r
+               | isDisplaceTeamsEvent                          = {Match | theMatch & team1=map (displacePlayer ds) team1,team2=map (displacePlayer ds) team2}\r
+               | isReprimandEvent                                      = let (team1`,team2`)           = reprimandPlayer rep (team1,team2) in {Match | theMatch & team1=team1`,team2=team2`}\r
+               | otherwise                                                     = theMatch\r
+               where\r
+                       (isAlterMatchBallAndTeams,pos)  = case refereeAction of\r
+                                                                                               DirectFreeKick _ pos    = (True,pos)\r
+                                                                                               ThrowIn        _ pos    = (True,pos)\r
+                                                                                               Corner         _ _              = (True,fromJust (getKickPos theField playingHalf refereeAction))\r
+                                                                                               GoalKick       _                = (True,fromJust (getKickPos theField playingHalf refereeAction))\r
+                                                                                               Penalty        _                = (True,fromJust (getKickPos theField playingHalf refereeAction))\r
+                                                                                               CenterKick     _                = (True,fromJust (getKickPos theField playingHalf refereeAction))\r
+                                                                                               otherwise                               = (False,undef)\r
+                       (isProgressEvent,gameProgress)  = case refereeAction of\r
+                                                                                               GameOver                                = (True,\m                -> {Match | m & playingTime=zero})\r
+                                                                                               GameCancelled mt                = (True,\m                -> {Match | m & playingTime=zero,score=case mt of\r
+                                                                                                                                                                                                                   Nothing   = (0,0)\r
+                                                                                                                                                                                                                   Just West = if (playingHalf==FirstHalf) (1,0) (0,1)\r
+                                                                                                                                                                                                                   just_east = if (playingHalf==FirstHalf) (0,1) (1,0)\r
+                                                                                                                                                                            })\r
+                                                                                               AddTime t                               = (True,\m                -> {Match | m & playingTime=m.Match.playingTime+t})\r
+                                                                                               EndHalf                                 = (True,\m                -> {Match | m & playingHalf=SecondHalf})\r
+                                                                                               Goal    h                               = (True,\m=:{score=(w,e)} -> {Match | m & score=if (h==West && playingHalf==FirstHalf || h==East && playingHalf==SecondHalf) (w+1,e) (w,e+1)})\r
+                                                                                               otherwise                               = (False,undef)\r
+                       (isDisplaceTeamsEvent,ds)               = case refereeAction of\r
+                                                                                               DisplacePlayers ds              = (True, ds)\r
+                                                                                               otherwise                               = (False,undef)\r
+                       (isReprimandEvent,rep)                  = case refereeAction of\r
+                                                                                               ReprimandPlayer p r             = (True, (p,r))\r
+                                                                                               otherwise                               = (False,undef)\r
+                       \r
+                       displacePlayer :: !Displacements !Footballer -> Footballer\r
+                       displacePlayer displacements fb = case lookup fb.playerID displacements of\r
+                                                                                               Just pos        = {fb & pos=pos}\r
+                                                                                               nothing         = fb\r
+                       \r
+                       reprimandPlayer :: !(!FootballerID,!Reprimand) !(![Footballer],![Footballer]) -> (![Footballer],![Footballer])\r
+                       reprimandPlayer (playerID,RedCard) (team1,team2)\r
+                                                                                       = splitAt (nr_players_1 - if (playerID.clubName == club1) 1 0) (uneq1++uneq2)\r
+                       where\r
+                               club1                                           = nameOf team1\r
+                               (uneq1,_,uneq2)                         = break1 (identify_player playerID) (team1++team2)\r
+                               nr_players_1                            = length team1\r
+                       reprimandPlayer _ teams                 = teams                 \r
+       \r
+/*     playersThink match\r
+               lets every footballer player conjure an initiative.\r
+*/     playersThink :: ![RefereeAction] !Match -> (!AssocList FootballerID FootballerAction,!Match)\r
+       playersThink refereeActions match=:{Match | theBall,team1,team2}\r
+                                                                                       = (intendedActions,new_match)\r
+       where\r
+               actionsOfTeam1                                          = map (think refereeActions theBall team2) (singleOutElems team1)\r
+               actionsOfTeam2                                          = map (think refereeActions theBall team1) (singleOutElems team2)\r
+               new_match                                                       = {Match | match & team1 = map snd actionsOfTeam1,team2 = map snd actionsOfTeam2}\r
+               intendedActions                                         = [(playerID,action) \\ (action,{playerID}) <- actionsOfTeam1 ++ actionsOfTeam2]\r
+               \r
+               think :: ![RefereeAction] !FootballState ![Footballer] !(!Footballer,![Footballer]) -> (!FootballerAction,!Footballer)\r
+               think refereeActions ballstate opponents (me=:{Footballer | brain=brain=:{ai,memory}},ownTeam)\r
+               # (action,memory)                                       = ai ({referee=refereeActions,football=ballstate,others=ownTeam ++ opponents,me=me},memory)\r
+               # me                                                            = {Footballer | me & brain = {Brain | brain & memory=memory}}\r
+               = (action,me)\r
+               \r
+/*     successfulActions intendedActions match\r
+               removes all failing intended actions, and returns the list of remaining succeeding actions.\r
+               Players who are successfully tackled fail their action.\r
+               Players who are (still) lying on the ground fail their action.\r
+               At most one action of {GainBall, KickBall, HeadBall, CatchBall} succeeds.\r
+               If another player has successfully played the ball then his/her playerID is registered in Match.\r
+*/     successfulActions :: !(AssocList FootballerID FootballerAction) !Match -> (!AssocList FootballerID FootballerAction,!Match)\r
+       successfulActions intendedActions match=:{seed,lastContact,nextRandomP,team1,team2,theBall}\r
+       # otherActions                                                  = filter (\(playerID,_) -> not (isMember playerID groundVictims)) intendedActions\r
+       # (tackleActions,otherActions)                  = spanfilter (isFootballerTackle o snd) intendedActions\r
+       # (okTackleActions,seed)                                = selectTackleActions tackleActions seed\r
+       # tackleVictims                                                 = [victim \\ (_,Tackle victim _) <- okTackleActions]\r
+       # otherActions                                                  = filter (\(playerID,action) -> not (isMember playerID tackleVictims)) otherActions\r
+       # (ballActions,otherActions)                    = spanfilter (isActionOnBall o snd) otherActions\r
+       # (okBallAction,seed)                                   = selectBallAction ballActions seed\r
+       # (okActions,newContact)                                = case okBallAction of\r
+                                                                                            Just (player,action) = ([(player,action):okTackleActions ++ otherActions],Just player)\r
+                                                                                            nope                 = (                 okTackleActions ++ otherActions ,lastContact)\r
+       = (okActions,{match & seed=seed, lastContact=newContact})\r
+       where\r
+               all_players                                                     = team1 ++ team2\r
+               ball                                                            = getFootball theBall all_players\r
+               groundVictims                                           = [playerID \\ {playerID,effect=Just (OnTheGround frames)} <- all_players | frames >= 0]\r
+               \r
+       /*      selectBallAction picks at most one action of {GainBall, KickBall, HeadBall, CatchBall} intentions.\r
+               The association list is assumed to contain only these actions.\r
+       */      selectBallAction :: !(AssocList FootballerID FootballerAction) !RandomSeed -> (!Maybe (FootballerID,FootballerAction),!RandomSeed)\r
+               selectBallAction intendedActions seed\r
+               # (ps,seed)                                                     = iterateStn (length intendedActions) nextRandomP seed\r
+               = selectMostProbableAction [ (successOfAction action (if (p==one) p (makeRandomRealistic p)),action) \\ action <- intendedActions & p <- ps ] seed\r
+               where\r
+                       successOfAction :: !(!FootballerID,!FootballerAction) !P -> P\r
+                       successOfAction (who,action) p  = me.stamina * me.health * p * success_of_action\r
+                       where\r
+                               success_of_action                       = if (isGainBall  action && ballGainable  && ballAtGainSpeed)  success_gaining\r
+                                                                                        (if (isCatchBall action && ballCatchable && ballAtCatchSpeed) success_catching\r
+                                                                                        (if (isKickBall  action && ballKickable)                      success_kicking\r
+                                                                                        (if (isHeadBall  action && ballHeadable)                      success_heading\r
+                                                                                                                                                          zero\r
+                                                                                        )))\r
+                               me                                                      = find1 (identify_player who) all_players\r
+                               mySkills                                        = skillsAsList me\r
+                               length                                          = me.length\r
+                               iGainWell                                       = isMember Gaining  mySkills\r
+                               iKickWell                                       = isMember Kicking  mySkills\r
+                               iHeadWell                                       = isMember Heading  mySkills\r
+                               iCatchWell                                      = isMember Catching mySkills\r
+                               ballGainable                            = d_player_ball <= maxGainReach  me && ball_height <= scale 0.8 length + scale (if iGainWell  0.2 0.0) length\r
+                               ballKickable                            = d_player_ball <= maxKickReach  me && ball_height <= scale 0.4 length + scale (if iKickWell  0.6 0.0) length\r
+                               ballCatchable                           = d_player_ball <= maxCatchReach me && ball_height <=           length + scale (if iCatchWell 1.0 0.5) length\r
+                               ballHeadable                            = d_player_ball <= maxHeadReach  me && ball_height <=           length + scale (if iHeadWell  0.5 0.0) length && ball_height >= scale 0.8 length\r
+                               ballAtGainSpeed                         = d_velocity    <= maxGainVelocityDifference  me d_player_ball\r
+                               ballAtCatchSpeed                        = d_velocity    <= maxCatchVelocityDifference me d_player_ball\r
+                               d_speed                                         = {zero & dxy = scale (toReal me.speed.velocity) (toRVector me.speed.direction)}\r
+                                                                                               -\r
+                                                                                         {dxy = scale (toReal ball.ballSpeed.vxy.velocity) (toRVector ball.ballSpeed.vxy.direction),dz = m (toReal ball.ballSpeed.vz)}\r
+                               d_velocity                                      = ms (toReal (size_vector3D d_speed))\r
+                               ball_height                                     = ball.ballPos.pz\r
+                               d_player_ball                           = dist me ball\r
+                               others_with_ball                        = case theBall of\r
+                                                                                           GainedBy playerID = if (playerID <> who) (filter (identify_player playerID) all_players) []\r
+                                                                                           free              = []\r
+                               other_has_ball                          = not (isEmpty others_with_ball)\r
+                               otherDribblesWell                       = isMember Dribbling (skillsAsList (hd others_with_ball))\r
+                               success_gaining                         = if (ballIsFree theBall)   (if iGainWell 0.95 0.8)\r
+                                                                                        (if  other_has_ball        (if iGainWell 0.75 0.3 * if otherDribblesWell 0.6 1.0)\r
+                                                                                                                       1.0)\r
+                               success_kicking                         = if (ballIsFree theBall)   (if iKickWell 0.95 0.85)\r
+                                                                                        (if  other_has_ball        (if iKickWell 0.80 0.70 * if otherDribblesWell 0.7 1.0)\r
+                                                                                                                       1.0)\r
+                               success_heading                         = if iHeadWell  0.95 0.90\r
+                               success_catching                        = if iCatchWell 1.00 0.95\r
+               \r
+       /**     selectTackleActions removes impossible tackle actions and, by chance, ignores some of the possible tackle actions.\r
+       */      selectTackleActions :: !(AssocList FootballerID FootballerAction) !RandomSeed -> (!AssocList FootballerID FootballerAction,!RandomSeed)\r
+               selectTackleActions performedActions seed\r
+                       = filterSt isPossibleTackle [action \\ action <- performedActions | isFootballerTackle (snd action)] seed\r
+               where\r
+                       isPossibleTackle :: !(!FootballerID,!FootballerAction) !RandomSeed -> (!Bool,!RandomSeed)\r
+                       isPossibleTackle (playerID,Tackle victimID _) seed\r
+                       | d_me_victim > maxTackleReach offender                                                         // victim is out of reach\r
+                                                                                       = (False,seed)\r
+                       # (p,seed)                                              = nextRandomP seed\r
+                       | otherwise                                             = (avg [p,chanceOfSuccess] > 0.5,seed)  // victim is within reach, but tackle may fail\r
+                       where\r
+                               offender                                        = find1 (identify_player playerID) all_players\r
+                               victim                                          = find1 (identify_player victimID) all_players\r
+                               d_me_victim                                     = dist offender victim\r
+                               chanceOfSuccess                         = avg [1.0 - toReal d_me_victim, if (isMember Tackling (skillsAsList offender)) 0.9 0.7]\r
+               \r
+/*     doFootballerActions intendedActions okActions match\r
+               performs for each football player in match his succeededAction. \r
+*/     doFootballerActions :: !(AssocList FootballerID FootballerAction) !(AssocList FootballerID FootballerAction) !Match -> Match\r
+       doFootballerActions intendedActions okActions match=:{theField,theBall,team1,team2,seed,nextRandomP}\r
+       # (seed,ball,new_players1,new_players2) = foldl (flip doAction) (seed,theBall,team1,team2) intendedActions\r
+       = { match & team1 = new_players1, team2 = new_players2, theBall = ball, seed = seed }\r
+       where\r
+               dt                                                                      = toReal match.Match.unittime                   // duration, in seconds, of one step\r
+               {fwidth,flength}                                        = theField\r
+               \r
+               doAction :: !(!FootballerID,!FootballerAction) !(!RandomSeed,!FootballState,![Footballer],![Footballer]) \r
+                                                            -> (!RandomSeed,!FootballState,![Footballer],![Footballer])\r
+               doAction intendedAction (seed,ball,allPlayers1,allPlayers2)\r
+               | isMember intendedAction okActions     = act intendedAction (seed,ball,allPlayers1,allPlayers2)\r
+               | otherwise                                                     = (seed,ball,map (failThisPlayerAction intendedAction) allPlayers1,map (failThisPlayerAction intendedAction) allPlayers2)                                               \r
+               where\r
+                       failThisPlayerAction :: !(!FootballerID,!FootballerAction) !Footballer -> Footballer\r
+                       failThisPlayerAction (id,idea) fb=:{playerID,effect}\r
+                       | id <> playerID                                = fb\r
+                       | otherwise                                             = {fb & effect = new_effect}\r
+                       where\r
+                               new_effect                                      = case effect of\r
+                                                                                               Just (OnTheGround nr_of_frames) = if (nr_of_frames < 0) Nothing (Just (OnTheGround (nr_of_frames-1)))\r
+                                                                                               _                                                               = Just (failFootballerAction idea)\r
+                       \r
+                       act :: !(!FootballerID,!FootballerAction) !(!RandomSeed,!FootballState,![Footballer],![Footballer]) \r
+                                                                               -> (!RandomSeed,!FootballState,![Footballer],![Footballer])\r
+                       \r
+               /** Rules for moving:\r
+               */      act (playerID,Move speed angle) (seed,ball,team1,team2)\r
+                       # (team1,team2)                                 = splitAt (length team1) (unbreak1 (uneq1,new_fb,uneq2))\r
+                       = (seed,ball,team1,team2)\r
+                       where\r
+                               (uneq1,fb,uneq2)                        = break1 (identify_player playerID) (team1 ++ team2)\r
+                               feasible_angle                          = scale (fromInt (sign angle)) (setbetween (abs angle) zero (maxRotateAngle fb))\r
+                               new_nose                                        = fb.nose + feasible_angle\r
+                               angleDifficulty                         = angleHowFarFromPi   (speed.direction-new_nose)\r
+                               angleDifference                         = angleHowFarFromAngle speed.direction new_nose\r
+                               new_stamina                                     = alter_stamina ball fb angleDifficulty angleDifference\r
+                               new_vel                                         = scale (1.4 * fb.health * new_stamina) (setbetween speed.velocity zero (maxVelocity (skillsAsList fb) angleDifficulty angleDifference))\r
+                               new_speed                                       = {speed & velocity=new_vel}\r
+                               new_position`                           = move_point (scale (dt * (toReal new_vel)) (toRVector new_speed.direction)) fb.pos\r
+                               new_position                            = point_to_rectangle ({px=scale -0.5 flength, py=scale -0.5 fwidth},{px=scale 0.5 flength,py=scale 0.5 fwidth}) new_position` \r
+                               new_fb                                          = {fb & stamina = new_stamina\r
+                                                                                             , speed   = new_speed\r
+                                                                                             , pos     = new_position\r
+                                                                                             , nose    = new_nose\r
+                                                                                             , effect  = Just (Moved new_speed feasible_angle)\r
+                                                                                         }\r
+       \r
+               /**     Rules for gaining ball:\r
+                       (1) ball obtains position and surface speed of obtaining player\r
+               */      act (playerID,GainBall) (seed,ball,team1,team2)\r
+                       # (team1,team2)                                 = splitAt (length team1) (unbreak1 (uneq1,new_fb,uneq2))\r
+                       = (seed,GainedBy playerID,team1,team2)\r
+                       where\r
+                               (uneq1,fb,uneq2)                        = break1 (identify_player playerID) (team1 ++ team2)\r
+                               new_fb                                          = {fb & effect = Just (GainedBall Success)}\r
+                       \r
+               /**     Rules for kicking ball:\r
+                       (1) kicking decreases stamina\r
+                       (2) kicking is more effective towards your direction, and least effective in opposite direction\r
+                       (3) being taller, you can kick harder\r
+                       (4) a low stamina/health lower your max kickspeed\r
+                       (5) todo: kicking a ball held/gained by a keeper, may damage the keeper\r
+               */      act (playerID,KickBall {vxy={velocity=v,direction=d},vz}) (seed,ball,team1,team2)\r
+                       # (team1,team2)                                 = splitAt (length team1) (unbreak1 (uneq1,new_fb,uneq2))\r
+                       = (seed1,Free new_ball,team1,team2)\r
+                       where\r
+                               (uneq1,fb,uneq2)                        = break1 (identify_player playerID) (team1 ++ team2)\r
+                               new_fb                                          = {fb & stamina=new_stamina,effect=Just (KickedBall (Just new_speed))}\r
+                               theBall                                         = getFootball ball (team1 ++ team2)\r
+                               skills                                          = skillsAsList fb\r
+                               max_v                                           = maxVelocityBallKick fb\r
+                               new_v                                           = scale speed_factor (setbetween v  zero max_v)\r
+                               new_vz                                          = scale speed_factor (setbetween vz zero max_v)\r
+                               new_speed                                       = {vxy={velocity=new_v,direction=new_d},vz=new_vz}\r
+                               new_stamina                                     = kickingPenalty fb new_v * fb.stamina\r
+                               speed_factor                            = oppositeKickPenalty fb d\r
+                               new_ball                                        = {theBall & ballSpeed=new_speed}\r
+                               (new_d,seed1)                           = new_ball_direction Kicking fb d seed\r
+                       \r
+               /**     Rules for heading ball:\r
+                       (1) heading decreases stamina, but less than kicking\r
+                       (2) kicking is more effective towards your direction, and least effective in opposite direction\r
+                       (3) a low stamina/health lower your max headspeed, but less than kicking\r
+                       (4) heading is less harder than kicking, but is not effected by your length\r
+                       (5) todo: heading a ball held/gained by a keeper, may damage the keeper (less than with kicking)\r
+               */      act (playerID,HeadBall {vxy={velocity=v,direction=d},vz}) (seed,ballstate,team1,team2)\r
+                       # (team1,team2)                                 = splitAt (length team1) (unbreak1 (uneq1,new_fb,uneq2))\r
+                       = (seed1,Free new_ball,team1,team2)\r
+                       where\r
+                               (uneq1,fb,uneq2)                        = break1 (identify_player playerID) (team1 ++ team2)\r
+                               skills                                          = skillsAsList fb\r
+                               ball                                            = getFootball ballstate (team1 ++ team2)\r
+                               ball_speed                                      = ball.ballSpeed.vxy.velocity\r
+                               max_v                                           = maxVelocityBallHead fb ball_speed\r
+                               new_v                                           = setbetween v zero max_v\r
+                               new_vz                                          = scale 0.25 (setbetween vz zero max_v)\r
+                               new_speed                                       = {vxy={velocity=new_v,direction=new_d},vz=new_vz}\r
+                               new_stamina                                     = headingPenalty fb new_v ball_speed * fb.stamina\r
+                               new_fb                                          = {fb & stamina=new_stamina,effect=Just (HeadedBall (Just new_speed))}\r
+                               new_ball                                        = {ball & ballSpeed=new_speed}\r
+                               (new_d,seed1)                           = new_ball_direction Heading fb d seed\r
+                       \r
+               /**     Rules for feinting:\r
+                       (1) you must have velocity in order to feint manouvre.\r
+                       (2) a feint manouvre changes your position, and decreases your velocity (depends on Feinting skill)\r
+               */      act (playerID,Feint d) (seed,ball,team1,team2)\r
+                       # (team1,team2)                                 = splitAt (length team1) (unbreak1 (uneq1,new_fb,uneq2))\r
+                       = (seed,ball,team1,team2)\r
+                       where\r
+                               (uneq1,fb,uneq2)                        = break1 (identify_player playerID) (team1 ++ team2)\r
+                               new_stamina                                     = (maxFatigueLossAtFeint fb) * fb.stamina\r
+                               new_velocity                            = scale (fb.health * fb.stamina * (maxVelocityLossAtFeint fb)) fb.speed.velocity\r
+                               new_speed                                       = {fb.speed & velocity=new_velocity}\r
+                               (leftv,rightv)                          = orthogonal fb.speed.direction\r
+                               sidestep                                        = case d of FeintLeft -> leftv; _ -> rightv\r
+                               new_position`                           = move_point ((scale (toReal (maxFeintStep fb)) (toRVector sidestep))\r
+                                                                                            + \r
+                                                                             (scale (dt * toReal new_velocity) (toRVector fb.speed.direction))\r
+                                                                            ) fb.pos\r
+                               new_position                            = point_to_rectangle ({px=scale -0.5 flength,py=scale -0.5 fwidth},{px=scale 0.5 flength,py=scale 0.5 fwidth}) new_position`\r
+                               new_fb                                          = {fb & pos=new_position,speed=new_speed,stamina=new_stamina,effect=Just (Feinted d)}\r
+                       \r
+               /** Rules for Tackling\r
+                       (1) tackling may lower the health of the victim but increases his stamina (last is because he lies on the ground the next rounds)\r
+                       (2) tackling costs stamina\r
+               */      act (playerID,Tackle victimID ve) (seed,ball,team1,team2)\r
+                       = (seed1,new_ball,team1T,team2T)\r
+                       where\r
+                               nrPlayersTeam1                          = length team1\r
+                               (uneq1,fb,uneq2)                        = break1 (identify_player playerID) (team1 ++ team2)\r
+                               (team1N,team2N)                         = splitAt nrPlayersTeam1 (unbreak1 (uneq1,new_fb,uneq2))\r
+                               (uneq1T,fbT,uneq2T)                     = break1 (identify_player victimID) (team1N ++ team2N)\r
+                               (team1T,team2T)                         = splitAt nrPlayersTeam1 (unbreak1 (uneq1T,new_target,uneq2T))\r
+                               new_stamina_self                        = maxFatigueLossAtTackle fb * fb.stamina\r
+                               new_fb                                          = {fb & stamina = new_stamina_self, effect = Just (Tackled victimID ve Success)}\r
+                               target_has_ball                         = ballIsGainedBy victimID ball\r
+                               (p,seed1)                                       = nextRandomP seed\r
+                               new_v`                                          = min max_tackle_velocity ve\r
+                               max_tackle_velocity                     = ms 10.0\r
+                               max_ground_time                         = s 30.0\r
+                               ground_frames                           = toInt ((((toReal new_v`) / (toReal max_tackle_velocity)) * (toReal max_ground_time)) / dt)\r
+                               new_v                                           = scale 0.1 new_v`\r
+                               healthDamageTarget                      = (toReal new_v) * fb.health * fb.stamina * (0.5*p + 0.1) + (toReal (fbT.length-min_length))/2.0\r
+                               new_health_target                       = max zero (fbT.health - healthDamageTarget)\r
+                               new_target                                      = {fbT & health = new_health_target, effect = Just (OnTheGround ground_frames) }\r
+                               new_ball                                        = if target_has_ball (Free (mkFootball fbT.pos fbT.speed)) ball \r
+                               \r
+               /** Rules for catching\r
+                       (1) ball optains speed and distance of player\r
+               */      act (playerID,CatchBall) (seed,ball,team1,team2)\r
+                       # (team1,team2)                                 = splitAt (length team1) (unbreak1 (uneq1,new_fb,uneq2))\r
+                       = (seed,GainedBy playerID,team1,team2)\r
+                       where\r
+                               (uneq1,fb,uneq2)                        = break1 (identify_player playerID) (team1 ++ team2)\r
+                               new_fb                                          = {fb & effect=Just (CaughtBall Success)}\r
+\r
+                       new_ball_direction :: !Skill !Footballer !Angle !RandomSeed -> (!Angle,!RandomSeed)\r
+                       new_ball_direction skill fb d seed\r
+                       # (p1,seed)                                             = nextRandomP seed\r
+                       # (p2,seed)                                             = nextRandomP seed\r
+                       | p2 == one                                             = (d,seed)\r
+                       # failure                                               = one - if (isMember skill (skillsAsList fb)) makeRandomRealisticSkilled makeRandomRealistic p2\r
+                       # diff                                                  = scale failure (maxHeadingDeviation fb)\r
+                       | p1 <= 0.5                                             = (d - diff, seed)\r
+                       | otherwise                                             = (d + diff, seed)\r
+\r
+/**    moveFootball match\r
+               makes the free ball move (a gained ball moves along with its player).\r
+*/     moveFootball :: !Match -> Match\r
+       moveFootball match=:{Match | theBall=Free football=:{ballSpeed={vxy={velocity=v,direction=d},vz},ballPos},theField,team1,team2,seed,lastContact,unittime}\r
+               = { match & theBall = Free {football & ballSpeed=new_speed,ballPos=new_ballpos}, seed = seed1, lastContact = if (isJust hit_player) hit_player lastContact }\r
+       where\r
+               old_height                                                      = ballPos.pz\r
+               in_the_air                                                      = old_height > zero\r
+               resistance                                                      = if in_the_air air_resistance surface_resistance\r
+               dt                                                                      = toReal unittime\r
+               surface_movement                                        = scale (dt * (toReal v)) (toRVector d)\r
+               new_speed2D                                                     = let new_v = scale resistance v in {direction = d, velocity = if (new_v <= ms 0.05) zero new_v}\r
+               new_vz`                                                         = if in_the_air (vz - scale dt accelleration_sec) zero\r
+               new_height`                                                     = ballPos.pz + m (toReal vz)\r
+               (new_height,new_vz)                                     = if (in_the_air && new_height` <= zero) // the ball bounces on the field\r
+                                                                                            (scale 0.5 (abs new_height`),let new_vz`` = scale 0.33 (abs new_vz`) in if (new_vz`` <= ms 0.8) zero new_vz``)\r
+                                                                                            (new_height`, new_vz`)\r
+               new_speed`                                                      = {vxy=new_speed2D, vz=new_vz}\r
+               new_ballpos                                                     = {pxy=move_point surface_movement ballPos.pxy,pz=new_height}\r
+               all_players                                                     = team1 ++ team2\r
+               (hit_player,new_speed,seed1)            = ballBounces new_ballpos new_speed` seed\r
+               \r
+       //      the direction of the ball changes after a bounce and its velocity may reduce in case of bouncing against a player\r
+               ballBounces :: !Position3D !Speed3D !RandomSeed -> (!Maybe FootballerID,!Speed3D,!RandomSeed)\r
+               ballBounces new_ballpos new_speed=:{vxy={velocity=v,direction=d},vz=s3d} seed\r
+               | hit_west_goal                                         = (Nothing,{new_speed & vxy = {new_speed.vxy & direction = if (d <= rad pi) (d - rad (0.5*pi)) (d + rad (0.5*pi)), velocity = v}},seed)\r
+               | hit_east_goal                                         = (Nothing,{new_speed & vxy = {new_speed.vxy & direction = if (d <= rad pi) (d + rad (0.5*pi)) (d - rad (0.5*pi)), velocity = v}},seed)\r
+               | isEmpty hit_players                           = (Nothing, new_speed, seed)\r
+               # (p1,seed)                                                     = nextRandomP seed\r
+               # (p2,seed)                                                     = nextRandomP seed\r
+               # (p3,seed)                                                     = nextRandomP seed\r
+               | otherwise                                                     = (Just (hd hit_players),{vxy = {direction = rad (p2*2.0*pi), velocity = scale p3 v}, vz=scale p1 s3d},seed)\r
+               where\r
+                       half_length                                             = scale 0.5 theField.flength\r
+                       goal_pole_r                                             = scale 0.5 goal_pole_width\r
+                       (northPole,southPole)                   = goal_poles theField\r
+                       hit_west_goal                                   = againstGoalWestNorthPole || againstGoalWestSouthPole || againstGoalWestPoleUpper\r
+                       hit_east_goal                                   = againstGoalEastNorthPole || againstGoalEastSouthPole || againstGoalEastPoleUpper\r
+                       hit_players                                             = [playerID \\ fb=:{length,playerID} <- all_players | inRadiusOfFootballer new_ballpos.pxy fb && length >= new_ballpos.pz]\r
+                       againstGoalWestNorthPole                = inCircleRadiusOfPosition new_ballpos goal_pole_r goal_height {px = ~half_length, py = northPole + goal_pole_r}\r
+                       againstGoalWestSouthPole                = inCircleRadiusOfPosition new_ballpos goal_pole_r goal_height {px = ~half_length, py = southPole - goal_pole_r}\r
+                       againstGoalEastNorthPole                = inCircleRadiusOfPosition new_ballpos goal_pole_r goal_height {px =  half_length, py = northPole + goal_pole_r}\r
+                       againstGoalEastSouthPole                = inCircleRadiusOfPosition new_ballpos goal_pole_r goal_height {px =  half_length, py = southPole - goal_pole_r}\r
+                       againstGoalWestPoleUpper                = (isbetween new_ballpos.pxy.py (southPole - goal_pole_r) (northPole + goal_pole_r))\r
+                                                                                                       &&\r
+                                                                                         (isbetween new_ballpos.pz goal_height (goal_height+goal_pole_width))\r
+                                                                                                       &&\r
+                                                                                         (new_ballpos.pxy.px <= ~half_length)\r
+                       againstGoalEastPoleUpper                = (isbetween new_ballpos.pxy.py (southPole - goal_pole_r) (northPole + goal_pole_r))\r
+                                                                                                       &&\r
+                                                                                         (isbetween new_ballpos.pz goal_height (goal_height+goal_pole_width))\r
+                                                                                                       &&\r
+                                                                                         (new_ballpos.pxy.px >= half_length)\r
+                       inCircleRadiusOfPosition {pxy,pz} r zr pos\r
+                                                                                       = dist pxy pos <= r && pz <= zr\r
+\r
+       moveFootball match\r
+               = match\r
+                       \r
+/**    advanceTime match\r
+               decreases the time to play with unittime.\r
+*/     advanceTime :: !Match -> Match\r
+       advanceTime match=:{Match | playingTime, unittime}\r
+               = {Match | match & playingTime = max zero (playingTime - minutes unittime)}\r
+\r
+/*     Attribute altering functions depending on angles:\r
+       params: \r
+               Angle :: between zero and pi, how much the player is running backwards (pi is backwards).\r
+               Angle :: between zero and pi, the difference between the desired angle and the angle the player previously ran to.\r
+*/\r
+alter_stamina :: !FootballState !Footballer !Angle !Angle -> Stamina\r
+alter_stamina ballState fb angleDifficulty angleDifference\r
+| velocity <= rfv                                                                                      // increase stamina\r
+       | stamina < MinimumFatigue                              = MinimumFatigue\r
+       | otherwise                                                             = stamina^0.8   \r
+| otherwise                                                                    = fatigue * factor\r
+where\r
+       velocity                                                                = fb.speed.velocity\r
+       length                                                                  = fb.length\r
+       stamina                                                                 = fb.stamina\r
+       rfv                                                                             = restore_stamina_velocity (ballIsGainedBy fb.playerID ballState) (skillsAsList fb) angleDifficulty angleDifference\r
+       diff                                                                    = velocity - rfv\r
+       fv                                                                              = if (diff >= ms 6.0) (stamina^(stamina^(1.6 + 0.02 * toReal length)))\r
+                                                                                        (if (diff >= ms 4.0) (stamina^(         1.5 + 0.01 * toReal length))\r
+                                                                                        (if (diff >= ms 2.0) (stamina^(         1.4 - 0.01 * toReal length))\r
+                                                                                                                         (stamina^(         1.3 - 0.02 * toReal length))))\r
+       factor                                                                  = one - (toReal angleDifficulty)/(4.0*pi)\r
+       fatigue                                                                 = if (stamina > MaximumFatigue) MaximumFatigue fv\r
+\r
+restore_stamina_velocity :: !Bool ![Skill] !Angle !Angle -> Velocity\r
+restore_stamina_velocity gained_ball skills angleDifficulty angleDifference\r
+| gained_ball                                                          = scale ( one / if (isMember Running   skills) 1.6 2.6)         max_v\r
+| isMember Running skills                                      = scale ((one / if (isMember Dribbling skills) 2.0 3.0) * 1.22) max_v\r
+| otherwise                                                                    = scale ( one / if (isMember Dribbling skills) 2.0 3.0)         max_v\r
+where\r
+       max_v                                                                   = maxVelocity skills angleDifficulty angleDifference\r
+\r
+maxVelocity :: ![Skill] !Angle !Angle -> Velocity\r
+maxVelocity skills angleDifficulty angleDifference\r
+       = scale (dribblingPenalty * runningPenalty) base_velocity\r
+where\r
+       base_velocity                                                   = ms 10.0\r
+       dribblingPenalty                                                = if (isMember Dribbling skills) 0.95 0.85\r
+       runningPenalty                                                  = if (isMember Running   skills) 1.0  0.85\r
+\r
+MinimumFatigue                                                         :== 0.05\r
+MaximumFatigue                                                         :== 0.985\r
+\r
+\r
+/**    The functions below defines the penalty factor: values between 0.0 and 1.0 that define the loss of an attribute of an action.\r
+*/\r
+::     PenaltyFactor :== Real                                  // a value between 0.0 and 1.0\r
+\r
+kickingPenalty :: !Footballer !Velocity -> PenaltyFactor\r
+kickingPenalty fb new_v                                                = 1.0 - (if (isMember Kicking (skillsAsList fb)) 0.3 0.6) * ((toReal new_v)/(toReal max_v))^2.0\r
+where\r
+       max_v                                                                   = maxVelocityBallKick fb\r
+\r
+headingPenalty :: !Footballer !Velocity !Velocity -> PenaltyFactor\r
+headingPenalty fb new_v ball_v                         = 1.0 - (if (isMember Heading (skillsAsList fb)) 0.08 0.13) * ((toReal new_v)/(toReal max_v))^2.0\r
+where\r
+       max_v                                                                   = maxVelocityBallHead fb ball_v\r
+\r
+maxFatigueLossAtTackle :: !Footballer -> PenaltyFactor\r
+maxFatigueLossAtTackle fb                                      = if (isMember Tackling (skillsAsList fb)) 0.99 0.9\r
+\r
+maxFatigueLossAtFeint :: !Footballer -> PenaltyFactor\r
+maxFatigueLossAtFeint fb                                       = if (isMember Feinting (skillsAsList fb)) 0.92 0.77\r
+\r
+maxVelocityLossAtFeint :: !Footballer -> PenaltyFactor\r
+maxVelocityLossAtFeint fb                                      = if (isMember Feinting (skillsAsList fb)) 0.99 0.75\r
+\r
+oppositeKickPenalty :: !Footballer !Angle -> PenaltyFactor\r
+oppositeKickPenalty fb kick_to                         = 1.0 - toReal (scale (skillPenaltyFactor/pi) (angleHowFarFromPi angle))\r
+where\r
+       angle                                                                   = abs (fb.nose - kick_to)\r
+       skills                                                                  = skillsAsList fb\r
+       skillPenaltyFactor                                              = if (isAllMember [Rotating,Kicking] skills) 0.3\r
+                                                                                        (if (isAnyMember [Rotating,Kicking] skills) 0.5\r
+                                                                                                                            0.9)\r
+\r
+angleHowFarFromPi :: !Angle -> Angle\r
+angleHowFarFromPi a\r
+| a` > rad pi                                                          = rad (2.0*pi) - a`\r
+| otherwise                                                                    = a`\r
+where\r
+       a`                                                                              = abs a\r
+\r
+angleHowFarFromAngle :: !Angle !Angle -> Angle\r
+angleHowFarFromAngle a b\r
+| a` > b`\r
+       | a` - b` > rad pi                                              = b` - a` + rad (2.0*pi)\r
+       | otherwise                                                             = a` - b`\r
+| otherwise\r
+       | b` - a` > rad pi                                              = a` - b` + rad (2.0*pi)\r
+       | otherwise                                                             = b` - a`\r
+where\r
+       a`                                                                              = abs a\r
+       b`                                                                              = abs b\r
diff --git a/src/Game/matchGame.dcl b/src/Game/matchGame.dcl
new file mode 100644 (file)
index 0000000..6660874
--- /dev/null
@@ -0,0 +1,108 @@
+definition module matchGame\r
+\r
+/** This module defines the match and tournament data structures.\r
+*/\r
+import matchLog, guiInterface, render\r
+\r
+::     FootballGame\r
+       =       { match                         :: !Match                                               // the football match to be played\r
+               , actionPics            :: !ActionPics                                  // the action-images\r
+               , history                       :: !History                                             // recent history of game\r
+               , frames                        :: !Int                                                 // nr of frames so far (reset to zero every second)\r
+               , options                       :: !Options                                             // options of football game\r
+               , logging                       :: !WhatToLog                                   // logging options\r
+               }\r
+\r
+::     Options\r
+       =       { closeReferee          :: !Bool                                                // automatically close referee dialog after one second (True - default) or by user (False)\r
+               , showSplash            :: !Bool                                                // show splash screen at opening (False - default) or do (True)\r
+               , displaySpeed          :: !DisplaySpeed                                // slow, normal or fast-play (Normal - default)\r
+               , showReferee           :: !Bool                                                // show referee-intermezzo (True - default) or not (False)\r
+               , playingTime           :: !PlayingTime                                 // default playingtime (defaultPlayingTime)\r
+               , renderStyle       :: !RenderStyle                                     // the chosen render style (flatland style is default)\r
+               }\r
+instance toString   Options\r
+instance fromString Options\r
+instance ==         Options\r
+\r
+::     History\r
+       =       { time                          :: !Seconds                                             // time in seconds of length history\r
+               , past                          :: ![Match]                                             // the recent history\r
+               } \r
+\r
+/**    incFrames game increases the frames count of game.\r
+*/\r
+incFrames                                      :: !FootballGame -> FootballGame\r
+\r
+/*     defaultPlayingTime returns recommended playing time\r
+*/\r
+defaultPlayingTime                     :: PlayingTime\r
+\r
+/**    defaultOptions returns default options.\r
+*/\r
+defaultOptions                         :: Options\r
+\r
+/*     timeLeft is True if the game has not finished\r
+*/\r
+timeLeft                                       :: !FootballGame -> Bool\r
+\r
+/**    getOptions env reads the options file (if present) and returns its content.\r
+               If no options file was found, it is created and filled with default values.\r
+       setOptions options stores the options in the options file.\r
+*/\r
+getOptions                                     :: !*env -> (!Options,!*env)    | FileSystem env\r
+setOptions                                     :: !Options !*env -> *env               | FileSystem env\r
+\r
+::     Competition                             =       { results               :: ![[Maybe Score]]     // teams x teams matrix of match results (note: team x team -> Nothing)\r
+                                                               , west                  :: ![ClubName]          // names of participating teams (west side)\r
+                                                               , east                  :: ![ClubName]          // names of participating teams (east side)\r
+                                                               , usedRandomSeed:: !RandomSeed          // the seed that is used for computing the matches\r
+                                                               }\r
+::     Ranking                                 :== AssocList ClubName Rank\r
+::     Rank                                    =       { matchpoints   :: !Int                         // number of matchpoints   (>= 0)\r
+                                                               , goals_scored  :: !Int                         // number of scored goals  (>= 0)\r
+                                                               , goals_against :: !Int                         // number of goals against (>= 0)\r
+                                                               }\r
+instance zero Rank\r
+instance ==   Rank\r
+instance <    Rank\r
+instance +    Rank\r
+\r
+/** competition teams field referee time rs\r
+               computes an entire competition between all teams in teams.\r
+               Each match uses the same referee and same initial random seed value rs.\r
+*/\r
+competition                                    :: ![Home FootballField -> Team] !FootballField !Referee !PlayingTime !RandomSeed -> Competition\r
+\r
+/** computeMatch match\r
+               computes an entire match between the currently selected team1 and team2.\r
+*/\r
+computeMatch                           :: !Match -> Score\r
+\r
+/** ranking competition\r
+               computes the ranking of all teams that have participated in competition.\r
+*/\r
+//ranking                                              :: !Competition -> Ranking\r
+ranking                                                :: ![ClubName] ![Maybe Score] -> Ranking\r
+\r
+/** checkCompetitionFile west_team_names rs env\r
+               checks whether there is a competition backup file present for the current set\r
+               of teams (assuming they start on the West home side) and initial random seed value rs\r
+               for computing matches. \r
+               If not, then such a file is created, and the same random seed value and empty list of scores is returned. \r
+               If so, then the currently stored random seed value and list of scores is returned.\r
+*/\r
+checkCompetitionFile           :: ![ClubName] !RandomSeed !*env -> (!(!RandomSeed,![Maybe Score]),!*env) | FileSystem env\r
+\r
+/** appendMatchToCompetitionFile west east env\r
+               appends an empty entry of a match between west versus east in the competition backup file.\r
+               It also returns the file pointer to allow a correct update in updateMatchToCompetitionFile.\r
+*/\r
+appendMatchToCompetitionFile:: !ClubName !ClubName !*env -> (!Int,!*env) | FileSystem env\r
+\r
+\r
+/** updateMatchToCompetitionFile west east score filepointer env\r
+               updates the line that starts at filepointer in the competition backup file with the result \r
+               of the match between west versus east.\r
+*/\r
+updateMatchToCompetitionFile:: !ClubName !ClubName !(Maybe Score) !Int !*env -> *env | FileSystem env\r
diff --git a/src/Game/matchGame.icl b/src/Game/matchGame.icl
new file mode 100644 (file)
index 0000000..ae6b0c1
--- /dev/null
@@ -0,0 +1,214 @@
+implementation module matchGame\r
+\r
+import StdEnvExt, fileIO\r
+import guiInterface, matchControl, render\r
+from   Parsers import parse, :: Parser, :: Result(..), :: SugPosition, :: Rose(..), :: RoseNode(..), :: SymbolTypes(..), \r
+                      :: SymbolType(..),\r
+                      fail, yield, token, symbol, <&>, &>, <!>, <!+>, <!*>, number, digit\r
+       \r
+timeLeft                                       :: !FootballGame -> Bool\r
+timeLeft game                          = game.match.Match.playingTime > zero\r
+\r
+defaultPlayingTime                     :: PlayingTime\r
+defaultPlayingTime                     = minutes 1.0\r
+\r
+incFrames                                      :: !FootballGame -> FootballGame\r
+incFrames game=:{frames}       = {game & frames=frames+1}\r
+\r
+\r
+instance zero Rank where\r
+       zero                                    = { matchpoints = zero, goals_scored = zero, goals_against = zero }\r
+instance == Rank where\r
+       (==) r1 r2                              = (r1.matchpoints,r1.goals_scored,r1.goals_against) == (r2.matchpoints,r2.goals_scored,r2.goals_against)\r
+instance < Rank where\r
+       (<) r1 r2                               = r1.matchpoints <  r2.matchpoints || \r
+                                                         r1.matchpoints == r2.matchpoints && r1.goals_scored <  r2.goals_scored ||\r
+                                                         r1.matchpoints == r2.matchpoints && r1.goals_scored == r2.goals_scored && r1.goals_against > r2.goals_against\r
+instance + Rank where\r
+       (+) r1 r2                               = { matchpoints   = r1.matchpoints   + r2.matchpoints\r
+                                                         , goals_scored  = r1.goals_scored  + r2.goals_scored\r
+                                                         , goals_against = r1.goals_against + r2.goals_against\r
+                                                         }\r
+\r
+competition                                    :: ![Home FootballField -> Team] !FootballField !Referee !PlayingTime !RandomSeed -> Competition\r
+competition teams field referee playingtime rs\r
+       = { results                             = [ [  if (nr_west == nr_east) \r
+                                                                 Nothing \r
+                                                                 (Just (computeMatch (setMatchStart (team_west West field) (team_east East field) field referee playingtime rs)))\r
+                                                           \\ (nr_east,team_east) <- zip2 [1..] teams\r
+                                                           ]\r
+                                                         \\ (nr_west,team_west) <- zip2 [1..] teams\r
+                                                         ]\r
+         , west                                = map (\f -> nameOf (f West field)) teams\r
+         , east                                = map (\f -> nameOf (f East field)) teams\r
+         , usedRandomSeed              = rs\r
+         }\r
+\r
+computeMatch                           :: !Match -> Score\r
+computeMatch match\r
+| match.Match.playingTime > zero\r
+                                                       = computeMatch (snd (stepMatch match))\r
+| otherwise                                    = match.score\r
+\r
+ranking                                                :: ![ClubName] ![Maybe Score] -> Ranking\r
+ranking names scores           = foldl upd [(t,zero) \\ t <- names] (zip2 [(tw,te) \\ tw <- names, te <- names] scores)\r
+where  \r
+       upd ranking (_,Nothing)\r
+               = ranking\r
+       upd ranking ((west,east),Just (goals_west,goals_east))\r
+               = updkeyvalue west ((+) rank_west) (updkeyvalue east ((+) rank_east) ranking)\r
+       where\r
+               (mps_west, mps_east)    = if (goals_west > goals_east) (3,0) (if (goals_west < goals_east) (0,3) (1,1))\r
+               (rank_west,rank_east)   = ({matchpoints=mps_west,goals_scored=goals_west,goals_against=goals_east}\r
+                                                                 ,{matchpoints=mps_east,goals_scored=goals_east,goals_against=goals_west}\r
+                                                                 )\r
+\r
+instance toString Options where\r
+       toString {closeReferee,showSplash,displaySpeed,showReferee,playingTime,renderStyle}\r
+                                                       = "{closeReferee=" <+++ closeReferee       <+++\r
+                                                         ",showSplash="   <+++ showSplash         <+++\r
+                                                         ",displaySpeed=" <+++ displaySpeed       <+++\r
+                                                         ",showReferee="  <+++ showReferee        <+++\r
+                                                         ",playingTime="  <+++ playingTime        <+++\r
+                                                         ",renderStyle="  <+++ nameOf renderStyle <+++\r
+                                                         "}"\r
+instance fromString Options where\r
+       fromString str\r
+       = case parse optionsP (fromString str) optionsFile "char" of\r
+               Succ [opt:_]            = opt\r
+               _                                       = defaultOptions\r
+       where\r
+               optionsP                        :: Parser Char Options Options\r
+               optionsP                        = token ['{closeReferee=']  &>\r
+                                                         boolP                    <&> \closeReferee ->\r
+                                                         token [',showSplash=']    &>\r
+                                                         boolP                    <&> \showSplash   ->\r
+                                                         token [',displaySpeed=']  &> \r
+                                                         displaySpeedP            <&> \displaySpeed ->\r
+                                                         token [',showReferee=']   &>\r
+                                                         boolP                    <&> \showReferee  ->\r
+                                                         token [',playingTime=']   &>\r
+                                                         timeP                    <&> \playingTime  ->\r
+                                                         token [',renderStyle=']   &>\r
+                                                         renderP                  <&> \renderStyle  ->\r
+                                                         symbol '}'                &>\r
+                                                         yield { closeReferee = closeReferee\r
+                                                               , showSplash   = showSplash\r
+                                                               , displaySpeed = displaySpeed\r
+                                                               , showReferee  = showReferee\r
+                                                               , playingTime  = playingTime\r
+                                                               , renderStyle  = renderStyle\r
+                                                               }\r
+               boolP                           = (token ['True'] &> yield True) <!> (token ['False'] &> yield False)\r
+               renderP                         = firstP [token (fromString (nameOf style)) &> yield style \\ style <- allRenderStyles] <!> yield (hd allRenderStyles)\r
+               firstP []                       = fail\r
+               firstP [p:ps]           = p <!> firstP ps\r
+               timeP                           = <!+> digit        <&> \mts   ->\r
+                                                             (symbol ':')  <&> \colon ->\r
+                                                         <!+> digit        <&> \secs  ->\r
+                                                         (token [' min'])  <&> \_     ->\r
+                                                         yield (minutes ((toReal (toInt (toString mts))) + (toReal (toInt (toString secs)))/60.0))\r
+               displaySpeedP           = (token ['Slowest'] &> yield Slowest) <!> \r
+                                                         (token ['Slower']  &> yield Slower)  <!>\r
+                                                         (token ['Normal']  &> yield Normal)  <!>\r
+                                                         (token ['Faster']  &> yield Faster)  <!>\r
+                                                         (token ['Fastest'] &> yield Fastest)\r
+\r
+instance == Options where\r
+       (==) o1 o2                              = o1.closeReferee                  == o2.closeReferee                 &&\r
+                                                         o1.showSplash                    == o2.showSplash                   &&\r
+                                                         o1.displaySpeed                  == o2.displaySpeed                 &&\r
+                                                         o1.showReferee                   == o2.showReferee                  &&\r
+                                                         o1.Options.playingTime           == o2.Options.playingTime          &&\r
+                                                         o1.renderStyle.RenderStyle.name  == o2.renderStyle.RenderStyle.name\r
+       \r
+getOptions                                     :: !*env -> (!Options,!*env)    | FileSystem env\r
+getOptions env\r
+       = case readFile optionsFile env of\r
+               (Just options,env)      = (fromString options,env)\r
+               (nothing,     env)      = (defaultOptions,    env)\r
+\r
+setOptions                                     :: !Options !*env -> *env               | FileSystem env\r
+setOptions options env         = writeFile False optionsFile (toString options) env\r
+\r
+optionsFile                                    :== "SoccerFun_options.txt"\r
+\r
+defaultOptions                         :: Options\r
+defaultOptions\r
+       = { closeReferee                = True\r
+         , showSplash                  = False\r
+         , displaySpeed                = Normal\r
+         , showReferee                 = True\r
+         , playingTime                 = defaultPlayingTime\r
+         , renderStyle                 = hd allRenderStyles\r
+         }\r
+\r
+checkCompetitionFile           :: ![ClubName] !RandomSeed !*env -> (!(!RandomSeed,![Maybe Score]),!*env) | FileSystem env\r
+checkCompetitionFile west rs env\r
+# (ok,cf,env)                          = fopen competitionFile FReadText env\r
+| not ok                                       = ((rs,[]), createCompetitionFile west rs env)                                          // competition file does not exist: create it\r
+# (ok,frs,fwest,cf)                    = header cf\r
+| not ok || fwest <> teams_line west\r
+                                                       = ((rs,[]), createCompetitionFile west rs (snd (fclose cf env)))        // competition file ill-formatted or different set of teams: create it\r
+# (scores,cf)                          = readScores cf                                                                                                         // competition file exists, and for this competition\r
+# (ok,env)                                     = fclose cf env\r
+| not ok                                       = abort ("Could not close competition file after reading scores.\n" <+++ length scores)\r
+| otherwise                                    = ((frs,scores),env)\r
+where\r
+       readScores                              :: !*File -> (![Maybe Score],!*File)\r
+       readScores cf\r
+       # (end,cf)                              = fend cf\r
+       | end                                   = ([],cf)\r
+       # (line,cf)                             = freadline cf\r
+       # score                                 = if (line.[0] == 'x') Nothing\r
+                                                        (let (i1,l1)   = span ((<>) ' ') [c \\ c<-:line]\r
+                                                             (i2,l2)   = span ((<>) ' ') (tl l1)\r
+                                                          in Just (toInt (toString i1),toInt (toString i2))\r
+                                                        )\r
+       # (scores,cf)                   = readScores cf\r
+       = ([score:scores],cf)\r
+\r
+appendMatchToCompetitionFile:: !ClubName !ClubName !*env -> (!Int,!*env) | FileSystem env\r
+appendMatchToCompetitionFile west east env\r
+# (ok,cf,env)                          = fopen competitionFile FAppendText env\r
+| not ok                                       = abort "Could not open competition file for appending data.\n"\r
+# (pos,cf)                                     = fposition cf\r
+# (ok,env)                                     = fclose (cf <<< "x " <<< west <<< " vs " <<< east <<< '\n') env\r
+| not ok                                       = abort "Could not close competition file after appending data.\n"\r
+| otherwise                                    = (pos,env)\r
+\r
+updateMatchToCompetitionFile:: !ClubName !ClubName !(Maybe Score) !Int !*env -> *env | FileSystem env\r
+updateMatchToCompetitionFile west east score pos env\r
+# (ok,cf,env)                          = fopen competitionFile FAppendText env\r
+| not ok                                       = abort "Could not open competition file for appending data.\n"\r
+# (ok,cf)                                      = fseek cf pos FSeekSet\r
+| not ok                                       = abort "Could not seek in competition file for updating data.\n"\r
+# (ok,env)                                     = fclose (cf <<< result <<< ' ' <<< west <<< " vs " <<< east <<< '\n') env\r
+| not ok                                       = abort "Could not close competition file after appending data.\n"\r
+| otherwise                                    = env\r
+where\r
+       result                                  = case score of\r
+                                                               Nothing      = "x"\r
+                                                               Just (gw,ge) = gw +++> (" " <+++ ge)\r
+\r
+createCompetitionFile          :: ![ClubName] !RandomSeed !*env -> *env | FileSystem env\r
+createCompetitionFile west rs env\r
+# (ok,cf,env)                          = fopen competitionFile FWriteText env\r
+| not ok                                       = abort "Could not create competition file.\n"\r
+# (ok,env)                                     = fclose (cf <<< seed_line rs <<< '\n' <<< teams_line west <<< '\n') env\r
+| not ok                                       = abort "Could not close competition file.\n"\r
+| otherwise                                    = env\r
+\r
+header                                         :: !*File -> (!Bool,!RandomSeed,!String,!*File)\r
+header file\r
+# (rs_line,   file)                    = freadline file\r
+# (teams_line,file)                    = freadline file\r
+= (size rs_line > 1 && size teams_line > 1, fromString (rs_line%(0,size rs_line-2)), teams_line%(0,size teams_line-2),file)\r
+\r
+seed_line                                      :: !RandomSeed -> String\r
+seed_line rs                           = toString rs\r
+\r
+teams_line                                     :: ![ClubName] -> String\r
+teams_line west                                = foldl (\t ts -> t +++ "," +++ ts) "" west\r
+\r
+competitionFile                                :== "competition.txt"\r
diff --git a/src/Game/matchLog.dcl b/src/Game/matchLog.dcl
new file mode 100644 (file)
index 0000000..1b179bc
--- /dev/null
@@ -0,0 +1,23 @@
+definition module matchLog\r
+\r
+/**    This module defines the logging facilities of Soccer-Fun.\r
+*/\r
+import matchControl\r
+\r
+/** Logging a match.\r
+*/\r
+::     WhatToLog       = { footballerActions   :: !Bool\r
+                                 , fbPositions                 :: !Bool\r
+                                 , refEvents                   :: !Bool\r
+                                 , ballPosition                :: !Bool\r
+                                 }\r
+instance toString WhatToLog\r
+\r
+getWhatToLog   :: !*env -> (!WhatToLog,!*env) | FileSystem env\r
+\r
+logFile                        :: String\r
+\r
+/*     logMatch options match refereeActions succeededActions env\r
+               writes the indicated log fields to logFile.\r
+*/\r
+logMatch               :: !WhatToLog !Match ![RefereeAction] !(AssocList FootballerID FootballerAction) !*env -> *env | FileSystem env\r
diff --git a/src/Game/matchLog.icl b/src/Game/matchLog.icl
new file mode 100644 (file)
index 0000000..744f25b
--- /dev/null
@@ -0,0 +1,125 @@
+implementation module matchLog\r
+\r
+import StdEnvExt, fileIO\r
+import matchControl\r
+\r
+logFile                                                :: String\r
+logFile                                                = "SoccerFun.log"\r
+\r
+getWhatToLog                           :: !*env -> (!WhatToLog,!*env) | FileSystem env\r
+getWhatToLog env\r
+       = case readFile fileStr env of\r
+               (Just line,env)         = (fromString line,env)\r
+               (nothing,  env)         = (defaultLogging, env)\r
+where\r
+       fileStr                                 = "logMatch.conf"\r
+\r
+instance toString WhatToLog where \r
+       toString l = "{footballerActions=" <+++ l.footballerActions +++ \r
+                                ",fbPositions="       <+++ l.fbPositions       +++ \r
+                                ",refEvents="         <+++ l.refEvents         +++ \r
+                                ",ballPosition="      <+++ l.ballPosition      +++ \r
+                                "}"\r
+instance fromString WhatToLog where\r
+       fromString str\r
+               # (okActions,  actions,  str)                   = isBool (literal "{footballerActions=" str)\r
+               # (okPositions,positions,str)                   = isBool (literal ",fbPositions="       str)\r
+               # (okRefEvents,events,   str)                   = isBool (literal ",refEvents="         str)\r
+               # (okPositions,pos,      str)                   = isBool (literal ",ballPosition="      str)\r
+               | okActions && okPositions && okRefEvents && okPositions && str=="}"\r
+                       = { footballerActions                           = actions\r
+                         , fbPositions                                         = positions\r
+                         , refEvents                                           = events\r
+                         , ballPosition                                        = pos\r
+                         }\r
+               | otherwise\r
+                       = defaultLogging\r
+       where\r
+               literal literal str\r
+               | stringStarts str literal                              = str%(size literal,size str-1)\r
+               | otherwise                                                             = str\r
+               isBool str\r
+               | stringStarts str "True"                               = (True,True, str%(4,size str-1))\r
+               | stringStarts str "False"                              = (True,False,str%(5,size str-1))\r
+               | otherwise                                                             = (False,undef,str)\r
+\r
+defaultLogging         = { footballerActions           = False\r
+                                         , fbPositions                         = False\r
+                                         , refEvents                           = False\r
+                                         , ballPosition                        = False\r
+                                         }\r
+\r
+\r
+/*     logMatch logging match refereeActions succeededActions env\r
+               writes the log fields indicated in logging from the match and actions to disk.\r
+*/\r
+logMatch :: !WhatToLog !Match ![RefereeAction] !(AssocList FootballerID FootballerAction) !*env -> *env | FileSystem env\r
+logMatch logging match_to_log=:{Match | team1,team2,playingTime,theBall} refereeActions succeededActions env\r
+       | logging.footballerActions || logging.fbPositions || logging.refEvents || logging.ballPosition\r
+               # env                           = writeFile True logFile ("BEGIN STEP "<+++playingTime<+++"\n") env\r
+               # env                           = if (logging.footballerActions) (writeFile True logFile (logActions    allPlayers succeededActions) env) env\r
+               # env                           = if (logging.fbPositions)       (writeFile True logFile (logPositions  allPlayers)                  env) env\r
+               # env                           = if (logging.refEvents)         (writeFile True logFile (logRefereeActions refereeActions)          env) env\r
+               # env                           = if (logging.ballPosition)      (writeFile True logFile ("BallPos: " <+++ ball.ballPos +++ "\n")    env) env\r
+               # env                           = writeFile True logFile ("END STEP " <+++ playingTime <+++ "\n") env\r
+               = env\r
+       | otherwise\r
+               = env\r
+where\r
+       allPlayers                              = team1 ++ team2\r
+       ball                                    = getFootball theBall allPlayers \r
+\r
+       logActions :: ![Footballer] !(AssocList FootballerID FootballerAction) -> String\r
+       logActions _ []         = ""\r
+       logActions allPlayers [(playerID=:{clubName,playerNr},action) : mfals]\r
+                                               = "FootballerWithAction\n\tTeam: "     <+++ \r
+                                                 clubName                             <+++ \r
+                                                 "\n\tNumber: "                       <+++ \r
+                                                 playerNr                             <+++ \r
+                                                 "\n\tName: "                         <+++ \r
+                                                 nameOf self                          <+++ \r
+                                                 "\n\tAction: "                       <+++ \r
+                                                 improveString (toString action)      <+++ \r
+                                                 "\n"                                 <+++ logActions allPlayers mfals\r
+       where\r
+               self                    = find1 (identify_player playerID) allPlayers\r
+               \r
+       improveString           = (replaceInString "}\"" "}") o (replaceInString "\"{" "{") o (replaceInString "\\\"" "\"")\r
+\r
+       logPositions :: ![Footballer] -> String\r
+       logPositions fbs        = "POSITIONS:\n" <+++ foldl printFootballer "" fbs\r
+       where\r
+               printFootballer str {playerID={clubName,playerNr},name,pos}\r
+                                               = str <+++ "\t(" <+++ clubName <+++ ",(" <+++ playerNr <+++"," <+++ name <+++")):\t" <+++ pos <+++ "\n"\r
+\r
+       logRefereeActions :: ![RefereeAction] -> String\r
+       logRefereeActions []                            = ""\r
+       logRefereeActions refls                         = "REFEREE_ACTIONS:" <+++ logRefereeActions` refls <+++ "\n"\r
+       where\r
+               logRefereeActions` :: ![RefereeAction] -> String\r
+               logRefereeActions` []                   = ""\r
+               logRefereeActions` [ref:refls]  = "\n\t" <+++ logRefereeAction ref <+++ logRefereeActions` refls\r
+               \r
+               logRefereeAction :: !RefereeAction -> String\r
+               logRefereeAction (ReprimandPlayer   tfp r)      = "(ReprimandPlayer " <+++ tfp.playerNr <+++ " " <+++ r <+++ ")"\r
+               logRefereeAction (Hands                         tfp)    = "(Hands "           <+++ tfp.playerNr <+++ ")"\r
+               logRefereeAction (TackleDetected        tfp)    = "(TackleDetected "  <+++ tfp.playerNr <+++ ")"\r
+               logRefereeAction (DangerousPlay         tfp)    = "(DangerousPlay "   <+++ tfp.playerNr <+++ ")"\r
+               logRefereeAction  GameOver                                      = "GameOver"\r
+               logRefereeAction (GameCancelled     mt)         = "(GameCancelled "   <+++ mt <+++ ")"\r
+               logRefereeAction  PauseGame                                     = "PauseGame"\r
+               logRefereeAction (AddTime                       t)              = "(AddTime "         <+++ t <+++ ")"\r
+               logRefereeAction  EndHalf                                       = "EndHalf"\r
+               logRefereeAction (Goal                          t)              = "(Goal "            <+++ t <+++ ")"\r
+               logRefereeAction (Offside                       tfp)    = "(Offside "         <+++ tfp.playerNr <+++ ")"\r
+               logRefereeAction (DirectFreeKick        t p)    = "(DirectFreeKick "  <+++ t <+++ " " <+++ p <+++ ")"\r
+               logRefereeAction (GoalKick              t)              = "(GoalKick "        <+++ t <+++ ")"\r
+               logRefereeAction (Corner                t e)    = "(Corner "          <+++ t <+++ " " <+++ e <+++ ")"\r
+               logRefereeAction (ThrowIn               t p)    = "(ThrowIn "         <+++ t <+++ " " <+++ p <+++ ")"\r
+               logRefereeAction (Penalty                       t)              = "(Penalty "         <+++ t <+++ ")"\r
+               logRefereeAction (CenterKick            t)              = "(CenterKick "      <+++ t <+++ ")"\r
+               logRefereeAction (Advantage                     t)              = "(Advantage "       <+++ t <+++ ")"\r
+               logRefereeAction (OwnBallIllegally  tfp)        = "(OwnBallIllegally" <+++ tfp.playerNr <+++ ")"\r
+               logRefereeAction (DisplacePlayers       ds)             = "DisplacePlayers"\r
+               logRefereeAction  ContinueGame                          = "ContinueGame"\r
+               logRefereeAction (TellMessage           txt)    = "(TellMessage "     <+++ txt <+++ ")"\r
diff --git a/src/Game/randomstream.dcl b/src/Game/randomstream.dcl
new file mode 100644 (file)
index 0000000..55c6a05
--- /dev/null
@@ -0,0 +1,49 @@
+definition module randomstream\r
+\r
+/**    This module implements a number of infinite random streams.\r
+       For predictable games, the onesStream can be used.\r
+*/\r
+import StdClass\r
+import StdMaybe\r
+import RandomExt\r
+\r
+::     Stream a                                :== [a]                 // an infinite list of random values\r
+::     P                                               :== Real                // 0<=x<=1.0\r
+\r
+/**    intRandomStream\r
+               creates a stream of random (positive and negative) Integer values. \r
+       realRandomStream\r
+               creates a stream of random (positive and negative) Real values.\r
+       boolRandomStream\r
+               creates a stream of random Bool values.\r
+       probabilityRandomStream\r
+               creates a stream of random P values.\r
+       onesStream\r
+               creates a stream of one values.\r
+*/\r
+intRandomStream                                :: !RandomSeed -> Stream Int\r
+realRandomStream                       :: !RandomSeed -> Stream Real\r
+boolRandomStream                       :: !RandomSeed -> Stream Bool\r
+probabilityRandomStream                :: !RandomSeed -> Stream P\r
+onesStream                                     ::                Stream P\r
+\r
+/**    nextRandom<Type> creates a next pseudo random value of given type.\r
+*/\r
+nextRandomInt                          :: !RandomSeed -> .(!Int, !RandomSeed)\r
+nextRandomReal                         :: !RandomSeed -> .(!Real,!RandomSeed)\r
+nextRandomBool                         :: !RandomSeed -> .(!Bool,!RandomSeed)\r
+nextRandomP                                    :: !RandomSeed -> .(!P,   !RandomSeed)\r
+next1                                          :: !RandomSeed -> .(!P,   !RandomSeed)\r
+\r
+/** make the random realistic, as in, small errors occur more often:\r
+               \r -> 1.0-r^4 (zero <= r <= 1.0)\r
+*/\r
+makeRandomRealistic                    :: !P -> P\r
+//             \r -> 1-r^10\r
+makeRandomRealisticSkilled     :: !P -> P\r
+\r
+/** selectMostProbableAction randomly selects one of the elements of the list that have the same\r
+       highest probability.\r
+       If all probabilities are equal to zero, then Nothing is returned.\r
+*/\r
+selectMostProbableAction       :: ![(P,a)] !RandomSeed -> (!Maybe a,!RandomSeed)\r
diff --git a/src/Game/randomstream.icl b/src/Game/randomstream.icl
new file mode 100644 (file)
index 0000000..f5a907e
--- /dev/null
@@ -0,0 +1,101 @@
+implementation module randomstream\r
+\r
+import StdEnv, StdEnvExt\r
+import RandomExt\r
+\r
+::     Stream a :== [a]\r
+\r
+randomStream                                   :: !Int !([Int] -> a) !RandomSeed -> Stream a\r
+randomStream nrInts transform seed\r
+       # (ints,seed)                           = randoms nrInts seed\r
+       = [transform ints : randomStream nrInts transform seed]\r
+where\r
+       randoms                                         :: !Int !RandomSeed -> (![Int],!RandomSeed)\r
+       randoms 0 seed                          = ([],seed)\r
+       randoms n seed\r
+               # (r, seed)                             = random seed\r
+               # (rs,seed)                             = randoms (n-1) seed\r
+               = ([r:rs],seed)\r
+\r
+intRandomStream                                        :: !RandomSeed -> Stream Int\r
+intRandomStream seed                   = randomStream 2 createInt seed\r
+where\r
+       createInt                                       :: ![Int] -> Int\r
+       createInt [a,b]                         = if (isOdd a) -1 1 * (abs b)\r
+       createInt _                                     = abort "Fatal error: intRandomStream applied to unexpected number of integers.\n"\r
+\r
+realRandomStream                               :: !RandomSeed -> Stream Real\r
+realRandomStream seed                  = randomStream 4 createReal seed\r
+where\r
+       createReal                                      :: ![Int] -> Real\r
+       createReal [s,a,b,c]            = toReal (if (isOdd s) "-" "" <+++ abs a <+++ "." <+++ abs b <+++ "E" <+++ (c rem 100))\r
+       createReal _                            = abort "Fatal error: realRandomStream applied to unexpected number of integers.\n"\r
+\r
+boolRandomStream                               :: !RandomSeed -> Stream Bool\r
+boolRandomStream seed                  = randomStream 1 createBool seed\r
+where\r
+       createBool                                      :: ![Int] -> Bool\r
+       createBool [i]                          = isEven i\r
+       createBool _                            = abort "Fatal error: boolRandomStream applied to unexpected number of integers.\n"\r
+\r
+probabilityRandomStream                        :: !RandomSeed -> Stream P\r
+probabilityRandomStream seed   = randomStream 2 createProbability seed\r
+where\r
+       createProbability                       :: ![Int] -> P\r
+       createProbability [a,b]\r
+               | b==0                                  = 1.0\r
+               | otherwise                             = (toReal a`) / (toReal b`)\r
+       where\r
+               [a`,b`:_]                               = sort [abs a,abs b]\r
+       createProbability _                     = abort "Fatal error: probabilityRandomStream applied to unexpected number of integers.\n"\r
+\r
+onesStream                                             :: Stream P\r
+onesStream                                             = [one,one..]\r
+\r
+nextRandomInt                                  :: !RandomSeed -> .(!Int, !RandomSeed)\r
+nextRandomInt seed\r
+       # (r1,seed)                                     = random seed\r
+       # (r2,seed)                                     = random seed\r
+       = (if (isOdd r1) -1 1 * (abs r2),seed)\r
+\r
+nextRandomReal                                 :: !RandomSeed -> .(!Real,!RandomSeed)\r
+nextRandomReal seed\r
+       # (r1,seed)                                     = random seed\r
+       # (r2,seed)                                     = random seed\r
+       # (r3,seed)                                     = random seed\r
+       # (r4,seed)                                     = random seed\r
+       = (toReal (if (isOdd r1) "-" "" <+++ abs r2 <+++ "." <+++ abs r3 <+++ "E" <+++ (r4 rem 100)),seed)\r
+       \r
+nextRandomBool                                 :: !RandomSeed -> .(!Bool,!RandomSeed)\r
+nextRandomBool seed\r
+       # (r1,seed)                                     = random seed\r
+       = (isEven r1,seed)\r
+\r
+nextRandomP                                            :: !RandomSeed -> .(!P,   !RandomSeed)\r
+nextRandomP seed\r
+       # (r1,seed)                                     = random seed\r
+       # (r2,seed)                                     = random seed\r
+       # (a,b)                                         = minmax (abs r1,abs r2)\r
+       = (if (r2==0) 1.0 ((toReal a)/(toReal b)),seed)\r
+\r
+next1                                                  :: !RandomSeed -> .(!P,   !RandomSeed)\r
+next1 seed                                             = (1.0,seed)\r
+\r
+/** make the random realistic, as in, small errors occur more often:\r
+               \r -> 1.0-r^4\r
+               zero <= r <= 1.0\r
+*/\r
+makeRandomRealistic                            :: !P -> P\r
+makeRandomRealistic r                  = 1.0-r^4.0\r
+\r
+makeRandomRealisticSkilled             :: !P -> P\r
+makeRandomRealisticSkilled r   = 1.0-r^10.0\r
+\r
+selectMostProbableAction               :: ![(P,a)] !RandomSeed -> (!Maybe a,!RandomSeed)\r
+selectMostProbableAction odds seed\r
+       = case sortBy (\(p1,_) (p2,_) -> p1 > p2) (filter (\(p,_) -> p > zero) odds) of\r
+               []                                              = (Nothing,seed)\r
+               odds=:[(p,_):_]                 = let mostProbable      = takeWhile ((==) p o fst) odds\r
+                                                                     nr                        = length mostProbable\r
+                                                                     (p1,seed1)        = nextRandomP seed\r
+                                                                  in (Just (snd (odds !! (entier (p1 * toReal nr)))),seed1)\r
diff --git a/src/Gui/Gui2D.dcl b/src/Gui/Gui2D.dcl
new file mode 100644 (file)
index 0000000..9e8bb8d
--- /dev/null
@@ -0,0 +1,6 @@
+definition module Gui2D\r
+\r
+/**    This module implements a simple SDI GUI for Soccer-Fun.\r
+*/\r
+\r
+SoccerFunGUI2D :: !*World -> *World\r
diff --git a/src/Gui/Gui2D.icl b/src/Gui/Gui2D.icl
new file mode 100644 (file)
index 0000000..53902a3
--- /dev/null
@@ -0,0 +1,571 @@
+implementation module Gui2D\r
+\r
+import StdEnvExt, StdIOExt\r
+import fileIO\r
+import digitdisplay, textdisplay, render, matchGame, RangeSlider\r
+import StdDebug\r
+\r
+SoccerFunGUI2D                                         :: !*World -> *World\r
+SoccerFunGUI2D world\r
+# (theGame, world)                                     = getBeginMatch world\r
+# (ids,     world)                                     = openIds 4 world\r
+# (displIds,world)                                     = sseqList (repeatn 2 openDigitDisplayId) world\r
+# (teamdIds,world)                                     = sseqList (repeatn 5 openTextDisplayId)  world\r
+# (frameId, world)                                     = openTextDisplayId world\r
+= startIO SDI theGame (initGUI (ids,displIds,teamdIds,frameId)) [ProcessClose closeProcess] world\r
+where\r
+       getBeginMatch                                   :: !*env -> (!FootballGame,!*env) | TimeEnv, FileSystem env\r
+       getBeginMatch env\r
+       | isEmpty teams                                 = abort "There are no teams.\nPlease add teams to \"allAvailableTeams\" in the \"Team\"-module\n"       \r
+       | isEmpty referees                              = abort "There are no referees.\nPlease add referees to \"allAvailableReferees\" in the \"Referee\"-module\n"\r
+       # (whatToLog,env)                               = getWhatToLog     env\r
+       # (options,  env)                               = getOptions       env\r
+       # (seed,     env)                               = getNewRandomSeed env\r
+       # match                                                 = setMatchStart (hd teams West field) (hd teams East field) field (hd referees field) options.Options.playingTime seed\r
+       = ( { match                                             = match\r
+               , actionPics                            = {refereePics=[]}\r
+               , history                                       = {time=s 2.0,past=[]}\r
+               , frames                                        = 0\r
+               , options                                       = options\r
+               , logging                                       = whatToLog\r
+               }\r
+         , env\r
+         )\r
+       where\r
+               teams                                           = allAvailableTeams\r
+               referees                                        = allAvailableReferees\r
+               field                                           = getDefaultField\r
+\r
+       initGUI                                                 :: !(![Id],![DigitDisplayId],![TextDisplayId],!TextDisplayId) !(PSt FootballGame) -> (PSt FootballGame) \r
+       initGUI ([timerId,fieldId,windowId,splashId],[westId,eastId],[team1Id,team2Id,halfId,timeId,refId],framesId) pSt=:{ls=ls=:{match=matchAtStart,options}}\r
+       # (penAtts,  pSt)                               = accPIO renderAttributes pSt\r
+       # (penFont,  pSt)                               = accPIO (accScreenPicture (openFont {fName="Courier New",fSize=32,fStyles=[BoldStyle]})) pSt\r
+       # (frameFont,pSt)                               = accPIO (accScreenPicture (openFont {fName="Courier New",fSize=16,fStyles=[BoldStyle]})) pSt\r
+       # (underFont,pSt)                               = accPIO (accScreenPicture (openFont {fName="Courier New",fSize=12,fStyles=[BoldStyle]})) pSt\r
+       # refsName                                              = nameOf matchAtStart.Match.theReferee\r
+       # wDef                                                  = Window "SoccerFun: Van Gaal's Electronic Notebook" \r
+                                                                               (       LayoutControl\r
+                                                                                       (           teamName team1Id (nameOf matchAtStart.Match.team1) (snd penFont) WestColour\r
+                                                                                               :+: DigitDisplay  westId (IntegerFormat 2) digitDisplaySize WestColour []\r
+                                                                                               :+: DigitDisplay  eastId (IntegerFormat 2) digitDisplaySize EastColour []\r
+                                                                                               :+: teamName team2Id (nameOf matchAtStart.Match.team2) (snd penFont) EastColour\r
+                                                                                       )       [ ControlPos (Center,zero) ]\r
+                                                                                       :+: fpsDisplay framesId frameRatePrefix (snd frameFont) Green \r
+                                                                                       :+:     CustomControl footballFieldDisplaySize (options.renderStyle.look ls.match)\r
+                                                                                                       [ ControlId     fieldId\r
+                                                                                                       , ControlPen    penAtts\r
+                                                                                                       , ControlPos    (Center,zero)\r
+                                                                                                       , ControlResize (\_ _ wViewSize=:{h} -> {wViewSize & h=h-digitDisplaySize.h-60})\r
+                                                                                                       ]\r
+                                                                                       :+: TextDisplay halfId (showHalf matchAtStart.Match.playingHalf) {w=80,h=15}\r
+                                                                                                       [ ControlPen [PenColour White,PenBack Black,PenFont (snd underFont)]\r
+                                                                                                       //, ControlResize (\_ _ size -> {size & h=size.h-digitDisplaySize.h})\r
+                                                                                                       , ControlPos (LeftBottom,OffsetVector {vx=10,vy=(~7)})\r
+                                                                                                       ]\r
+                                                                                       :+: TextDisplay timeId (toString matchAtStart.Match.playingTime) {w=100,h=15}\r
+                                                                                                       [ ControlPen [PenColour White,PenBack Black,PenFont (snd underFont)]\r
+                                                                                                       , ControlPos (Center,OffsetVector {vx=zero,vy=zero})\r
+                                                                                                       ]\r
+                                                                                       :+: TextDisplay refId refsName {w=80+(12*(size refsName)),h=15}\r
+                                                                                                       [ ControlPen [PenColour White,PenBack Black,PenFont (snd underFont)]\r
+                                                                                                       , ControlPos (RightBottom,OffsetVector {vx=zero,vy=(~7)})//(3*(size "test"))\r
+                                                                                                       ]\r
+                                                                               )\r
+                                                                               [ WindowViewSize        {w=footballFieldDisplaySize.w-1, h=footballFieldDisplaySize.h+digitDisplaySize.h}\r
+                                                                               , WindowLook False      stdUnfillNewFrameLook\r
+                                                                               , WindowPen                     [PenBack Black]\r
+                                                                               , WindowId                      windowId\r
+                                                                               ]\r
+       # (error,pSt)                                   = openWindow undef wDef pSt\r
+       # pSt                                                   = setDigitDisplayValue westId (fst ls.match.score) pSt\r
+       # pSt                                                   = setDigitDisplayValue eastId (snd ls.match.score) pSt\r
+       | error<>NoError                                = abort "Could not create window.\n"\r
+       # speed                                                 = intervalFactor ls.options.displaySpeed\r
+       # tDef                                                  = Timer (toInt ((toReal ticksPerSecond)*(toReal matchAtStart.Match.unittime)*speed)) NilLS \r
+                                                                               [ TimerFunction    (noLS1 (const (nextstep timerId fieldId westId eastId)))\r
+                                           , TimerId          timerId\r
+                                                   , TimerSelectState Unable\r
+                                               ]\r
+       # (error,pSt)                                   = openTimer undef tDef pSt\r
+       | error<>NoError                                = abort "Could not create step timer.\n"\r
+       # tDef                                                  = Timer ticksPerSecond NilLS        [TimerFunction (noLS1 (const (frameRatef timeId halfId framesId)))]\r
+       # (error,pSt)                                   = openTimer undef tDef pSt\r
+       | error<>NoError                                = abort "Could not open frame rate timer.\n"\r
+       # mDef                                                  = Menu "&File"\r
+                                                                               (       MenuItem "E&xit"            [MenuShortKey 'q',MenuFunction (noLS quitf)]\r
+                                                                               )       []\r
+       # (error,pSt)                                   = openMenu undef mDef pSt\r
+       | error<>NoError                                = abort "Could not create File menu.\n"\r
+       # mDef2                                                 = Menu "&Game"\r
+                                                                               (   MenuItem "&Match"           [MenuShortKey 'm',MenuFunction (noLS (matchDialogf westId eastId fieldId timerId refId team1Id team2Id))]\r
+                                                                               :+: MenuItem "Competition"      [MenuShortKey 'u',MenuFunction (noLS (competitionDialogf timerId refId))]\r
+                                                                               :+: MenuSeparator               []\r
+                                                                               :+: MenuItem "&Run"             [MenuShortKey 'r',MenuFunction (noLS (continuef timerId))]\r
+                                                                               :+:     MenuItem "&Step"            [MenuShortKey 's',MenuFunction (noLS (stepf timerId fieldId westId eastId))]\r
+                                                                               :+:     MenuItem "&Halt"            [MenuShortKey 'h',MenuFunction (noLS (haltf timerId))]\r
+                                                                               :+: MenuSeparator               []\r
+                                                                               :+: SubMenu "&Mode"             ( RadioMenu [ ("&Realistic",  Nothing,Nothing,noLS realisticf)\r
+                                                                                                                           , ("&Predictable",Nothing,Nothing,noLS predictablef)\r
+                                                                                                                           ] 0 []\r
+                                                                                                               ) []\r
+                                                                               :+: SubMenu "Sp&eed"            ( RadioMenu [ ("&Slowest",Nothing, Just '1', noLS (changeSpeedf timerId Slowest))\r
+                                                                                                                               , ("S&lower", Nothing, Just '2', noLS (changeSpeedf timerId Slower))\r
+                                                                                                                               , ("N&ormal", Nothing, Just '3', noLS (changeSpeedf timerId Normal))\r
+                                                                                                                               , ("&Faster", Nothing, Just '4', noLS (changeSpeedf timerId Faster))\r
+                                                                                                                               , ("Fas&test",Nothing, Just '5', noLS (changeSpeedf timerId Fastest))\r
+                                                                                                                               ] ([Slowest,Slower,Normal,Faster,Fastest]??options.displaySpeed+1) []\r
+                                                                                                                   ) []\r
+                                                                               :+: SubMenu "Re&feree"          ( RadioMenu [ ("&Show",   Nothing, Just '+', noLS (showReff True))\r
+                                                                                                                               , ("&NoShow", Nothing, Just '-', noLS (showReff False))\r
+                                                                                                                               ] ([True,False]??options.showReferee+1) []\r
+                                                                                                                                   ) []\r
+                                                                               :+: SubMenu "R&ender"           ( RadioMenu [ (nameOf style, Nothing, Nothing, noLS (setfieldlook fieldId style))\r
+                                                                                                                           \\ style <- allRenderStyles \r
+                                                                                                                           ] ((map nameOf allRenderStyles)??(nameOf options.renderStyle)+1) []\r
+                                                                                                               ) []\r
+                                                                               :+: MenuItem "&Playing Time..." [MenuFunction (noLS (playtimef westId eastId fieldId timeId)), MenuShortKey 't']\r
+                                                                               :+: MenuItem "Splash screen"    [MenuFunction (noLS (setSplashScreenf splashId)),MenuMarkState (if options.showSplash Mark NoMark),MenuId splashId]\r
+                                                                               )       []\r
+       # (error,pSt)                                   = openMenu undef mDef2 pSt\r
+       | error<>NoError                                = abort "Could not create Game menu.\n"\r
+       # pSt                                                   = appPIO (setWindowViewSize windowId {w=640,h=550}) pSt\r
+       # pSt                                                   = showSplashScreen pSt\r
+       = pSt\r
+\r
+       showSplashScreen                                :: !(PSt FootballGame) -> PSt FootballGame\r
+       showSplashScreen pSt=:{ls=game}\r
+       | not game.options.showSplash   = pSt\r
+       # (spls,pSt)                                    = getSplashImageForGui pSt\r
+       # splashDef                                             = Dialog "The Footballer's Mind"\r
+                                                                               (       CompoundControl \r
+                                                                                       (       ButtonControl "&Close" [ControlFunction (noLS closeActiveWindow)]\r
+                                                                                       )\r
+                                                                                       [       ControlLook True (const2 (drawAt zero spls.img))\r
+                                                                                       ,       ControlViewSize  (getBitmapSize spls.img)\r
+                                                                                       ]\r
+                                                                               ) []\r
+       # ((error,_),pSt)                               = openModalDialog undef splashDef pSt\r
+       | error<>NoError                                = abort "Could not open splash screen.\n"\r
+       | otherwise                                             = pSt\r
+\r
+\r
+//     Constants for the GUI:\r
+digitDisplaySize                                       = { w=24, h=36 }\r
+footballFieldDisplaySize                       = { w=640,h=400}\r
+frameRatePrefix                                                :== "Rounds/sec: "\r
+\r
+//     GUI elements:\r
+\r
+/** teamName id name font colour\r
+               describes a TextDisplay that is identified by id, has text content name, uses the given font in the given colour.\r
+*/\r
+teamName                                                       :: TextDisplayId String Font Colour -> TextDisplay .ls .pst\r
+teamName id name penFont colour                = TextDisplay id name (teamSize footballFieldDisplaySize)\r
+                                                                               [ ControlPen [PenColour colour,PenBack Black,PenFont penFont]\r
+                                                                               , ControlResize (const2 teamSize)\r
+                                                                               ]\r
+where teamSize {w}                                     = {digitDisplaySize & w=(w-digitDisplaySize.w*4)/2}\r
+\r
+/** fpsDisplay id name font colour\r
+               describes a TextDisplay that is used to display the frame rate of a match.\r
+*/\r
+fpsDisplay                                                     :: TextDisplayId String Font Colour -> TextDisplay .ls .pst\r
+fpsDisplay id name penFont colour      = TextDisplay id name {digitDisplaySize & w=300} \r
+                                                                               [ ControlPen [PenColour colour, PenBack Black, PenFont penFont]\r
+                                                                       , ControlPos (Center,zero)\r
+                                                                               ]\r
+\r
+\r
+//     The callback functions of the GUI:\r
+\r
+/** setSplashScreenf splashId pSt\r
+               sets the check mark of the menu item that controls the splash screen option, and updates the Options record in the state accordingly.\r
+*/\r
+setSplashScreenf                                       :: !Id !(PSt FootballGame) -> PSt FootballGame\r
+setSplashScreenf splashId pSt=:{ls=game}\r
+| game.options.showSplash                      = appPIO (unmarkMenuItems [splashId]) {pSt & ls={game & options={game.options & showSplash = False}}}\r
+| otherwise                                                    = appPIO (markMenuItems   [splashId]) {pSt & ls={game & options={game.options & showSplash = True}}}\r
+\r
+/** quitf pSt\r
+               stores the current options to disk and terminates the parent interactive process.\r
+*/\r
+quitf                                                          :: !(PSt FootballGame) -> PSt FootballGame\r
+quitf pSt=:{ls=game}\r
+       # pSt                                                   = setOptions game.options pSt\r
+       # pSt                                                   = closeProcess pSt\r
+       = pSt\r
+\r
+/** continuef timerId pSt\r
+               continues the simulation of the current match.\r
+*/\r
+continuef                                                      :: !Id !(PSt FootballGame) -> PSt FootballGame\r
+continuef timerId pSt                          = appPIO (enableTimer timerId) pSt\r
+\r
+/** haltf timerId pSt\r
+               stops the simulation of the current match.\r
+*/\r
+haltf                                                          :: !Id !(PSt FootballGame) -> PSt FootballGame\r
+haltf timerId pSt                                      = appPIO (disableTimer timerId) pSt\r
+\r
+/** stepf timerId fieldId westId eastId pSt\r
+               stops the simulation of the current match, and computes a single step of the current match.\r
+*/\r
+stepf :: !Id !Id !DigitDisplayId !DigitDisplayId -> IdFun (PSt FootballGame)\r
+stepf timerId fieldId westId eastId    = nextstep timerId fieldId westId eastId o haltf timerId\r
+\r
+/** nextstep timerId fieldId westId eastId pSt\r
+               computes a single step for the current match, renders the new state of the match, and displays the referee dialog if required.\r
+*/\r
+nextstep                                                       :: !Id !Id !DigitDisplayId !DigitDisplayId !(PSt FootballGame) -> PSt FootballGame\r
+nextstep timerId fieldId westId eastId pSt=:{ls=game,io}\r
+       # (refEvents,game,io)                   = stepMatchForGui game io\r
+       # pSt                                                   = {pSt & io = setControlLook fieldId True (False,game.options.renderStyle.look game.match) io\r
+                                                                              , ls = incFrames game\r
+                                                                         }\r
+       = analyseRefEvents refEvents pSt\r
+where\r
+       analyseRefEvents                                :: ![RefereeAction] !(PSt FootballGame) -> PSt FootballGame\r
+       analyseRefEvents refEvents pSt  = foldl analyseRefEvent pSt refEvents\r
+       where\r
+               analyseRefEvent :: !(PSt FootballGame) !RefereeAction -> PSt FootballGame\r
+               analyseRefEvent pSt=:{ls=ls=:{FootballGame | match={score,playingHalf}}} rev\r
+               | or (apply rev [isContinueGame,isDisplacePlayers,isDirectFreeKick,isCenterKick,isPauseGame,isAddTime])\r
+                                                                       = pSt\r
+               # pSt                                           = refereeDialog rev pSt\r
+               # pSt                                           = if (isGameOver rev) (appPIO (disableTimer timerId) pSt) pSt\r
+               = case rev of\r
+                       Goal h                                  = if (h == West && playingHalf == FirstHalf || h == East && playingHalf == SecondHalf)\r
+                                                                            (setDigitDisplayValue westId (fst score) pSt)\r
+                                                                            (setDigitDisplayValue eastId (snd score) pSt)\r
+                       no_goal                                 = pSt\r
+               \r
+               refereeDialog                           :: !RefereeAction !(PSt FootballGame) -> PSt FootballGame\r
+               refereeDialog rev pSt=:{ls=ls=:{match=match=:{theReferee=referee=:{Referee | name}}}}\r
+               | not pSt.ls.options.showReferee\r
+                                                                       = pSt\r
+               # pSt                                           = case defaultSoundFile rev of\r
+                                                                               Just sound      = appPIO (makeSound sound) pSt\r
+                                                                               nothing         = pSt\r
+               # pSt                                           = haltf timerId pSt\r
+               # (image,pSt)                           = accPIO (defaultImage match rev) pSt\r
+               # (closeId, pSt)                        = openId pSt\r
+               # (dialogId,pSt)                        = openId pSt\r
+               # tDef                                          = Timer (3*ticksPerSecond) NilLS [ TimerFunction (noLS1 (const ((continuef timerId) o (closeWindow dialogId) o (appPIO (closeTimer closeId)))))\r
+                                                                                                        , TimerId       closeId\r
+                                                                                                        ]\r
+               # (error,  pSt)                         = openTimer undef tDef pSt\r
+               | error<>NoError                        = abort "Could not open referee dialog timer.\n"\r
+               # refereeDef                            = Dialog ("Referee " <+++ name)\r
+                                                                               (       TextControl (showSuccintRefereeAction rev) []\r
+                                                                               :+: CustomControl (getBitmapSize image) (const2 (drawAt zero image)) []\r
+                                                                               )       [WindowId dialogId]\r
+               # ((error,_),pSt)                       = openModalDialog undef refereeDef pSt\r
+               | error<>NoError                        = abort "Could not open referee dialog.\n"\r
+               | otherwise                                     = pSt\r
+\r
+/** showReff show pSt\r
+               sets the option to show the referee during simulation.\r
+*/\r
+showReff                                                       :: !Bool !(PSt FootballGame) -> PSt FootballGame\r
+showReff show pSt                                      = {pSt & ls = {pSt.ls & options = {pSt.ls.options & showReferee = show}}}\r
+\r
+/** playtimef westId eastId fieldId timeId pSt\r
+               opens the dialog to alter the play time of a match.\r
+*/\r
+playtimef                                                      :: !DigitDisplayId !DigitDisplayId !Id !TextDisplayId !(PSt FootballGame) -> PSt FootballGame\r
+playtimef westId eastId fieldId timeId pSt=:{ls=game=:{options={Options | playingTime}}}\r
+       # (dialogId,pSt)                                = openId pSt\r
+       # (textId,  pSt)                                = openId pSt\r
+       # (sliderId,pSt)                                = openRangeSliderId pSt\r
+       # playingtimeDef                                = Dialog "Playing Time"\r
+                                                                               (   TextControl (toString playingTime) [ControlId textId, ControlPos (Center,zero),ControlWidth (ContentWidth (toString (maxList times)))]\r
+                                                                               :+: RangeSlider sliderId Horizontal (PixelWidth 16) {values=times,index=times??playingTime} (noLS1 (setPlayingTime westId eastId textId)) []\r
+                                                                               :+: ButtonControl "Close" [ControlFunction (noLS (closeWindow dialogId)),ControlPos (Right,zero)]\r
+                                                                               )\r
+                                                                               [ WindowClose (noLS (closeWindow dialogId))\r
+                                                                               , WindowId dialogId\r
+                                                                               ]\r
+       # ((error,_),pSt)                               = openModalDialog undef playingtimeDef pSt\r
+       | error <> NoError                              = abort "Could not open Playing Time dialog.\n"\r
+       | otherwise                                             = pSt\r
+where\r
+       times                                                   = map minutes [0.5, 1.0 .. 10.0]\r
+       \r
+       setPlayingTime westId eastId textId newtime pSt=:{ls=game}\r
+               # pSt                                           = setTextDisplayText timeId display_time pSt\r
+               # pSt                                           = appPIO (setControlText textId display_time) pSt\r
+               # pSt                                           = {pSt & ls = {game & options = {Options | game.options & playingTime=newtime}\r
+                                                                                           , match   = {Match   | game.match   & playingTime=newtime}\r
+                                                                         }           }\r
+               # pSt                                           = restartf westId eastId fieldId pSt\r
+               = pSt\r
+       where\r
+               display_time                            = toString newtime\r
+\r
+/** changeteamf fieldId team1Id team2Id home team pSt\r
+               replaces the current team at home with the given team. The display name of the team is adapted, and the match is to the beginning of the first half.\r
+*/\r
+changeteamf                                                    :: !DigitDisplayId !DigitDisplayId !Id !TextDisplayId !TextDisplayId !Home !Team !(PSt FootballGame) -> PSt FootballGame\r
+changeteamf westId eastId fieldId team1Id team2Id home team pSt=:{ls=game=:{match,options},io}\r
+       # match                                                 = {Match | match & team1 = if (home == West) team match.Match.team1, team2 = if (home == East) team match.Match.team2}\r
+       # pSt                                                   = {pSt   & ls = {game & match=match}}\r
+       # pSt                                                   = setTextDisplayText (if (home == West) team1Id team2Id) (nameOf team) pSt\r
+       # pSt                                                   = restartf westId eastId fieldId pSt\r
+       = pSt\r
+\r
+/** changereff timerId refId referee pSt\r
+               replaces the current referee with the given referee and adapts the display name of the new referee.\r
+*/\r
+changereff                                                     :: !Id !TextDisplayId !Referee !(PSt FootballGame) -> PSt FootballGame\r
+changereff timerId refId ref=:{Referee | name} pSt\r
+       # pSt                                                   = setTextDisplayText refId name pSt //todo: de positionering moet aangepast worden \r
+       = appPIO (disableTimer timerId) {pSt & ls={pSt.ls & match = {pSt.ls.match & theReferee = ref}}}\r
+\r
+/** restartf fieldId pSt\r
+               makes sure that the current match is reinitialized to the initial teams, referee, and ball position.s\r
+*/\r
+restartf                                                       :: !DigitDisplayId !DigitDisplayId !Id !(PSt FootballGame) -> PSt FootballGame\r
+restartf westId eastId fieldId pSt=:{ls=game=:{match,options},io}\r
+       # match                                                 = {match & theBall     = Free zero\r
+                                                                                , playingHalf = FirstHalf\r
+                                                                                , playingTime = options.Options.playingTime\r
+                                                                                , score       = (0,0)\r
+                                                                                , theReferee  = getRefereeFresh   match.Match.theField (nameOf match.Match.theReferee)\r
+                                                                                , team1       = getTeamFresh West match.Match.theField (nameOf match.Match.team1)\r
+                                                                                , team2       = getTeamFresh East match.Match.theField (nameOf match.Match.team2)\r
+                                                                         }\r
+       # pSt                                                   = setDigitDisplayValue westId 0 pSt\r
+       # pSt                                                   = setDigitDisplayValue eastId 0 pSt\r
+       = {pSt & ls = {game & match=match}\r
+              , io = setControlLook fieldId True (False,options.renderStyle.look match) io\r
+         }\r
+where\r
+       getRefereeFresh                                 :: !FootballField !String -> Referee\r
+       getRefereeFresh field name              = hd [r field \\ r <- allAvailableReferees | nameOf (r field) == name]\r
+       \r
+       getTeamFresh                                    :: !Home !FootballField !String -> Team\r
+       getTeamFresh home field name    = hd [t \\ t <- getAllTeamsOfHome home field | nameOf t == name]\r
+\r
+/**    setfieldlook fieldId style pSt\r
+               sets a new rendering style for the football field\r
+*/\r
+setfieldlook                                           :: !Id !RenderStyle !(PSt FootballGame) -> PSt FootballGame\r
+setfieldlook fieldId style=:{look} pSt=:{ls=game=:{match,options},io}\r
+       = {pSt & ls = {game & options = {options & renderStyle = style}}\r
+              , io = setControlLook fieldId True (False,look match) io\r
+         }\r
+       \r
+\r
+/** changeSpeedf timerId speed pSt\r
+               modifies the current simulation speed of a match.\r
+*/\r
+changeSpeedf                                           :: !Id !DisplaySpeed !(PSt FootballGame) -> PSt FootballGame\r
+changeSpeedf timerId speed pSt=:{ls}\r
+       # timerInterval                                 = toInt ((toReal ticksPerSecond)*(toReal ls.match.Match.unittime)*(intervalFactor speed))\r
+       # pSt                                                   = {pSt & ls = {FootballGame | ls & options = {Options | ls.options & displaySpeed = speed}}}\r
+       = appPIO (setTimerInterval timerId timerInterval) pSt\r
+\r
+/** realisticf pSt\r
+               sets a true pseudo-random generating function.\r
+*/\r
+realisticf                                                     :: !(PSt FootballGame) -> PSt FootballGame\r
+realisticf pSt=:{ls=ls=:{match}}       = {pSt & ls={FootballGame | ls & match={match & nextRandomP=nextRandomP}}}\r
+\r
+/** predictablef pSt\r
+               sets a 'random-generating' function that always yields 1.0.\r
+*/\r
+predictablef                                           :: !(PSt FootballGame) -> PSt FootballGame\r
+predictablef pSt=:{ls=ls=:{match}}     = {pSt & ls={FootballGame | ls & match={match & nextRandomP=next1}}}\r
+\r
+/** frameRatef timeId halfId framesId pSt\r
+               updates the current playing time and playing half information, as well as the frame rate counter, which is reset every second.\r
+*/\r
+frameRatef                                                     :: !TextDisplayId !TextDisplayId !TextDisplayId !(PSt FootballGame) -> PSt FootballGame\r
+frameRatef timeId halfId framesId pSt=:{ls=ls=:{frames,match={Match | playingTime,playingHalf}}}\r
+       # pSt                                                   = setTextDisplayText timeId (toString playingTime) pSt\r
+       # pSt                                                   = setTextDisplayText halfId (showHalf playingHalf) pSt\r
+       = setTextDisplayText framesId (frameRatePrefix <+++ frames) {pSt & ls={ls & frames=0}}\r
+\r
+/** matchDialogf westId eastId fieldId timerId refId team1Id team2Id pSt\r
+               opens a dialog in which the user can select two teams that play a match, and a referee to control the match.\r
+*/\r
+matchDialogf                                           :: DigitDisplayId DigitDisplayId Id Id TextDisplayId TextDisplayId TextDisplayId (PSt FootballGame) -> PSt FootballGame\r
+matchDialogf westId eastId fieldId timerId refId team1Id team2Id pSt=:{ls=game}\r
+       # (dialogId,pSt)                                = openId pSt\r
+       # dialog                                                = Dialog "Choose Match"\r
+                                                                               (       LayoutControl\r
+                                                                                   (   TextControl "Choose Team West" [ControlPos (Center,zero)]\r
+                                                                                   :+: LayoutControl\r
+                                                                                       (   RadioControl [  (nameOf t,Nothing,noLS (changeteamf westId eastId fieldId team1Id team2Id West t)) \r
+                                                                                                        \\ t <- teams West\r
+                                                                                                        ] (Columns 1) ((map nameOf (teams West)) ?? (nameOf game.match.Match.team1)+1) []\r
+                                                                                       ) [ControlPos (Center,zero)]\r
+                                                                                   ) [ControlPos (Left,zero)]\r
+                                                                               :+: LayoutControl\r
+                                                                                   (   TextControl "Choose Team East" [ControlPos (Center,zero)]\r
+                                                                                   :+: LayoutControl\r
+                                                                                       (   RadioControl [  (nameOf t,Nothing,noLS (changeteamf westId eastId fieldId team1Id team2Id East t)) \r
+                                                                                                        \\ t <- teams East\r
+                                                                                                        ] (Columns 1) ((map nameOf (teams East)) ?? (nameOf game.match.Match.team2)+1) []\r
+                                                                                       ) [ControlPos (Center,zero)]\r
+                                                                                   ) [ControlPos (RightToPrev,zero)]\r
+                                                                               :+: LayoutControl\r
+                                                                                   (   TextControl "Choose Referee" [ControlPos (Center,zero)]\r
+                                                                                   :+: LayoutControl\r
+                                                                                       (   RadioControl [  (nameOf r,Nothing,noLS (changereff timerId refId r)) \r
+                                                                                                        \\ r <- apply field allAvailableReferees\r
+                                                                                                        ] (Columns 1) ((map nameOf (apply field allAvailableReferees)) ?? (nameOf game.match.theReferee)+1) []\r
+                                                                                       ) [ControlPos (Center,zero)]\r
+                                                                                   ) [ControlPos (RightToPrev,zero)]\r
+                                                                               :+: ButtonControl "Ok" [ControlFunction (closef dialogId),ControlPos (Right,zero)]\r
+                                                                               )\r
+                                                                               [ WindowClose (closef dialogId)\r
+                                                                               , WindowId    dialogId\r
+                                                                               ]\r
+       # ((error,_),pSt)                               = openModalDialog undef dialog pSt\r
+       | error <> NoError                              = abort "Could not open match dialog.\n"\r
+       | otherwise                                             = pSt\r
+where\r
+       teams home                                              = getAllTeamsOfHome home field\r
+       field                                                   = game.match.theField\r
+       closef dialogId                                 = noLS (restartf westId eastId fieldId o closeWindow dialogId)\r
+\r
+/** competitionDialogf timerId refId pSt\r
+               opens a dialog in which the user can select the teams that participate in a full competition; i.e. each team plays against each other at either home side of\r
+               the football field. Once the teams and referee are selected, all matches are computed, and the final ranking is displayed.\r
+*/\r
+competitionDialogf                                     :: Id TextDisplayId (PSt FootballGame) -> PSt FootballGame\r
+competitionDialogf timerId refId pSt=:{ls=game}\r
+       # (dialogId,pSt)                                = openId pSt\r
+       # (teamsId, pSt)                                = openId pSt\r
+       # dialog                                                = Dialog "Competition"\r
+                                                                               (       LayoutControl\r
+                                                                                       (       TextControl "Choose Teams West" [ControlPos (Center,zero)]\r
+                                                                                       :+: LayoutControl\r
+                                                                                               (       CheckControl [(nameOf t,Nothing,Mark,id) \\ t <- teams_west] (Columns 1) [ControlId teamsId]\r
+                                                                                       ) [ControlPos (Center,zero)]\r
+                                                                                   :+: ButtonControl "Select &All" \r
+                                                                                               [ControlFunction (noLS (selectTeams teamsId (index_all_teams,index_no_teams))),ControlPos (Left,zero)]\r
+                                                                                   :+: ButtonControl "Cl&ear All" \r
+                                                                                               [ControlFunction (noLS (selectTeams teamsId (index_no_teams,index_all_teams))),ControlPos (RightToPrev,zero)]\r
+                                                                                   ) [ControlPos (Left,zero)]\r
+                                                                               :+: LayoutControl\r
+                                                                                   (   TextControl "Choose Referee" [ControlPos (Center,zero)]\r
+                                                                                   :+: LayoutControl\r
+                                                                                       (   RadioControl [(nameOf r,Nothing,noLS (changereff timerId refId r)) \\ r <- apply field allAvailableReferees] (Columns 1) 1 []\r
+                                                                                       ) [ControlPos (Center,zero)]\r
+                                                                                   ) [ControlPos (RightToPrev,zero)]\r
+                                                                               :+: ButtonControl "Ok" [ControlFunction (noLS (startCompetition teamsId dialogId)),ControlPos (Right,zero)]\r
+                                                                               )\r
+                                                                               [ WindowClose (noLS (closeWindow dialogId))\r
+                                                                               , WindowId    dialogId\r
+                                                                               , WindowPos   (Center,OffsetVector {zero & vy=100})\r
+                                                                               ]\r
+       # ((error,_),pSt)                               = openModalDialog undef dialog pSt\r
+       | error <> NoError                              = abort "Could not open competition dialog.\n"\r
+       | otherwise                                             = pSt\r
+where\r
+       teams home                                              = getAllTeamsOfHome home field\r
+       teams_west                                              = teams West\r
+       index_all_teams                                 = [1 .. length teams_west]\r
+       index_no_teams                                  = []\r
+       field                                                   = game.match.theField\r
+       \r
+       selectTeams checkId (set,clear) = appPIO (markCheckControlItems checkId set o unmarkCheckControlItems checkId clear)\r
+       \r
+       startCompetition checkId dialogId pSt=:{ls=game}\r
+       = case accPIO (getWindow dialogId) pSt of\r
+               (Nothing, pSt)                          = abort "Fatal error: could not retrieve competition dialog data.\n"    // should be impossible, because the dialog has not been closed yet\r
+               (Just wSt,pSt=:{ls=game})\r
+               = case getCheckControlSelection checkId wSt of\r
+                       (_,Nothing)                             = closeWindow dialogId pSt\r
+                       (_,Just idxs)\r
+                               # (teams,names)         = unzip [(t,nameOf (t West game.match.theField)) \\ t <- allAvailableTeams & i <- [1..] | isMember i idxs]\r
+                               # ((rs,scores),pSt)     = checkCompetitionFile names game.match.seed pSt\r
+                               # compete                       = competition teams game.match.theField game.match.theReferee game.match.Match.playingTime rs\r
+                               = showMatches dialogId compete scores {pSt & ls={game & match = {game.match & seed=rs}}}\r
+       \r
+       showMatches dialogId compete=:{west,east} scores pSt\r
+               # pSt                                           = appPIO (closeAllControls dialogId) pSt\r
+               # (textId,    pSt)                      = openId pSt\r
+               # (progressId,pSt)                      = openId pSt\r
+               # (matchId,   pSt)                      = openId pSt\r
+               # (error,     pSt)                      = openControls dialogId undef \r
+                                                                               (   TextControl "" [ ControlWidth (ContentWidth (result (longest west) (longest east) (Just (99,99))))\r
+                                                                                                  , ControlId    textId\r
+                                                                                                  , ControlPos   (Center,OffsetVector {zero & vy=100})\r
+                                                                                                  ]\r
+                                                                               :+: TextControl "" [ ControlWidth (ContentWidth (progress nr_of_matches nr_of_matches))\r
+                                                                                                  , ControlId    progressId\r
+                                                                                                  , ControlPos   (BelowPrev,zero)\r
+                                                                                                  ]\r
+                                                                               ) pSt\r
+               # (error, pSt)                          = openTimer ([(i,j) \\ i <- [0..length compete.west-1], j <- [0 .. length compete.east-1]],scores) \r
+                                                                           (Timer 0 NilLS [TimerFunction (showNextMatch textId progressId matchId compete),TimerId matchId]) pSt\r
+               | error <> NoError                      = abort "Could not open timer to display matches.\n"\r
+               | otherwise                                     = pSt\r
+       where\r
+               longest texts                           = hd (sortBy (\t1 t2 -> size t1 > size t2) texts)\r
+               nr_of_matches                           = length west * length east\r
+               \r
+               result teamw teame score        = teamw +++ "-" +++ teame +++": " <+++ if (isNothing score) "no result" (toString (fromJust score))\r
+               progress i total                        = i +++> (" out of "<+++ total)\r
+               \r
+               showNextMatch textId progressId matchId compete dt (([_:ms],[_:cs]),pSt)                                                // match has already been computed: skip it\r
+                       = showNextMatch textId progressId matchId compete dt ((ms,cs),pSt)\r
+               showNextMatch textId progressId matchId compete=:{results,west,east} dt (([(tw,te):ms],cs),pSt) // match has not yet been computed: compute and backup\r
+                       # (pos,pSt)                             = appendMatchToCompetitionFile westt eastt pSt                                          // create an empty entry in the competition backup file\r
+                       # pSt                                   = updateMatchToCompetitionFile westt eastt score pos pSt                        // after computing match, store in the competition backup file\r
+                       # pSt                                   = appPIO (setControlText textId (result westt eastt score) o            // show user which match was successfully computed\r
+                                                                               setControlText progressId (progress (tw*length west + te) nr_of_matches)) pSt\r
+                       = ((ms,cs),pSt)\r
+               where\r
+                       (westt,eastt,score)             = ( west!!tw, east!!te, results!!tw!!te )\r
+               showNextMatch textId progressId matchId compete _ (ls,pSt)\r
+                       # pSt                                   = appPIO (closeTimer matchId) pSt \r
+                       # ((_,scores),pSt)              = checkCompetitionFile compete.west compete.usedRandomSeed pSt\r
+                       = (ls,showRanking dialogId (ranking compete.west scores) pSt)\r
+\r
+       showRanking dialogId ranking pSt\r
+               # pSt                                           = rankingToFile pSt\r
+               # pSt                                           = appPIO (closeAllControls dialogId) pSt\r
+               # (error,pSt)                           = openControls dialogId undef resultlist pSt\r
+               | error <> NoError                      = abort "Could not refill dialog with result list.\n"\r
+               | otherwise                                     = pSt\r
+       where\r
+               sorted_ranking                          = sortBy (\(_,r1) (_,r2) -> r1 > r2) ranking            // sort ranked list in descending order\r
+               resultlist                                      =     LayoutControl \r
+                                                                         (   ListLS [TextControl (toString i) [ControlPos (Left,zero)] \\ i        <- [1..length sorted_ranking]]\r
+                                                                         )   [ControlPos (LeftTop,zero),ControlItemSpace 4 0]\r
+                                                                         :+: LayoutControl\r
+                                                                         (   ListLS [TextControl club         [ControlPos (Left,zero)] \\ (club,_) <- sorted_ranking]\r
+                                                                         )   [ControlPos (RightToPrev,zero),ControlItemSpace 4 0]\r
+                                                                         :+: LayoutControl\r
+                                                                         (   ListLS [TextControl (toString r.matchpoints) [ControlPos (Left,zero)] \\ (_,r) <- sorted_ranking]\r
+                                                                         )   [ControlPos (RightToPrev,zero),ControlItemSpace 4 0]\r
+                                                                         :+: LayoutControl\r
+                                                                         (   ListLS [TextControl (toString r.goals_scored) [ControlPos (Left,zero)] \\ (_,r) <- sorted_ranking]\r
+                                                                         )   [ControlPos (RightToPrev,zero),ControlItemSpace 4 0]\r
+                                                                         :+: LayoutControl\r
+                                                                         (   ListLS [TextControl (toString r.goals_against) [ControlPos (Left,zero)] \\ (_,r) <- sorted_ranking]\r
+                                                                         )   [ControlPos (RightToPrev,zero),ControlItemSpace 4 0]\r
+                                                                         :+: ButtonControl "Ok" [ControlFunction (noLS (closeWindow dialogId)),ControlPos (Right,zero)]\r
+               \r
+               rankingToFile env\r
+                       # (ok,file,env)                 = fopen "ranking.txt" FWriteText env\r
+                       | not ok                                = trace_n "Could not output ranking to ranking.txt" env\r
+                       # file                                  = foldl (\file (club,{matchpoints,goals_scored,goals_against}) -> fwrites (club <+++ "\t" <+++ matchpoints <+++ "\t" <+++ goals_scored <+++ "\t" <+++ goals_against <+++ "\n") file) file sorted_ranking\r
+                       # (ok,env)                              = fclose file env\r
+                       | not ok                                = trace_n "Could not close ranking.txt" env\r
+                       | otherwise                             = env\r
+\r
+//     Utility functions:\r
+showHalf                                                       :: !Half -> String\r
+showHalf FirstHalf                                     = "1st half"\r
+showHalf SecondHalf                                    = "2nd half"\r
+\r
+/** getAllTeamsOfHome home field\r
+               yields all teams that start playing at given home and given football field dimensions.\r
+*/\r
+getAllTeamsOfHome                                      :: !Home !FootballField -> [Team]\r
+getAllTeamsOfHome home field           = apply field (apply home allAvailableTeams)\r
diff --git a/src/Gui/digitdisplay.dcl b/src/Gui/digitdisplay.dcl
new file mode 100644 (file)
index 0000000..b891767
--- /dev/null
@@ -0,0 +1,27 @@
+definition module digitdisplay\r
+\r
+import StdControl, StdId\r
+\r
+/*     A DigitDisplay displayId format size colour atts\r
+               is a Controls instance that displays a positive integral number of maximal format digits\r
+               in the given colour. Each digit has a given size.\r
+       The following ControlAttribute-s are inherited:\r
+               ControlPos:     the layout position of the digit display control\r
+               ControlTip:     the tool tip text that must be displayed\r
+       All other attributes are ignored.\r
+*/\r
+\r
+::     DigitDisplay ls pst\r
+ =     DigitDisplay DigitDisplayId DigitFormat DigitSize Colour [ControlAttribute *(ls,pst)]\r
+::     DigitDisplayId                  // The identification value of the digit display\r
+::     DigitFormat\r
+ =     IntegerFormat !Int              // The number of digits\r
+::     DigitSize                               // The size of one digit\r
+ :== Size\r
+\r
+openDigitDisplayId :: !*env -> (!DigitDisplayId,!*env) | Ids env\r
+\r
+instance Controls DigitDisplay\r
+\r
+getDigitDisplayValue :: !DigitDisplayId      !(PSt .ps) -> (!Int,!PSt .ps)\r
+setDigitDisplayValue :: !DigitDisplayId !Int !(PSt .ps) -> PSt .ps\r
diff --git a/src/Gui/digitdisplay.icl b/src/Gui/digitdisplay.icl
new file mode 100644 (file)
index 0000000..a1d548c
--- /dev/null
@@ -0,0 +1,205 @@
+implementation module digitdisplay\r
+\r
+import StdArray, StdClass, StdEnum, StdInt, StdList, StdMisc, StdReal, StdString\r
+import StdEnvExt\r
+import StdControl, StdControlAttribute, StdControlReceiver, StdId, StdPicture, StdPSt, StdReceiver\r
+\r
+/*     A DigitDisplay displayId format size atts\r
+               is a Controls instance that displays a positive integral number of maximal format digits\r
+               in a given colour. Each digit has a given size.\r
+       The following ControlAttribute-s are inherited:\r
+               ControlPos:     the layout position of the digit display control\r
+               ControlTip:     the tool tip text that must be displayed\r
+       All other attributes are ignored.\r
+*/\r
+\r
+::     DigitDisplay ls pst\r
+ =     DigitDisplay DigitDisplayId DigitFormat DigitSize Colour [ControlAttribute *(ls,pst)]\r
+::     DigitDisplayId\r
+ =     {       customId        :: !Id\r
+       ,       receiverId      :: !R2Id DigitDisplayMsgIn DigitDisplayMsgOut\r
+       }\r
+::     DigitDisplayMsgIn  = SetDigitValueIn Int | GetDigitValueIn\r
+::     DigitDisplayMsgOut = SetDigitValueOut    | GetDigitValueOut Int\r
+::     DigitFormat\r
+ =     IntegerFormat !Int              // The number of digits\r
+::     DigitSize                               // The size of one digit\r
+ :== Size\r
+\r
+openDigitDisplayId :: !*env -> (!DigitDisplayId,!*env) | Ids env\r
+openDigitDisplayId env\r
+       # (id,  env) = openId env\r
+       # (r2id,env) = openR2Id env\r
+       = ({customId=id,receiverId=r2id},env)\r
+\r
+::     DigitDisplaySt\r
+ =     {       value           :: !Int                         // The current value that is displayed\r
+       }\r
+::     DigitShapeTT\r
+ =     {       horDigitBars:: ![RPoint2]               // The positions of the horizontal digitbars\r
+       ,       verDigitBars:: ![RPoint2]               // The positions of the vertical   digitbars\r
+       }\r
+::     DigitBarTT\r
+ =     {       horDigitBar     :: !PolygonShapeTT      // The horizontal `true type' polygon shape\r
+       ,       verDigitBar     :: !PolygonShapeTT      // The vertical   `true type' polygon shape\r
+       }\r
+::     RPoint2                 =       {rx ::!Real,ry ::!Real}\r
+::     RVector2                =       {rvx::!Real,rvy::!Real}\r
+::     PolygonShapeTT  :== [RVector2]\r
+\r
+\r
+instance Controls DigitDisplay where\r
+       controlToHandles (DigitDisplay {customId,receiverId} digitFormat digitSize colour atts) pst\r
+               = controlToHandles digitdisplay pst\r
+       where\r
+               okDigitFormat           = validateDigitFormat digitFormat\r
+               okDigitSize                     = validateDigitSize digitSize\r
+               nrOfDigits                      = getNrOfDigits digitFormat\r
+               customControlSize       = { okDigitSize & w = okDigitSize.w*nrOfDigits }\r
+               initDisplaySt           = { value       = 0 }\r
+               digitdisplay            = { newLS       = initDisplaySt\r
+                                                         , newDef      = CustomControl customControlSize (displaylook (format okDigitFormat 0)) \r
+                                                                                                       [ ControlId customId\r
+                                                                                                       , ControlPen [PenBack Black,PenColour colour]\r
+                                                                                                       : flatten [posAtt,tipAtt]\r
+                                                                                                       ]\r
+                                                                                       :+:\r
+                                                                                 Receiver2 receiverId receiverfun []\r
+                                                         }\r
+               \r
+               posAtt                          = case [att \\ att<-atts | isControlPos att] of\r
+                                                               [ ControlPos pos : _]   -> [ControlPos pos]\r
+                                                               _                                               -> []\r
+               tipAtt                          = case [att \\ att<-atts | isControlTip att] of\r
+                                                               [ ControlTip text : _]  -> [ControlTip text]\r
+                                                               _                                               -> []\r
+               digitbars                       = { horDigitBar = [ {rvx = dx,    rvy = ~dy}\r
+                                                                                         , {rvx = 1.0-lx,rvy = 0.0}\r
+                                                                                         , {rvx = dx,    rvy = dy}\r
+                                                                                         , {rvx = ~dx,   rvy = dy}\r
+                                                                                         , {rvx = lx-1.0,rvy = 0.0}\r
+                                                                                         , {rvx = ~dx,   rvy = ~dy}\r
+                                                                                         ]\r
+                                                         , verDigitBar = [ {rvx = dx,    rvy = dy}\r
+                                                                                         , {rvx = 0.0,   rvy = 0.5-ly}\r
+                                                                                         , {rvx = ~dx,   rvy = dy}\r
+                                                                                         , {rvx = ~dx,   rvy = ~dy}\r
+                                                                                         , {rvx = 0.0,   rvy = ly-0.5}\r
+                                                                                         , {rvx = dx,    rvy = ~dy}\r
+                                                                                         ]\r
+                                                         }\r
+               (hmargin,vmargin)       = (0.12,0.12)\r
+               (dx,dy)                         = (0.06,0.06)\r
+               (lx,ly)                         = (2.0*(hmargin+dx),vmargin+dy)\r
+               digitshapes         :: {!DigitShapeTT}\r
+               digitshapes                     = {shape0,shape1,shape2,shape3,shape4,shape5,shape6,shape7,shape8,shape9}\r
+               shape0                          = { horDigitBars = [a,c],   verDigitBars = [a,b,d,e] }\r
+               shape1                          = { horDigitBars = [],      verDigitBars = [d,e]     }\r
+               shape2                          = { horDigitBars = [a,b,c], verDigitBars = [b,d]     }\r
+               shape3                          = { horDigitBars = [a,b,c], verDigitBars = [d,e]     }\r
+               shape4                          = { horDigitBars = [b],     verDigitBars = [a,d,e]   }\r
+               shape5                          = { horDigitBars = [a,b,c], verDigitBars = [a,e]     }\r
+               shape6                          = { horDigitBars = [a,b,c], verDigitBars = [a,b,e]   }\r
+               shape7                          = { horDigitBars = [a],     verDigitBars = [d,e]     }\r
+               shape8                          = { horDigitBars = [a,b,c], verDigitBars = [a,b,d,e] }\r
+               shape9                          = { horDigitBars = [a,b,c], verDigitBars = [a,d,e]   }\r
+               [a,b,c,d,e:_]           = [ {rx=hmargin,    ry=vmargin}\r
+                                                         , {rx=hmargin,    ry=0.5}\r
+                                                         , {rx=hmargin,    ry=1.0-vmargin}\r
+                                                         , {rx=1.0-hmargin,ry=vmargin}\r
+                                                         , {rx=1.0-hmargin,ry=0.5}\r
+                                                         ]\r
+               \r
+               receiverfun :: !DigitDisplayMsgIn !*(DigitDisplaySt,PSt .ps) -> (DigitDisplayMsgOut,(DigitDisplaySt,PSt .ps))\r
+               receiverfun (SetDigitValueIn newValue) (ddst,pst=:{io})\r
+                       # ddst  = {ddst & value = okValue}\r
+                       # io    = setControlLook customId True (True,displaylook (format okDigitFormat okValue)) io\r
+                       = (SetDigitValueOut,(ddst,{pst & io=io}))\r
+               where\r
+                       okValue = validateDigitValue okDigitFormat newValue\r
+               receiverfun GetDigitValueIn (ddst=:{value},pst)\r
+                       = (GetDigitValueOut value,(ddst,pst))\r
+               \r
+               displaylook :: ![Digit] !SelectState !UpdateState !*Picture -> *Picture\r
+               displaylook digits _ _ picture\r
+                       # picture       = unfill {zero & corner2={x=customControlSize.w,y=customControlSize.h}} picture\r
+                       # picture       = sseq [fillPolygons {x=i*okDigitSize.w,y=0} digitshapes.[digit] \\ digit <- digits & i <- [0..]] picture\r
+                       = picture\r
+               where\r
+                       fillPolygons base {horDigitBars,verDigitBars} picture\r
+                               = sseq\r
+                                       ( [fillAt (base + scaleRPoint2 okDigitSize posTT) {polygon_shape=map (scaleRVector2 okDigitSize) digitbars.horDigitBar} \\ posTT <- horDigitBars]\r
+                                               ++\r
+                                         [fillAt (base + scaleRPoint2 okDigitSize posTT) {polygon_shape=map (scaleRVector2 okDigitSize) digitbars.verDigitBar} \\ posTT <- verDigitBars]\r
+                                       ) picture\r
+               \r
+       getControlType _ = "DigitDisplay"\r
+\r
+getDigitDisplayValue :: !DigitDisplayId !(PSt .ps) -> (!Int,!PSt .ps)\r
+getDigitDisplayValue {receiverId} pst\r
+       = case syncSend2 receiverId GetDigitValueIn pst of\r
+               ((SendOk,Just (GetDigitValueOut x)),pst) -> (x,pst)\r
+               other                                    -> sendError "getDigitDisplayValue"\r
+\r
+setDigitDisplayValue :: !DigitDisplayId !Int !(PSt .ps) -> PSt .ps\r
+setDigitDisplayValue {receiverId} newValue pst\r
+       = case syncSend2 receiverId (SetDigitValueIn newValue) pst of\r
+               ((SendOk,Just SetDigitValueOut),pst) -> pst\r
+               other                                -> sendError "setDigitDisplayValue"\r
+\r
+sendError fName\r
+       = abort (fName +++ ": wrong reply from DigitDisplay.\n")\r
+\r
+\r
+//     Validate format:\r
+validateDigitFormat :: !DigitFormat -> DigitFormat\r
+validateDigitFormat (IntegerFormat nrDigits)\r
+       = IntegerFormat (setbetween nrDigits 1 maxNrDigits)\r
+where\r
+       maxInt          = 0x7FFFFFFF\r
+       maxNrDigits     = toInt (log10 (toReal maxInt))-1\r
+\r
+\r
+//     getNrOfDigits returns the number of digits to display:\r
+getNrOfDigits :: !DigitFormat -> Int\r
+getNrOfDigits (IntegerFormat nrDigits) = nrDigits\r
+\r
+//     Validate digit size:\r
+validateDigitSize :: !DigitSize -> Size\r
+validateDigitSize {w,h}\r
+       = {w=max 1 w,h=max 1 h}\r
+\r
+//     Validate value according to valid format:\r
+validateDigitValue :: !DigitFormat !Int -> Int\r
+validateDigitValue (IntegerFormat nrDigits) x\r
+       = setbetween x 0 (10^nrDigits-1)\r
+\r
+//     Format integer values:\r
+::     Digit   :== Int         // A digit is an int in [0..9]\r
+\r
+class format a :: !DigitFormat !a -> [Digit]\r
+\r
+instance format Int where\r
+       format (IntegerFormat nrDigits) x\r
+               = getdigits nrDigits (abs x) []\r
+       where\r
+               getdigits :: !Int !Int ![Digit] -> [Digit]\r
+               getdigits 0 _ digits\r
+                       = digits\r
+               getdigits n x digits\r
+                       = getdigits (n-1) (x / 10) [x rem 10 : digits]\r
+\r
+digitsToString :: ![Digit] -> String\r
+digitsToString digits\r
+       = {toChar (toInt '0'+d) \\ d<-digits}\r
+\r
+\r
+instance toString DigitFormat where\r
+       toString (IntegerFormat nrDigits) = "(IntegerFormat " <+++ nrDigits <+++")"\r
+\r
+\r
+scaleRVector2 :: !Size !RVector2 -> Vector2\r
+scaleRVector2 {w,h} {rvx,rvy} = {vx=toInt ((toReal w)*rvx), vy=toInt ((toReal h)*rvy)}\r
+\r
+scaleRPoint2 :: !Size !RPoint2 -> Point2\r
+scaleRPoint2 {w,h} {rx,ry} = {x=toInt ((toReal w)*rx), y=toInt ((toReal h)*ry)}\r
diff --git a/src/Gui/guiInterface.dcl b/src/Gui/guiInterface.dcl
new file mode 100644 (file)
index 0000000..e7e5db4
--- /dev/null
@@ -0,0 +1,21 @@
+definition module guiInterface\r
+\r
+import matchGame\r
+\r
+/**    getSplashImageForGui loads the splash image for Soccer-Fun.\r
+*/\r
+getSplashImageForGui   :: !*env -> (!GamePicture,!*env) | FileSystem env\r
+\r
+//     todo:\r
+getActionPicsForGui            :: !Match !*env -> (!ActionPics,!*env) | FileSystem env\r
+\r
+/*     Steps the game one step, returns the game and the referee events\r
+*/\r
+stepMatchForGui                        :: !FootballGame !*env -> (![RefereeAction], !FootballGame, !*env) | FileSystem env\r
+\r
+:: DisplaySpeed                        = Slowest | Slower | Normal | Faster | Fastest\r
+instance toString              DisplaySpeed\r
+instance fromString            DisplaySpeed\r
+instance ==                            DisplaySpeed\r
+\r
+intervalFactor                 :: !DisplaySpeed -> Real\r
diff --git a/src/Gui/guiInterface.icl b/src/Gui/guiInterface.icl
new file mode 100644 (file)
index 0000000..e6a7dff
--- /dev/null
@@ -0,0 +1,55 @@
+implementation module guiInterface\r
+\r
+import fileIO\r
+import matchGame\r
+\r
+inDir img :== "afbeeldingen\\"+++img+++".bmp"\r
+\r
+getSplashImageForGui :: !*env -> (!GamePicture,!*env) | FileSystem env\r
+getSplashImageForGui env\r
+# pathToSplash         = inDir "AmsterdamArenA"\r
+# (splashImg, env)     = getImage pathToSplash env\r
+= ({img = splashImg, path = pathToSplash},env)\r
+\r
+stepMatchForGui :: !FootballGame !*env -> (![RefereeAction], !FootballGame, !*env) | FileSystem env\r
+stepMatchForGui game env\r
+| timeLeft game\r
+       # ((refEvents,actions),match)   = stepMatch game.match\r
+       # env                                                   = logMatch game.logging match refEvents actions env\r
+       = (refEvents,{game & match=match},env)\r
+| otherwise\r
+       = ([GameOver],game,env)\r
+\r
+getActionPicsForGui :: !Match !*env -> (!ActionPics,!*env) | FileSystem env\r
+getActionPicsForGui match env\r
+# (refereePics,env)    = sseqList (map fillWithPics` match.theReferee.refActionPics) env\r
+= ({refereePics=refereePics},env)\r
+where\r
+       fillWithPics` :: !Path !*env -> (!GamePicture,!*env) | FileSystem env\r
+       fillWithPics` path env\r
+       # (img,env)                     = getImage path env\r
+       = ({img=img, path=path},env)\r
+\r
+instance toString   DisplaySpeed where toString Slowest                = "Slowest"\r
+                                                                               toString Slower                 = "Slower"\r
+                                                                               toString Normal                 = "Normal"\r
+                                                                               toString Faster                 = "Faster"\r
+                                                                               toString Fastest                = "Fastest"\r
+instance fromString DisplaySpeed where fromString "Slowest"    = Slowest\r
+                                                                               fromString "Slower"             = Slower\r
+                                                                               fromString "Normal"             = Normal\r
+                                                                               fromString "Faster"             = Faster\r
+                                                                               fromString "Fastest"    = Fastest\r
+instance ==         DisplaySpeed where == Slowest Slowest              = True\r
+                                                                               == Slower  Slower               = True\r
+                                                                               == Normal  Normal               = True\r
+                                                                               == Faster  Faster               = True\r
+                                                                               == Fastest Fastest              = True\r
+                                                                               == _       _                    = False\r
+\r
+intervalFactor :: !DisplaySpeed -> Real\r
+intervalFactor Slowest         = 1.0 / 0.2     // five times slower\r
+intervalFactor Slower          = 1.0 / 0.5     // two  times slower\r
+intervalFactor Normal          = 1.0           // two  times faster\r
+intervalFactor Faster          = 1.0 / 5.0 // five times faster\r
+intervalFactor Fastest         = zero          // no timer delay\r
diff --git a/src/Gui/render.dcl b/src/Gui/render.dcl
new file mode 100644 (file)
index 0000000..ae62319
--- /dev/null
@@ -0,0 +1,23 @@
+definition module render\r
+\r
+import StdIOCommon, StdPicture, StdPSt\r
+import matchControl\r
+\r
+::     RenderStyle             = { name :: !String\r
+                                         , look :: !Match -> Look\r
+                                         }\r
+\r
+instance nameOf RenderStyle\r
+\r
+/**    allRenderStyles:\r
+               enumerates all present rendering styles.\r
+*/\r
+allRenderStyles                :: [RenderStyle]\r
+\r
+/**    renderAttributes\r
+               yields the attributes required by the rendering functions to accurately draw a match.\r
+*/\r
+renderAttributes       :: !*env -> (![PenAttribute],!*env) | accScreenPicture env\r
+\r
+WestColour                     :: Colour\r
+EastColour                     :: Colour\r
diff --git a/src/Gui/render.icl b/src/Gui/render.icl
new file mode 100644 (file)
index 0000000..f523d9d
--- /dev/null
@@ -0,0 +1,31 @@
+implementation module render\r
+\r
+import StdIOCommon, StdPicture, StdPSt\r
+import matchControl\r
+import renderGameFlatlandish                                                                   // the default rendering style\r
+import renderGameFixCamera                                                                             // 2.5D rendering with fixed camera and angles at south-east\r
+\r
+instance nameOf RenderStyle    where nameOf style = style.RenderStyle.name\r
+\r
+allRenderStyles                                :: [RenderStyle]\r
+allRenderStyles                                = [ renderFlatland\r
+                                                         , renderFixCamera\r
+                                                         ]\r
+\r
+green                                          :== RGB {r=30,g=140,b=40}                       // dark green works better on a beamer\r
+home_colour                                    :== RGB {r=255,g=255,b=70}                      // yellow works well on dark green background\r
+away_colour                                    :== RGB {r=102,g=255,b=255}\r
+\r
+WestColour                                     :: Colour\r
+WestColour                                     = home_colour\r
+\r
+EastColour                                     :: Colour\r
+EastColour                                     = away_colour\r
+\r
+renderAttributes ::                    !*env -> (![PenAttribute],!*env) | accScreenPicture env\r
+renderAttributes env           = accScreenPicture attributes env\r
+where\r
+       attributes ::                   !*Picture -> (![PenAttribute],!*Picture)\r
+       attributes picture\r
+               # ((_,font),picture)= openFont SmallFontDef picture\r
+               = ([PenBack green,PenFont font],picture)\r
diff --git a/src/Gui/renderGameFixCamera.dcl b/src/Gui/renderGameFixCamera.dcl
new file mode 100644 (file)
index 0000000..8582719
--- /dev/null
@@ -0,0 +1,14 @@
+definition module renderGameFixCamera\r
+\r
+/** This module implements a camera at the south-east corner of the football field.\r
+       The field is displayed in an isometric style.\r
+       Because a 'pure' isometric projection gives the illusion that the west-edge of the football field\r
+       is too wide, a visual correction is added to decrease this effect.\r
+*/\r
+import render\r
+\r
+/** renderFixCamera\r
+               renders a match using an elevated camera at the south-east corner of the football field\r
+               and fixed angles.\r
+*/\r
+renderFixCamera :: RenderStyle\r
diff --git a/src/Gui/renderGameFixCamera.icl b/src/Gui/renderGameFixCamera.icl
new file mode 100644 (file)
index 0000000..5acc609
--- /dev/null
@@ -0,0 +1,255 @@
+implementation module renderGameFixCamera\r
+\r
+import Geometry\r
+import render\r
+\r
+renderFixCamera                                                :: RenderStyle\r
+renderFixCamera                                                = { name = "Fixed camera"\r
+                                                                         , look = fixcamera\r
+                                                                         }\r
+\r
+fixcamera                                                      :: !Match !SelectState !UpdateState !*Picture -> *Picture\r
+fixcamera match=:{theField,theBall,team1,team2} _ updSt=:{newFrame} picture\r
+# picture                                                      = setPenColour Black picture\r
+# picture                                                      = fill newFrame      picture                                                            // erase entire background\r
+# picture                                      = setPenColour green picture\r
+# picture                                                      = drawField          picture                                                            // draw the field and outer lines\r
+# picture                                                      = drawMiddleArea     picture                                                            // middle line, circle and spot\r
+# picture                                                      = drawGoalAreas      picture                                                            // goal areas\r
+# picture                                                      = drawPenaltyAreas   picture                                                            // penalty areas\r
+# picture                                                      = drawCornerAreas    picture                                                            // corner areas\r
+# picture                                                      = drawGoals          picture                                                            // goals\r
+# picture                                                      = foldr drawPlayer   picture sorted_players                                     // players\r
+# picture                                                      = drawBall (getFootball theBall (team1 ++ team2)) picture       // football\r
+= picture\r
+where\r
+       {w,h}                                                   = rectangleSize newFrame\r
+       {fwidth,flength}                                = theField\r
+       ratio                                                   = min ((toReal w) / (toReal flength)) ((toReal h) / (toReal fwidth))\r
+       pix x                                                   = toInt (ratio * toReal x)                                                                      // convert metres   to pixels\r
+       ppix {px,py}                                    = {x = pix px, y = pix py}                                                                      // convert Position to pixels\r
+       (northPole,southPole)                   = goal_poles theField\r
+       fieldfit                                = min (toReal w / (ratio * (convertToIsoXNormal (toReal flength) 0.0             - convertToIsoXNormal 0.0 (toReal fwidth)))) \r
+                                                                             (toReal h / (ratio * (convertToIsoYNormal (toReal flength) (toReal fwidth) - convertToIsoYNormal 0.0 0.0)))\r
+       north_west                                              = ppix (convertToIso {px = zero,    py = zero  })\r
+       north_east                                              = ppix (convertToIso {px = flength, py = zero  })\r
+       south_east                                              = ppix (convertToIso {px = flength, py = fwidth})\r
+       south_west                                              = ppix (convertToIso {px = zero,    py = fwidth})\r
+       sorted_players                                  = let se = {px=scale 0.5 flength, py=scale -0.5 fwidth}\r
+                                                                          in sortBy (\(_,fb1) (_,fb2) -> dist fb1 se < dist fb2 se) ([(WestColour,fb) \\ fb <- team1] ++ [(EastColour,fb) \\ fb <- team2])\r
+       \r
+       drawPlayer                                              :: !(!Colour, !Footballer) !*Picture -> *Picture\r
+       drawPlayer (colour, fb=:{playerID ,name,nose=nose_dir,effect,pos=pos`}) picture\r
+       # picture                                               = drawName name picture\r
+       | perhaps isOnTheGround effect  = drawGroundPlayer   fb picture\r
+       | otherwise                                             = drawStandingPlayer fb picture\r
+       where\r
+               pos                                                     = move_point {dx=scale 0.5 flength, dy=scale 0.5 fwidth} {pos` & py = ~pos`.py}\r
+               player_width                            = m 0.5\r
+               body_circle                                     = circle (pix player_width)\r
+               bearing_circle                          = circle (pix (m 0.3))\r
+               nose_dir_point k                        = move_point (scale k (convertToIsoVector {dx = m (cosinus nose_dir), dy = m (~(sinus nose_dir))})) (convertToIso pos)\r
+               \r
+               drawName name picture\r
+               # picture                                       = setPenColour White                                     picture\r
+               # picture                                       = drawAt (ppix (move_point one (convertToIso pos))) name picture\r
+               = picture\r
+               \r
+               drawGroundPlayer fb=:{length} picture\r
+               # (w,picture)                           = getPenSize                                                          picture\r
+               # picture                                       = setPenSize (pix player_width + 2)                                   picture\r
+               # picture                                       = setPenColour Black                                                  picture\r
+               # picture                                       = draw (body_line offset)                                             picture\r
+               # picture                                       = setPenSize (pix player_width)                                       picture\r
+               # picture                                       = setPenColour colour                                                 picture\r
+               # picture                                       = draw (body_line zero)                                               picture\r
+               # picture                                       = setPenSize w                                                        picture\r
+               # picture                                       = fillAt (ppix (nose_dir_point (toReal length + 0.2))) bearing_circle picture\r
+               # picture                                       = setPenColour Black                                                  picture\r
+               # picture                                       = drawAt (ppix (nose_dir_point (toReal length + 0.2))) bearing_circle picture\r
+               = picture\r
+               where\r
+                       offset                                  = {vx = -1, vy = -1}\r
+                       body_line v                             = { line_end1 = movePoint v (ppix (convertToIso pos))\r
+                                                                         , line_end2 = movePoint v (ppix (nose_dir_point (toReal length))) \r
+                                                                         }\r
+               \r
+               drawStandingPlayer fb=:{length} picture\r
+               # picture                                       = setPenColour colour                               picture\r
+               # picture                                       = fillAt (ppix (nose_dir_point 1.0)) bearing_circle picture                                     // nose direction\r
+               # picture                                       = foldr (uncurry fillAt)                            picture playerCorpus\r
+               # picture                                       = setPenColour Black                                picture\r
+               # picture                                       = drawAt (ppix (nose_dir_point 1.0)) bearing_circle picture                                     // surrounding circle\r
+               # picture                                       = foldr (uncurry drawAt)                            picture playerCorpus\r
+               = picture\r
+               where\r
+                       player_width`                   = toReal player_width\r
+                       length`                                 = pix length\r
+                       (up,down)                               = ({vx = 0, vy = ~length`}, {vx = 0,vy = length`})\r
+                       playerCorpus                    = [(ptl,{polygon_shape = [up,{vx = ptr.x-ptl.x, vy = ptr.y-ptl.y},down]})\r
+                                                                         ,(pbl,{polygon_shape = [up,{vx = pbr.x-pbl.x, vy = pbr.y-pbl.y},down]})\r
+                                                                         ,(pbr,{polygon_shape = [up,{vx = ptr.x-pbr.x, vy = ptr.y-pbr.y},down]})\r
+                                                                         ,(pbl,{polygon_shape = [up,{vx = ptl.x-pbl.x, vy = ptl.y-pbl.y},down]})\r
+                                                                         ]\r
+                       playerRadius                    = m (sqrt (player_width` * player_width` + player_width` * player_width`))\r
+                       add_angle a                             = let c = cosinus (a + nose_dir)\r
+                                                                             s =   sinus (a + nose_dir)\r
+                                                                          in ppix (convertToIso (move_point {dx = scale c playerRadius, dy = scale s playerRadius} pos))\r
+                       ptr                                             = add_angle (rad (0.25*pi))\r
+                       ptl                                             = add_angle (rad (0.75*pi))\r
+                       pbl                                             = add_angle (rad (1.25*pi))\r
+                       pbr                                             = add_angle (rad (1.75*pi))\r
+                       \r
+       drawMiddleArea                                  :: !*Picture -> *Picture\r
+       drawMiddleArea picture\r
+       # picture                                               = drawLine {x = (north_west.x+north_east.x)/2, y = (north_west.y+north_east.y)/2} \r
+                                                                                  {x = (south_west.x+south_east.x)/2, y = (south_west.y+south_east.y)/2} picture               // middle line\r
+       # picture                                               = drawAt center (circle (pix (scale fieldfit radius_centre_spot)))                picture               // centre spot\r
+       # picture                                               = drawAt centerRadius {polygon_shape = circle_vs}                                 picture               // centre circle\r
+       = picture\r
+       where\r
+               center                                          = {x = sum [north_west.x,north_east.x,south_west.x,south_east.x] / 4\r
+                                                                         ,y = sum [north_west.y,north_east.y,south_west.y,south_east.y] / 4\r
+                                                                         }\r
+               centerRadius                            = ppix (convertToIso {px = scale 0.5 flength, py = scale 0.5 fwidth - radius_centre_circle})    // centre circle starting location for drawing\r
+               start                                           = {px=radius_centre_circle, py=zero}                                                                                                                    // starting location for generating circle points\r
+               circle_vs                                       = circle_shape radius_centre_circle (rad (0.025*pi)) (rad (2.0*pi)) start zero []\r
+               \r
+       drawGoals                                               :: !*Picture -> *Picture\r
+       drawGoals picture\r
+       # picture                                               = drawLine (ppix                ne)  (ppix (addGoalHeight ne)) picture  // east north pole\r
+       # picture                                               = drawLine (ppix                se)  (ppix (addGoalHeight se)) picture  // east south pole\r
+       # picture                                               = drawLine (ppix (addGoalHeight ne)) (ppix (addGoalHeight se)) picture  // east pole connect\r
+       # picture                                               = drawLine (ppix                nw)  (ppix (addGoalHeight nw)) picture  // west north pole\r
+       # picture                                               = drawLine (ppix                sw)  (ppix (addGoalHeight sw)) picture  // west south pole\r
+       # picture                                               = drawLine (ppix (addGoalHeight nw)) (ppix (addGoalHeight sw)) picture  // west pole connect\r
+       = picture\r
+       where \r
+               addGoalHeight p                         = move_point   {zero & dy = ~goal_height} p\r
+               nw                                                      = convertToIso {px = zero,    py = northPole + scale 0.5 fwidth}\r
+               sw                                                      = convertToIso {px = zero,    py = southPole + scale 0.5 fwidth}\r
+               ne                                                      = convertToIso {px = flength, py = northPole + scale 0.5 fwidth}\r
+               se                                                      = convertToIso {px = flength, py = southPole + scale 0.5 fwidth}\r
+               \r
+       drawField                                               :: !*Picture -> *Picture\r
+       drawField picture\r
+       # picture                                               = fillAt north_west field_shape picture //field\r
+       # picture                                               = setPenColour White            picture\r
+       # picture                                               = drawAt north_west field_shape picture //outline\r
+       = picture\r
+       where\r
+               field_shape                                     = {polygon_shape = [{vx = north_east.x-north_west.x, vy = north_east.y-north_west.y}\r
+                                                                                          ,{vx = south_east.x-north_east.x, vy = south_east.y-north_east.y}\r
+                                                                                          ,{vx = south_west.x-south_east.x, vy = south_west.y-south_east.y}\r
+                                                                                          ]\r
+                                                                         }\r
+               \r
+       drawBall                                                :: !Football !*Picture -> *Picture\r
+       drawBall football picture\r
+       # picture                                               = setPenColour ball_colour        picture\r
+       # picture                                               = drawAt (ppix ballPosition) ball picture       // ball shadow\r
+       # picture                                               = fillAt (ppix elevation)    ball picture       // ball\r
+       # picture                                               = setPenColour White              picture\r
+       # picture                                               = drawAt (ppix elevation)    ball picture       // ball-line\r
+       = picture\r
+       where\r
+               groundPos`                                      = football.ballPos.pxy\r
+               groundPos                                       = {groundPos` & py = ~groundPos`.py}\r
+               ballPosition                            = convertToIso (move_point {dx=scale 0.5 flength,dy=scale 0.5 fwidth} groundPos)\r
+               elevation                                       = move_point {zero & dy=scale (~fieldfit) football.ballPos.pz} ballPosition\r
+               ball                                            = circle (pix (scale 2.8 radius_football))\r
+       \r
+       drawGoalAreas                                   :: !*Picture -> *Picture\r
+       drawGoalAreas picture\r
+       # picture                                               = drawLine (ppix (convertToIso {px = flength,py = y_north})) (ppix (convertToIso {px = x_east, py = y_north})) picture  // east north edge\r
+       # picture                                               = drawLine (ppix (convertToIso {px = flength,py = y_south})) (ppix (convertToIso {px = x_east, py = y_south})) picture  // east south edge\r
+       # picture                                               = drawLine (ppix (convertToIso {px = x_east, py = y_south})) (ppix (convertToIso {px = x_east, py = y_north})) picture  // east edge\r
+       # picture                                               = drawLine (ppix (convertToIso {px = zero,   py = y_north})) (ppix (convertToIso {px = x_west, py = y_north})) picture  // west north edge\r
+       # picture                                               = drawLine (ppix (convertToIso {px = zero,   py = y_south})) (ppix (convertToIso {px = x_west, py = y_south})) picture  // west south edge\r
+       # picture                                               = drawLine (ppix (convertToIso {px = x_west, py = y_south})) (ppix (convertToIso {px = x_west, py = y_north})) picture  // west edge\r
+       = picture\r
+       where\r
+               (y_north,y_south)                       = (scale 0.5 fwidth + goal_area_depth + northPole, scale 0.5 fwidth + southPole - goal_area_depth)\r
+               (x_west, x_east)                        = (goal_area_depth, flength - goal_area_depth)\r
+       \r
+       drawPenaltyAreas                                :: !*Picture -> *Picture\r
+       drawPenaltyAreas picture\r
+       # picture                                               = drawLine (ppix (convertToIso {px = flength,py = y_north})) (ppix (convertToIso {px = x_east, py = y_north}))    picture       // east north edge\r
+       # picture                                               = drawLine (ppix (convertToIso {px = flength,py = y_south})) (ppix (convertToIso {px = x_east, py = y_south}))    picture       // east south edge\r
+       # picture                                               = drawLine (ppix (convertToIso {px = x_east, py = y_south})) (ppix (convertToIso {px = x_east, py = y_north}))    picture       // east edge\r
+       # picture                                               = drawLine (ppix (convertToIso {px = zero,   py = y_north})) (ppix (convertToIso {px = x_west, py = y_north}))    picture       // west north edge\r
+       # picture                                               = drawLine (ppix (convertToIso {px = zero,   py = y_south})) (ppix (convertToIso {px = x_west, py = y_south}))    picture       // west south edge\r
+       # picture                                               = drawLine (ppix (convertToIso {px = x_west, py = y_south})) (ppix (convertToIso {px = x_west, py = y_north}))    picture       // west edge\r
+       # picture                                               = drawAt   (ppix east_spotIso) (circle (pix (scale fieldfit radius_penalty_spot)))                                picture       // east penalty spot\r
+       # picture                                               = drawAt   (ppix (move_point (convertToIsoVector {dx=m (~h_dist),dy=m dyStart}) east_spotIso)) east_curve picture       // east curve\r
+       # picture                                               = drawAt   (ppix west_spotIso) (circle (pix (scale fieldfit radius_penalty_spot)))                                picture       // west penalty spot\r
+       # picture                                               = drawAt   (ppix (move_point (convertToIsoVector {dx=m h_dist,dy=m (~dyStart)}) west_spotIso)) west_curve picture       // west curve                                                                        \r
+       = picture\r
+       where\r
+               (y_north,y_south)                       = (northPole + penalty_area_depth + scale 0.5 fwidth, southPole - penalty_area_depth + scale 0.5 fwidth)\r
+               (x_west, x_east)                        = (penalty_area_depth, flength - penalty_area_depth)\r
+               angle                                           = arccosinus (h_dist / (toReal radius_penalty_area * fieldfit))\r
+               h_dist                                          = (toReal penalty_area_depth - toReal penalty_spot_depth) * fieldfit\r
+               east_spotIso                            = convertToIso {px = flength - penalty_spot_depth, py = scale 0.5 fwidth}\r
+               west_spotIso                            = convertToIso {px =           penalty_spot_depth, py = scale 0.5 fwidth}\r
+               circleStartWest                 = {px = scale (cosinus (angle - rad (0.5*pi))) radius_penalty_area, py = scale (sinus (angle - rad (0.5*pi))) radius_penalty_area}\r
+               circleStartEast                         = {px = scale (cosinus (angle + rad (0.5*pi))) radius_penalty_area, py = scale (sinus (angle + rad (0.5*pi))) radius_penalty_area}\r
+               dyStart                                         = sqrt (rpaff * rpaff - h_dist * h_dist)\r
+               rpaff                                           = toReal radius_penalty_area * fieldfit\r
+               east_curve                                      = {polygon_shape = circle_shape radius_penalty_area (rad (pi/180.0)) (rad (0.5*pi) + angle) circleStartEast   (rad (0.5*pi) - angle)  []}\r
+               west_curve                                      = {polygon_shape = circle_shape radius_penalty_area (rad (pi/180.0)) (angle - rad (0.5*pi)) circleStartWest (~(angle + rad (0.5*pi))) []}\r
+       \r
+       drawCornerAreas                                 :: !*Picture -> *Picture\r
+       drawCornerAreas picture\r
+       # picture                                               = drawAt (ppix (convertToIso {px = flength - radius_corner_kick_area, py = fwidth})) (corner (rad (1.0*pi) - a1) (rad (0.0*pi) + a1) True ) picture     // east south corner\r
+       # picture                                               = drawAt (ppix (convertToIso {px =           radius_corner_kick_area, py = zero  })) (corner (rad (2.0*pi) - a1) (rad (1.0*pi) + a1) True ) picture     // west north corner\r
+       # picture                                               = drawAt (ppix (convertToIso {px =           radius_corner_kick_area, py = fwidth})) (corner (rad (1.5*pi) + a2) (rad (0.5*pi) - a2) False) picture     // west south corner\r
+       # picture                                               = drawAt (ppix (convertToIso {px = flength - radius_corner_kick_area, py = zero  })) (corner (rad (0.5*pi) + a2) (rad (1.5*pi) - a2) False) picture     // east north corner\r
+       = picture\r
+       where\r
+               corner f t c                            = { curve_oval      = circle (pix (scale fieldfit radius_corner_kick_area))\r
+                                                                         , curve_from      = toReal f\r
+                                                                         , curve_to        = toReal t\r
+                                                                         , curve_clockwise = c\r
+                                                                         }\r
+               (a1,a2)                                         = (arctangens 0.5, arctangens 2.0)\r
+               \r
+       circle_shape                                    :: !Metre !Angle !Angle !Position !Angle ![Vector2] -> [Vector2]\r
+       circle_shape r i angle base end vs\r
+       | angle <= end                                  = reverse vs\r
+       | otherwise                                             = circle_shape r i (angle-i) this end [{vx = thisIso.x - baseIso.x, vy = baseIso.y - thisIso.y} : vs]\r
+       where\r
+               this                                            = {px = scale (cosinus angle) r, py = scale (sinus angle) r}\r
+               thisIso                                         = ppix (convertToIsoNormal this)\r
+               baseIso                                         = ppix (convertToIsoNormal base)\r
+               \r
+               convertToIsoNormal {px,py}      = {px = scale fieldfit (px - py + fwidth), py = scale (0.5*fieldfit) (px + py)}\r
+       \r
+       convertToIso                                    :: !Position -> Position\r
+       convertToIso pos                                = { px = scale      fieldfit  (pos.px - yScaled pos + fwidth)\r
+                                                                         , py = scale (0.5*fieldfit) (pos.px + yScaled pos)\r
+                                                                         }\r
+       \r
+       yScaled                                                 :: !Position -> Metre\r
+       yScaled pos=:{px, py}\r
+       | py <= scale 0.5 fwidth                = py + scale yscale d\r
+       | otherwise                                             = py - scale yscale d\r
+       where\r
+               yscale                                          = (1.0 - (toReal px)/(toReal flength)) / factor\r
+               d                                                       = abs (py - scale 0.5 fwidth)\r
+               factor                                          = 8.0\r
+               \r
+       convertToIsoVector                              :: !RVector -> RVector\r
+       convertToIsoVector {dx,dy}              = {dx = dx - dy, dy = scale 0.5 (dx+dy)}\r
+       \r
+       convertToIsoXNormal                             :: !Real !Real -> Real\r
+       convertToIsoXNormal x y                 = x - y\r
+\r
+       convertToIsoYNormal                             :: !Real !Real -> Real\r
+       convertToIsoYNormal x y                 = (x + y) / 2.0\r
+\r
+green                                                          :== RGB {r=30,g=140,b=40}                       // dark green works better on a beamer\r
+black                                                          :== Black                                                       // black\r
+ball_colour                                                    :== Black\r
+\r
+circle r                                                       :== {oval_rx=r,oval_ry=r}\r
diff --git a/src/Gui/renderGameFlatlandish.dcl b/src/Gui/renderGameFlatlandish.dcl
new file mode 100644 (file)
index 0000000..46afd27
--- /dev/null
@@ -0,0 +1,13 @@
+definition module renderGameFlatlandish\r
+\r
+/** Render a football match in Flatland-style:\r
+               the camera hovers above the center of the football field and everything is displayed in a\r
+               deliberately simplistic manner.\r
+*/\r
+import StdIOCommon, StdPSt\r
+import matchControl, render\r
+\r
+/**    renderFlatland\r
+               renders a complete match in Flatland style.\r
+*/\r
+renderFlatland :: RenderStyle\r
diff --git a/src/Gui/renderGameFlatlandish.icl b/src/Gui/renderGameFlatlandish.icl
new file mode 100644 (file)
index 0000000..6f9e6e2
--- /dev/null
@@ -0,0 +1,168 @@
+implementation module renderGameFlatlandish\r
+\r
+import matchControl, render\r
+import StdIOCommon, StdPSt\r
+\r
+renderFlatland                         :: RenderStyle\r
+renderFlatland                         = { name = "Flatland"\r
+                                                         , look = flatland\r
+                                                         }\r
+\r
+/**    flatland match updSt\r
+               renders a complete match, given the current dimensions of the drawing environment (updSt).\r
+*/\r
+flatland                                       :: !Match !SelectState !UpdateState !*Picture -> *Picture\r
+flatland match=:{theField,theBall,team1,team2} _ updSt=:{newFrame} picture\r
+# picture                                      = setPenColour Black                                  picture\r
+# picture                                      = fill {corner1={x=pixl,y=zero},corner2={x=w,y=pixw}} picture           // exterior right\r
+# picture                                      = fill {corner1={x=zero,y=pixw},corner2={x=w,y=h}}    picture           // exterior bottom\r
+# picture                                      = unfill field_rectangle                              picture           // football field\r
+# picture                                      = setPenColour White                                  picture\r
+# picture                                      = draw field_rectangle                                picture           // field outline\r
+# picture                                      = drawMiddleArea                                      picture           // middle line, circle and spot\r
+# picture                                      = drawGoals                                           picture           // goals\r
+# picture                                      = drawGoalAreas                                       picture           // goal areas\r
+# picture                                      = drawPenaltyAreas                                    picture           // penalty areas\r
+# picture                                      = drawCornerAreas                                     picture           // corner areas\r
+# picture                                      = foldr (drawPlayer WestColour)                       picture team1     // team1 players\r
+# picture                                      = foldr (drawPlayer EastColour)                       picture team2     // team2 players\r
+# picture                                      = drawBall (getFootball theBall (team1 ++ team2))     picture           // football\r
+= picture\r
+where\r
+       {w,h}                                   = rectangleSize newFrame\r
+       {fwidth,flength}                = theField\r
+       field_rectangle                 = {corner1=ppix {px=scale -0.5 flength,py=scale 0.5 fwidth}, corner2=ppix {px=scale 0.5 flength,py=scale -0.5 fwidth}}\r
+       ratio                                   = min ((toReal w) / (toReal flength)) ((toReal h) / (toReal fwidth))\r
+       pixw                                    = pix fwidth\r
+       pixl                                    = pix flength\r
+       pix  x                                  = toInt (ratio * toReal x)\r
+       pixx x                                  = pixl / 2 + pix x                                              // convert metres   to pixels\r
+       pixy y                                  = pixw / 2 - pix y\r
+       ppix {px,py}                    = {x  = pixx px, y  = pixy py}                  // convert Position to pixels\r
+       vpix {dx,dy}                    = {vx = pix  dx, vy = pix  dy}                  // convert RVector  to pixels\r
+       (northPole,southPole)   = goal_poles theField\r
+       \r
+       drawPlayer                              :: !Colour !Footballer !*Picture -> *Picture\r
+       drawPlayer colour fb=:{name,nose=nose_dir,effect,pos} picture\r
+       # picture                               = drawName          name picture\r
+       | perhaps isOnTheGround effect\r
+                                                       = drawLyingPlayer    fb  picture\r
+       | otherwise                             = drawStandingPlayer fb  picture\r
+       where\r
+               player_width            = m 0.5\r
+               body_circle                     = circle (pix player_width)\r
+               bearing_circle          = circle (pix (m 0.3))\r
+               nose_dir_vector         = {dx = m (cosinus nose_dir), dy = m (sinus nose_dir) }\r
+               offset                          = {vx = -1, vy = -1}\r
+               nose_dir_point k        = move_point (scale k nose_dir_vector) pos\r
+               \r
+               drawName name picture\r
+               # picture                       = setPenColour White                      picture\r
+               # picture                       = drawAt (ppix (move_point one pos)) name picture\r
+               = picture\r
+               \r
+               drawLyingPlayer fb=:{length} picture\r
+               # (w,picture)           = getPenSize                                                        picture\r
+               # picture                       = setPenSize (pix player_width+2)                                   picture\r
+               # picture                       = setPenColour Black                                                picture\r
+               # picture                       = draw (body_line offset)                                           picture\r
+               # picture                       = setPenSize (pix player_width)                                     picture\r
+               # picture                       = setPenColour colour                                               picture\r
+               # picture                       = draw (body_line zero)                                             picture\r
+               # picture                       = setPenSize w                                                      picture\r
+               # picture                       = fillAt (ppix (nose_dir_point (toReal length+0.2))) bearing_circle picture\r
+               # picture                       = setPenColour Black                                                picture\r
+               # picture                       = drawAt (ppix (nose_dir_point (toReal length+0.2))) bearing_circle picture\r
+               = picture\r
+               where\r
+                       body_line v             = { line_end1 = movePoint v (ppix pos)\r
+                                                         , line_end2 = movePoint v (ppix (nose_dir_point (toReal length))) \r
+                                                         }\r
+               \r
+               drawStandingPlayer fb picture\r
+               # picture                       = setPenColour colour                               picture\r
+               # picture                       = fillAt (ppix pos) body_circle                     picture                                     // body\r
+               # picture                       = fillAt (ppix (nose_dir_point 1.0)) bearing_circle picture                                     // nose direction\r
+               # picture                       = setPenColour Black                                picture                                     // surrounding circle\r
+               # picture                       = drawAt (ppix pos) body_circle                     picture\r
+               # picture                       = drawAt (ppix (nose_dir_point 1.0)) bearing_circle picture                                     // nose direction\r
+               = picture\r
+                       \r
+       drawMiddleArea                  :: !*Picture -> *Picture\r
+       drawMiddleArea picture\r
+       # picture                               = drawLine (ppix {zero & py = scale 0.5 fwidth}) (ppix {zero & py = scale -0.5 fwidth}) picture\r
+       # picture                               = drawAt (ppix zero) (circle (pix radius_centre_circle)) picture                        // middle area\r
+       # picture                               = drawAt (ppix zero) (circle (pix radius_centre_spot))   picture                        // center spot\r
+       = picture\r
+       \r
+       drawGoals                               :: !*Picture -> *Picture\r
+       drawGoals picture\r
+       # picture                               = drawAt (ppix {px=scale  0.5 flength-goal_indent,py=northPole}) h_vector picture               // east north pole\r
+       # picture                               = drawAt (ppix {px=scale  0.5 flength-goal_indent,py=southPole}) h_vector picture               // east south pole\r
+       # picture                               = drawAt (ppix {px=scale -0.5 flength,            py=northPole}) h_vector picture               // west north pole\r
+       # picture                               = drawAt (ppix {px=scale -0.5 flength,            py=southPole}) h_vector picture               // west south pole\r
+       = picture\r
+       where\r
+               goal_indent                     = m 1.0\r
+               h_vector                        = vpix {zero & dx=goal_indent}\r
+       \r
+       drawGoalAreas                   :: !*Picture -> *Picture\r
+       drawGoalAreas picture\r
+       # picture                               = drawAt (ppix {px=scale 0.5 flength-goal_area_depth,   py=northPole+goal_area_depth}) h_vector picture                 // east north edge\r
+       # picture                               = drawAt (ppix {px=scale 0.5 flength-goal_area_depth,   py=southPole-goal_area_depth}) h_vector picture                 // east south edge\r
+       # picture                               = drawAt (ppix {px=scale 0.5 flength-goal_area_depth,   py=northPole+goal_area_depth}) v_vector picture                 // east edge\r
+       # picture                               = drawAt (ppix {px=scale -0.5 flength,                  py=northPole+goal_area_depth}) h_vector picture                 // west north edge\r
+       # picture                               = drawAt (ppix {px=scale -0.5 flength,                  py=southPole-goal_area_depth}) h_vector picture                 // west south edge\r
+       # picture                               = drawAt (ppix {px=scale -0.5 flength + goal_area_depth,py=northPole+goal_area_depth}) v_vector picture                 // west edge\r
+       = picture\r
+       where\r
+               h_vector                        = vpix {zero & dx=goal_area_depth}\r
+               v_vector                        = vpix {zero & dy=scale 2.0 goal_area_depth + goal_width}\r
+       \r
+       drawPenaltyAreas                :: !*Picture -> *Picture\r
+       drawPenaltyAreas picture\r
+       # picture                               = drawAt (ppix {px=scale 0.5 flength-penalty_area_depth,py=northPole+penalty_area_depth}) h_vector picture              // east north edge\r
+       # picture                               = drawAt (ppix {px=scale 0.5 flength-penalty_area_depth,py=southPole-penalty_area_depth}) h_vector picture              // east south edge\r
+       # picture                               = drawAt (ppix {px=scale 0.5 flength-penalty_area_depth,py=northPole+penalty_area_depth}) v_vector picture              // east edge\r
+       # picture                               = drawAt (ppix east_spot) (circle (pix radius_penalty_spot))                                       picture              // east penalty spot\r
+       # picture                               = drawAt (ppix (move_point {dx= ~h_dist,dy= scale (~(sinus angle)) radius_penalty_area} east_spot))                             // east curve\r
+                                                                {curve_oval      = circle (pix radius_penalty_area)\r
+                                                                ,curve_from      = pi + angle\r
+                                                                ,curve_to        = pi - angle\r
+                                                                ,curve_clockwise = True } picture\r
+       # picture                               = drawAt (ppix {px=scale -0.5 flength,                     py=northPole+penalty_area_depth}) h_vector picture   // west north edge\r
+       # picture                               = drawAt (ppix {px=scale -0.5 flength,                     py=southPole-penalty_area_depth}) h_vector picture   // west south edge\r
+       # picture                               = drawAt (ppix {px=scale -0.5 flength + penalty_area_depth,py=northPole+penalty_area_depth}) v_vector picture   // west edge\r
+       # picture                               = drawAt (ppix west_spot) (circle (pix radius_penalty_spot))                                          picture   // west penalty spot\r
+       # picture                               = drawAt (ppix (move_point {dx=h_dist,dy= scale (~(sinus angle)) radius_penalty_area} west_spot))                               // west curve\r
+                                                                {curve_oval      = circle (pix radius_penalty_area)\r
+                                                                ,curve_from      = ~angle\r
+                                                                ,curve_to        = angle\r
+                                                                ,curve_clockwise = False } picture\r
+       = picture\r
+       where\r
+               h_vector                        = vpix {zero & dx=penalty_area_depth}\r
+               v_vector                        = vpix {zero & dy=scale 2.0 penalty_area_depth + goal_width}\r
+               angle                           = arccosinus ((toReal h_dist)/(toReal radius_penalty_area))\r
+               h_dist                          = penalty_area_depth - penalty_spot_depth\r
+               east_spot                       = {zero & px=scale  0.5 flength - penalty_spot_depth}\r
+               west_spot                       = {zero & px=scale -0.5 flength + penalty_spot_depth}\r
+       \r
+       drawCornerAreas                 :: !*Picture -> *Picture\r
+       drawCornerAreas picture\r
+       # picture                               = drawAt (ppix {px=scale -0.5 flength + radius_corner_kick_area,py=scale  0.5 fwidth}) (corner 0.0 (1.5*pi) True ) picture      // west north corner\r
+       # picture                               = drawAt (ppix {px=scale -0.5 flength + radius_corner_kick_area,py=scale -0.5 fwidth}) (corner 0.0 (0.5*pi) False) picture      // west south corner\r
+       # picture                               = drawAt (ppix {px=scale  0.5 flength - radius_corner_kick_area,py=scale  0.5 fwidth}) (corner pi  (1.5*pi) False) picture      // east north corner\r
+       # picture                               = drawAt (ppix {px=scale  0.5 flength - radius_corner_kick_area,py=scale -0.5 fwidth}) (corner pi  (0.5*pi) True ) picture      // east south corner\r
+       = picture\r
+       where\r
+               corner f t c            = {curve_oval=circle (pix radius_corner_kick_area),curve_from=f,curve_to=t,curve_clockwise=c}\r
+       \r
+       drawBall                                :: !Football !*Picture -> *Picture\r
+       drawBall ball picture\r
+       # picture                               = setPenColour ball_colour picture\r
+       # picture                               = fillAt (ppix ball.ballPos.pxy) (circle (pix (scale (2.8*toReal radius_football) (m 1.0 + scale 0.2 ball.ballPos.pz)))) picture\r
+       = picture\r
+\r
+ball_colour                                    :== Black\r
+circle r                                       :== {oval_rx=r,oval_ry=r}\r
diff --git a/src/Gui/textdisplay.dcl b/src/Gui/textdisplay.dcl
new file mode 100644 (file)
index 0000000..d30b876
--- /dev/null
@@ -0,0 +1,31 @@
+definition module textdisplay\r
+\r
+import StdControl, StdId\r
+\r
+/**    A TextDisplay is similar to a TextControl. A TextControl displays text using\r
+       system settings. A TextDisplay uses the ControlPen attribute to display text.\r
+       In addition, the ControlSize can be set by the programmer. \r
+       The following ControlAttribute-s are inherited:\r
+               ControlMinimumSize: the minimum size of the control in case of resizing\r
+               ControlPen:         the pen settings used to display the text\r
+               ControlPos:         the layout position of the text display control\r
+               ControlResize:      resizing the control\r
+               ControlTip:         the tool tip text that must be displayed\r
+*/\r
+::     TextDisplay ls pst\r
+ =     TextDisplay TextDisplayId String TextSize [ControlAttribute *(ls,pst)]\r
+::     TextDisplayId\r
+ =     {       customId        :: !Id\r
+       ,       receiverId      :: !R2Id TextDisplayMsgIn TextDisplayMsgOut\r
+       }\r
+::     TextDisplayMsgIn  = SetTextIn String | GetTextIn\r
+::     TextDisplayMsgOut = SetTextOut       | GetTextOut String\r
\r
+::     TextSize :== Size       // The size of the text display\r
+\r
+openTextDisplayId :: !*env -> (!TextDisplayId,!*env) | Ids env\r
+\r
+instance Controls TextDisplay\r
+\r
+getTextDisplayText :: !TextDisplayId                 !(PSt .ps) -> (!String,!PSt .ps)\r
+setTextDisplayText :: !TextDisplayId !String         !(PSt .ps) -> PSt .ps\r
diff --git a/src/Gui/textdisplay.icl b/src/Gui/textdisplay.icl
new file mode 100644 (file)
index 0000000..494092f
--- /dev/null
@@ -0,0 +1,107 @@
+implementation module textdisplay\r
+\r
+import StdInt, StdList, StdMisc\r
+import StdControl, StdControlAttribute, StdControlReceiver, StdId, StdPSt, StdReceiver\r
+\r
+/**    A TextDisplay is similar to a TextControl. A TextControl displays text using\r
+       system settings. A TextDisplay uses the ControlPen attribute to display text.\r
+       In addition, the ControlSize can be set by the programmer. \r
+       The following ControlAttribute-s are inherited:\r
+               ControlMinimumSize: the minimum size of the control in case of resizing\r
+               ControlPen:         the pen settings used to display the text\r
+               ControlPos:         the layout position of the text display control\r
+               ControlResize:      resizing the control\r
+               ControlTip:         the tool tip text that must be displayed\r
+*/\r
+::     TextDisplay ls pst\r
+ =     TextDisplay TextDisplayId String TextSize [ControlAttribute *(ls,pst)]\r
+::     TextDisplayId\r
+ =     {       customId        :: !Id\r
+       ,       receiverId      :: !R2Id TextDisplayMsgIn TextDisplayMsgOut\r
+       }\r
+::     TextSize :== Size       // The size of the text display\r
+::     TextDisplayMsgIn  = SetTextIn String | GetTextIn\r
+::     TextDisplayMsgOut = SetTextOut       | GetTextOut String\r
+\r
+openTextDisplayId :: !*env -> (!TextDisplayId,!*env) | Ids env\r
+openTextDisplayId env\r
+       # (id,  env) = openId env\r
+       # (r2id,env) = openR2Id env\r
+       = ({customId=id,receiverId=r2id},env)\r
+\r
+::     TextDisplaySt\r
+ =     {       text    :: !String      // The text to be displayed\r
+       }\r
+\r
+instance Controls TextDisplay where\r
+       controlToHandles (TextDisplay {customId,receiverId} text size atts) pst\r
+               = controlToHandles textdisplay pst\r
+       where\r
+               customControlSize       = validateTextDisplaySize minSize size\r
+               initDisplaySt           = { text        = text\r
+                                                         }\r
+               textdisplay                     = { newLS       = initDisplaySt\r
+                                                         , newDef      = CustomControl customControlSize (displaylook text) [ ControlId customId : okAtts ]\r
+                                                                                       :+:\r
+                                                                                 Receiver2 receiverId receiverfun []\r
+                                                         }\r
+               okAtts                          = map toTextDisplayAttribute (filter isTextDisplayAttribute atts)\r
+               minSize                         = case filter isControlMinimumSize okAtts of\r
+                                                               [ControlMinimumSize s : _]      -> s\r
+                                                               _                                                       -> zero\r
+\r
+               receiverfun :: !TextDisplayMsgIn !*(TextDisplaySt,PSt .ps) -> (TextDisplayMsgOut,(TextDisplaySt,PSt .ps))\r
+               receiverfun (SetTextIn str) (tdst,pst=:{io})\r
+                       # tdst  = {tdst & text = str}\r
+                       # io    = setControlLook customId True (True,displaylook str) io\r
+                       = (SetTextOut,(tdst,{pst & io=io}))\r
+               receiverfun GetTextIn (tdst=:{text},pst)\r
+                       = (GetTextOut text,(tdst,pst))\r
+               \r
+               displaylook :: !String !SelectState !UpdateState !*Picture -> *Picture\r
+               displaylook text _ {newFrame} picture\r
+                       # picture                       = unfill newFrame picture\r
+                       # (metrics,picture)     = getPenFontMetrics picture\r
+                       # base                          = metrics.fAscent + metrics.fLeading\r
+                       # height                        = fontLineHeight metrics\r
+                       # (width,picture)       = getPenFontStringWidth text picture\r
+                       # picture                       = drawAt {x=max 0 ((w-width)/2),y=(h-height)/2+base} text picture\r
+                       = picture\r
+               where\r
+                       {w,h}                           = rectangleSize newFrame\r
+               \r
+       getControlType _ = "TextDisplay"\r
+\r
+isTextDisplayAttribute :: !(ControlAttribute .ps) -> Bool\r
+isTextDisplayAttribute (ControlMinimumSize _)  = True\r
+isTextDisplayAttribute (ControlPen         _)  = True\r
+isTextDisplayAttribute (ControlPos         _)  = True\r
+isTextDisplayAttribute (ControlResize      _)  = True\r
+isTextDisplayAttribute (ControlTip         _)  = True\r
+isTextDisplayAttribute _                                               = False\r
+\r
+toTextDisplayAttribute :: !(ControlAttribute *(.ls,.pst)) -> ControlAttribute *(TextDisplaySt,.pst)\r
+toTextDisplayAttribute (ControlMinimumSize s)  = ControlMinimumSize s\r
+toTextDisplayAttribute (ControlPen         p)  = ControlPen         p\r
+toTextDisplayAttribute (ControlPos         p)  = ControlPos         p\r
+toTextDisplayAttribute (ControlResize      f)  = ControlResize      f\r
+toTextDisplayAttribute (ControlTip         t)  = ControlTip         t\r
+\r
+\r
+validateTextDisplaySize :: !Size !Size -> Size\r
+validateTextDisplaySize minSize {w,h} = {w=max w (min 0 minSize.w),h=max h (min 0 minSize.h)}\r
+\r
+getTextDisplayText :: !TextDisplayId !(PSt .ps) -> (!String,!PSt .ps)\r
+getTextDisplayText {receiverId} pst\r
+       = case syncSend2 receiverId GetTextIn pst of\r
+               ((SendOk,Just (GetTextOut x)),pst) -> (x,pst)\r
+               other                              -> sendError "getTextDisplayText"\r
+\r
+setTextDisplayText :: !TextDisplayId !String !(PSt .ps) -> PSt .ps\r
+setTextDisplayText {receiverId} newTxt pst\r
+       = case syncSend2 receiverId (SetTextIn newTxt) pst of\r
+               ((SendOk,Just SetTextOut),pst) -> pst\r
+               other                          -> sendError "setTextDisplayText"\r
+\r
+sendError fName\r
+       = abort (fName +++ ": wrong reply from TextDisplay.\n")\r
diff --git a/src/SoccerFun.env b/src/SoccerFun.env
new file mode 100644 (file)
index 0000000..ca5338e
--- /dev/null
@@ -0,0 +1,27 @@
+Version: 1.0\r
+Environments\r
+       Environment\r
+               EnvironmentName:        SoccerFun\r
+               EnvironmentPaths\r
+                       Path:   {Application}\Libraries\StdEnv\r
+                       Path:   {Application}\Libraries\StdLib\r
+                       Path:   {Application}\Libraries\ObjectIO\r
+                       Path:   {Application}\Libraries\ObjectIO\OS Windows\r
+                       Path:   {Application}\Libraries\Parsers\r
+                       Path:   {Application}\Libraries\Parsers\LanguageDependent\r
+                       Path:   {Application}\Libraries\Parsers\LanguageDependent\English\r
+                       Path:   {Application}\Examples\ObjectIO Examples\gui utilities\r
+                       Path:   {Application}\Examples\SoccerFun\src\Game\r
+                       Path:   {Application}\Examples\SoccerFun\src\Gui\r
+                       Path:   {Application}\Examples\SoccerFun\src\StdLibExt\r
+                       Path:   {Application}\Examples\SoccerFun\src\StdReferee\r
+                       Path:   {Application}\Examples\SoccerFun\src\StdTeam\r
+               EnvironmentCompiler:    Tools\Clean System\CleanCompiler.exe\r
+               EnvironmentCodeGen:     Tools\Clean System\CodeGenerator.exe\r
+               EnvironmentLinker:      Tools\Clean System\StaticLinker.exe: -h 40M\r
+               EnvironmentDynLink:     Tools\Dynamics\DynamicLinker.exe\r
+               EnvironmentVersion:     920\r
+               EnvironmentRedirect:    False\r
+               EnvironmentCompileMethod:       Pers\r
+               EnvironmentProcessor:   I386\r
+               Environment64BitProcessor:      False\r
diff --git a/src/SoccerFun.icl b/src/SoccerFun.icl
new file mode 100644 (file)
index 0000000..85de8fa
--- /dev/null
@@ -0,0 +1,10 @@
+module SoccerFun\r
+\r
+/**    The main module for Soccer-Fun.\r
+*/\r
+import matchControl\r
+\r
+/**    Function to start SoccerFun.\r
+*/\r
+Start :: *World -> *World\r
+Start world = doSoccerFun world\r
diff --git a/src/SoccerFun.prj b/src/SoccerFun.prj
new file mode 100644 (file)
index 0000000..464dc9e
--- /dev/null
@@ -0,0 +1,3027 @@
+Version: 1.4\r
+Global\r
+       ProjectRoot:    .\r
+       Built:  True\r
+       Target: SoccerFun64\r
+       Exec:   {Project}\SoccerFun.exe\r
+       CodeGen\r
+               CheckStacks:    False\r
+               CheckIndexes:   True\r
+       Application\r
+               HeapSize:       2097152\r
+               StackSize:      512000\r
+               ExtraMemory:    81920\r
+               IntialHeapSize: 204800\r
+               HeapSizeMultiplier:     4096\r
+               ShowExecutionTime:      False\r
+               ShowGC: False\r
+               ShowStackSize:  False\r
+               MarkingCollector:       False\r
+               StandardRuntimeEnv:     True\r
+               Profile\r
+                       Memory: False\r
+                       MemoryMinimumHeapSize:  0\r
+                       Time:   False\r
+                       Stack:  False\r
+               Output\r
+                       Output: ShowConstructors\r
+                       Font:   Courier\r
+                       FontSize:       9\r
+                       WriteStdErr:    False\r
+       Link\r
+               LinkMethod:     Static\r
+               GenerateRelocations:    False\r
+               GenerateLinkMap:        False\r
+               LinkResources:  False\r
+               ResourceSource: \r
+               GenerateDLL:    False\r
+               ExportedNames:  \r
+       Paths\r
+               Path:   {Project}\r
+               Path:   {Project}\Achten Peter\r
+       Precompile:     \r
+       Postlink:       \r
+MainModule\r
+       Name:   SoccerFun\r
+       Dir:    {Project}\r
+       Compiler\r
+               NeverMemoryProfile:     False\r
+               NeverTimeProfile:       False\r
+               StrictnessAnalysis:     True\r
+               ListTypes:      StrictExportTypes\r
+               ListAttributes: True\r
+               Warnings:       True\r
+               Verbose:        True\r
+               ReadableABC:    False\r
+               ReuseUniqueNodes:       True\r
+               Fusion: False\r
+OtherModules\r
+       Module\r
+               Name:   StdBitmap\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdClipboard\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdControl\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdControlAttribute\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdControlClass\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdControlDef\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdControlReceiver\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdFileSelect\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdIO\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdIOBasic\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdIOCommon\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdId\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdKey\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdMenu\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdMenuAttribute\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdMenuDef\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdMenuElement\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdMenuElementClass\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdMenuReceiver\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdPSt\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdPStClass\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdPicture\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdPictureDef\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdPrint\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdPrintText\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdProcess\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdProcessAttribute\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdProcessDef\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdReceiver\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdReceiverAttribute\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdReceiverDef\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdSystem\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdTime\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdTimer\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdTimerAttribute\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdTimerDef\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdTimerElementClass\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdTimerReceiver\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdWindow\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdWindowAttribute\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdWindowDef\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   cast\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   commondef\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   controlaccess\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   controlcreate\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   controldraw\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   controlinternal\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   controllayout\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   controlpos\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   controlrelayout\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   controlresize\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   controlvalidate\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   device\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   deviceevents\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   devicefunctions\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   devicesystemstate\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   id\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   iostate\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   keyfocus\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   layout\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   menuaccess\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   menucreate\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   menudefaccess\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   menudevice\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   menuhandle\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   menuinternal\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   menuitems\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   mstate\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   processdevice\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   processhandle\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   processstack\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   receiveraccess\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   receiverdefaccess\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   receiverdevice\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   receiverhandle\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   receiverid\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   receivermessage\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   receivertable\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   relayout\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   roundrobin\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   scheduler\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   sdisize\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   semidynamic\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   systemid\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   timeraccess\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   timerdefaccess\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   timerdevice\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   timerhandle\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   timertable\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   toolbar\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   windowaccess\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   windowclipstate\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   windowcontrols\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   windowcreate\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   windowdevice\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   windowdispose\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   windowdraw\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   windowhandle\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   windowupdate\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   windowvalidate\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   world\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   wstate\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   wstateaccess\r
+               Dir:    {Application}\Libraries\ObjectIO\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   clCCall_12\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+               NeededObjFiles\r
+                       ObjectFile:     util_121.\r
+                       ObjectFile:     cpicture_121.\r
+                       ObjectFile:     cdebug_121.\r
+                       ObjectFile:     cCrossCall_121.\r
+                       ObjectFile:     cCrossCallWindows_121.\r
+                       ObjectFile:     cCCallWindows_121.\r
+                       ObjectFile:     cCCallSystem_121.\r
+       Module\r
+               Name:   clCrossCall_12\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+               NeededObjFiles\r
+                       ObjectFile:     cCrossCallWindows_121.\r
+                       ObjectFile:     cCrossCallProcedureTable_121.\r
+                       ObjectFile:     cCrossCallCursor_121.\r
+                       ObjectFile:     cCrossCall_121.\r
+                       ObjectFile:     cCCallSystem_121.\r
+                       ObjectFile:     cCCallWindows_121.\r
+                       ObjectFile:     cAcceleratorTable_121.\r
+               NeededLibraries\r
+                       Library:        userExt_library\r
+                       Library:        gdiExt_library\r
+                       Library:        kernelExt_library\r
+                       Library:        winspool_library\r
+                       Library:        winmm_library\r
+                       Library:        shell32_library\r
+                       Library:        ole32_library\r
+                       Library:        kernel32_library\r
+                       Library:        comctl32_library\r
+                       Library:        advapi32_library\r
+       Module\r
+               Name:   clipboardCrossCall_12\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+               NeededObjFiles\r
+                       ObjectFile:     cCrossCallClipboard_121.\r
+       Module\r
+               Name:   menuCCall_12\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+               NeededObjFiles\r
+                       ObjectFile:     cCrossCallMenus_121.\r
+       Module\r
+               Name:   menuCrossCall_12\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   menuevent\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   menuwindowmenu\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   osactivaterequests\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   osbeep\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   osbitmap\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   osclipboard\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   osdocumentinterface\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+               NeededObjFiles\r
+                       ObjectFile:     cCrossCallxDI_121.\r
+       Module\r
+               Name:   osevent\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   osfileselect\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+               NeededObjFiles\r
+                       ObjectFile:     cCrossCallFileSelectors_121.\r
+       Module\r
+               Name:   osfont\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   osguishare\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   oskey\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   osmenu\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   osmouse\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   ospicture\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   osprint\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+               NeededObjFiles\r
+                       ObjectFile:     cprinter_121.\r
+                       ObjectFile:     cCrossCallPrinter_121.\r
+       Module\r
+               Name:   osrgn\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   ossystem\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   ostick\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   ostime\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   ostoolbar\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   ostoolbox\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+               NeededObjFiles\r
+                       ObjectFile:     cCrossCallFont_121.\r
+       Module\r
+               Name:   ostooltip\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   ostypes\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   oswindow\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   pictCCall_12\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   processevent\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   receiverevent\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   rgnCCall_12\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   timerevent\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   windowCCall_12\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+               NeededObjFiles\r
+                       ObjectFile:     cpicture_121.\r
+                       ObjectFile:     cCCallWindows_121.\r
+       Module\r
+               Name:   windowCrossCall_12\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   windowevent\r
+               Dir:    {Application}\Libraries\ObjectIO\OS Windows\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Parsers\r
+               Dir:    {Application}\Libraries\Parsers\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   ParsersAccessories\r
+               Dir:    {Application}\Libraries\Parsers\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   ParsersDerived\r
+               Dir:    {Application}\Libraries\Parsers\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   ParsersKernel\r
+               Dir:    {Application}\Libraries\Parsers\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   ParserLanguage\r
+               Dir:    {Application}\Libraries\Parsers\LanguageDependent\Nederlands\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdArray\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdBool\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdChar\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdCharList\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdClass\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdDebug\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdEnum\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdEnv\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdFile\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdFunc\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdInt\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdList\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdMisc\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdOrdList\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdOverloaded\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdReal\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdString\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdTuple\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   _SystemArray\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   _SystemEnum\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdLibMisc\r
+               Dir:    {Application}\Libraries\StdLib\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdMaybe\r
+               Dir:    {Application}\Libraries\StdLib\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Football\r
+               Dir:    {Project}\Game\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Footballer\r
+               Dir:    {Project}\Game\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   FootballerFunctions\r
+               Dir:    {Project}\Game\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   GamePicture\r
+               Dir:    {Project}\Game\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Geometry\r
+               Dir:    {Project}\Game\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Referee\r
+               Dir:    {Project}\Game\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Team\r
+               Dir:    {Project}\Game\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   matchControl\r
+               Dir:    {Project}\Game\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   matchGame\r
+               Dir:    {Project}\Game\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   matchLog\r
+               Dir:    {Project}\Game\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   randomstream\r
+               Dir:    {Project}\Game\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Gui2D\r
+               Dir:    {Project}\Gui\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   digitdisplay\r
+               Dir:    {Project}\Gui\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   guiInterface\r
+               Dir:    {Project}\Gui\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   renderGame\r
+               Dir:    {Project}\Gui\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   textdisplay\r
+               Dir:    {Project}\Gui\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   RandomExt\r
+               Dir:    {Project}\StdLibExt\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   RangeSlider\r
+               Dir:    {Project}\StdLibExt\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdEnvExt\r
+               Dir:    {Project}\StdLibExt\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdIOExt\r
+               Dir:    {Project}\StdLibExt\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   fileIO\r
+               Dir:    {Project}\StdLibExt\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Ivanov\r
+               Dir:    {Project}\StdReferee\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   RefereeCoach_DeepPass_Assignment\r
+               Dir:    {Project}\StdReferee\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   RefereeCoach_Keeper_Assignment\r
+               Dir:    {Project}\StdReferee\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   RefereeCoach_Passing_Assignment\r
+               Dir:    {Project}\StdReferee\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   RefereeCoach_Rounds_Assignment\r
+               Dir:    {Project}\StdReferee\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   RefereeCoach_Slalom_Assignment\r
+               Dir:    {Project}\StdReferee\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   RefereeFunctions\r
+               Dir:    {Project}\StdReferee\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Umpire\r
+               Dir:    {Project}\StdReferee\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Buffer\r
+               Dir:    {Project}\StdTeam\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   KeeperChallenger\r
+               Dir:    {Project}\StdTeam\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   TeamMiniEffie\r
+               Dir:    {Project}\StdTeam\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Team_Opponent_DeepPass_Assignment\r
+               Dir:    {Project}\StdTeam\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Team_Opponent_Keeper_Assignment\r
+               Dir:    {Project}\StdTeam\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Team_Opponent_Passing_Assignment\r
+               Dir:    {Project}\StdTeam\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Team_Opponent_Slalom_Assignment\r
+               Dir:    {Project}\StdTeam\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Team_Student_DeepPass_Assignment\r
+               Dir:    {Project}\StdTeam\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Team_Student_Keeper_Assignment\r
+               Dir:    {Project}\StdTeam\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Team_Student_Passing_Assignment\r
+               Dir:    {Project}\StdTeam\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Team_Student_Rounds_Assignment\r
+               Dir:    {Project}\StdTeam\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   Team_Student_Slalom_Assignment\r
+               Dir:    {Project}\StdTeam\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
diff --git a/src/SoccerFun64.env b/src/SoccerFun64.env
new file mode 100644 (file)
index 0000000..4fdbb12
--- /dev/null
@@ -0,0 +1,27 @@
+Version: 1.0\r
+Environments\r
+       Environment\r
+               EnvironmentName:        SoccerFun64\r
+               EnvironmentPaths\r
+                       Path:   {Application}\Libraries\StdEnv\r
+                       Path:   {Application}\Libraries\StdLib\r
+                       Path:   {Application}\Libraries\ObjectIO\r
+                       Path:   {Application}\Libraries\ObjectIO\OS Windows\r
+                       Path:   {Application}\Libraries\Parsers\r
+                       Path:   {Application}\Libraries\Parsers\LanguageDependent\r
+                       Path:   {Application}\Libraries\Parsers\LanguageDependent\English\r
+                       Path:   {Application}\Examples\ObjectIO Examples\gui utilities\r
+                       Path:   {Application}\Examples\SoccerFun\src\Game\r
+                       Path:   {Application}\Examples\SoccerFun\src\Gui\r
+                       Path:   {Application}\Examples\SoccerFun\src\StdLibExt\r
+                       Path:   {Application}\Examples\SoccerFun\src\StdReferee\r
+                       Path:   {Application}\Examples\SoccerFun\src\StdTeam\r
+               EnvironmentCompiler:    Tools\Clean System 64\CleanCompiler64.exe\r
+               EnvironmentCodeGen:     Tools\Clean System 64\CodeGenerator.exe\r
+               EnvironmentLinker:      Tools\Clean System 64\StaticLinker.exe: -h 40M\r
+               EnvironmentDynLink:     Tools\Dynamics\DynamicLinker.exe\r
+               EnvironmentVersion:     920\r
+               EnvironmentRedirect:    False\r
+               EnvironmentCompileMethod:       Pers\r
+               EnvironmentProcessor:   I386\r
+               Environment64BitProcessor:      True\r
diff --git a/src/SoccerFun_options.txt b/src/SoccerFun_options.txt
new file mode 100644 (file)
index 0000000..787224a
--- /dev/null
@@ -0,0 +1 @@
+{closeReferee=True,showSplash=False,displaySpeed=Normal,showReferee=True,playingTime=4:00 min,renderStyle=Fixed camera}
\ No newline at end of file
diff --git a/src/StdLibExt/RandomExt.dcl b/src/StdLibExt/RandomExt.dcl
new file mode 100644 (file)
index 0000000..5b19fac
--- /dev/null
@@ -0,0 +1,28 @@
+definition module RandomExt\r
+\r
+//     **************************************************************************************************\r
+//\r
+//     General utility for random number generation.\r
+//\r
+//     This module is actually an extension of the Random module in the 'Object IO Examples:gui utilities'\r
+//     folder. That module lacked instances of the usual overloaded functions.\r
+//     \r
+//     **************************************************************************************************\r
+\r
+import StdTime\r
+import StdClass\r
+\r
+::     RandomSeed\r
+\r
+nullRandomSeed :: RandomSeed\r
+//     nullRandomSeed generates a useless RandomSeed (random nullRandomSeed = (0,nullRandomSeed)).\r
+\r
+getNewRandomSeed:: !*env       -> (!RandomSeed, !*env) | TimeEnv env\r
+//     GetNewRandomSeed generates a useful RandomSeed, using the current time.\r
+\r
+random                 :: !RandomSeed          -> (!Int, !RandomSeed)\r
+//     Given a RandomSeed, Random generates a random number and a new RandomSeed.\r
+\r
+instance toString   RandomSeed\r
+instance fromString RandomSeed\r
+instance ==         RandomSeed\r
diff --git a/src/StdLibExt/RandomExt.icl b/src/StdLibExt/RandomExt.icl
new file mode 100644 (file)
index 0000000..1ed4f58
--- /dev/null
@@ -0,0 +1,30 @@
+implementation module RandomExt\r
+\r
+import StdEnvExt\r
+import StdClass, StdInt, StdString\r
+import StdTime\r
+\r
+\r
+::     RandomSeed      = RS !Int\r
+\r
+\r
+nullRandomSeed :: RandomSeed\r
+nullRandomSeed\r
+= RS 0\r
+\r
+getNewRandomSeed :: !*env -> (!RandomSeed, !*env) | TimeEnv env\r
+getNewRandomSeed env\r
+# ({hours,minutes,seconds}, env)       = getCurrentTime env\r
+= (RS (1+(hours+minutes+seconds) bitand 65535), env)\r
+\r
+random :: !RandomSeed -> (!Int,!RandomSeed)\r
+random (RS seed)\r
+= (newSeed,RS newSeed)\r
+where\r
+       newSeed         = if (nextSeed>=0) nextSeed (nextSeed+65537)\r
+       nextSeed        = (seed75 bitand 65535)-(seed75>>16)\r
+       seed75          = seed*75\r
+\r
+instance toString   RandomSeed where toString (RS r)    = toString r\r
+instance fromString RandomSeed where fromString str     = RS (fromString str)\r
+instance ==         RandomSeed where == (RS r1) (RS r2) = r1 == r2\r
diff --git a/src/StdLibExt/RangeSlider.dcl b/src/StdLibExt/RangeSlider.dcl
new file mode 100644 (file)
index 0000000..5c4c987
--- /dev/null
@@ -0,0 +1,53 @@
+definition module RangeSlider\r
+\r
+import StdEnv, StdIO\r
+\r
+/**    A (RangeSlider id dir width range action atts) value describes a control that allows users to select values from the \r
+       given range. The parameters have the following meaning:\r
+       id:             the identification value of the range slider;\r
+       dir:    the direction of the range slider (Horizontal or Vertical);\r
+       width:  the length of the range slider;\r
+       range:  the range {values=[v_0, ..., v_n],index=i}; here i is the 0-based index of the currently selected value, v_i.\r
+                       When the user selects another value, then index will have the corresponding value;\r
+       action: the function that is applied to the current local and process state of the control whenever the user has used\r
+                       the range slider;\r
+       atts:   the standard set of control attributes.\r
+       \r
+       Author: Peter Achten\r
+       E-mail: P.Achten@cs.ru.nl\r
+       Date:   january 2008\r
+       Uses:   Clean 2.2, Object I/O\r
+*/\r
+::     RangeSliderId a\r
+::     RangeSlider a ls pst\r
+       =       RangeSlider (RangeSliderId a) Direction ControlWidth (Range a) (RangeAction a *(ls,pst)) [ControlAttribute *(ls,pst)]\r
+::     Range a\r
+       =       { values        :: ![a]\r
+               , index         :: !RangeIndex\r
+               }\r
+::     RangeIndex\r
+       :== Int\r
+::     RangeAction a st\r
+       :== a -> st -> st\r
+\r
+openRangeSliderId :: !*env -> (!RangeSliderId a,!*env) | Ids env\r
+\r
+instance Controls (RangeSlider a)\r
+\r
+/** getRangeSliderIndex id pSt\r
+               yields (Just index) of the selected value of the indicated range slider if it exists, and Nothing otherwise.\r
+       getRangeSliderValue id pSt\r
+               yields (Maybe (values!!index)) of the indicated range slider if it exists, and Nothing otherwise.\r
+       setRangeSliderIndex id i pSt\r
+               sets the current index value of the indicated range slider to i, and applies the action function to that value\r
+               and the current local and process state.\r
+               If the indicated range slider does not exist, nothing happens.\r
+       setRangeSliderValue id v pSt\r
+               updates the value at the current index of the indicated range slider to v, and applies the action function to \r
+               that value and the current local and process state.\r
+               If the indicated range slider does not exist, nothing happens.\r
+*/\r
+getRangeSliderIndex :: !(RangeSliderId a)        !(PSt .ps) -> (!Maybe RangeIndex,!PSt .ps)\r
+getRangeSliderValue :: !(RangeSliderId a)        !(PSt .ps) -> (!Maybe a,         !PSt .ps)\r
+setRangeSliderIndex :: !(RangeSliderId a) !Index !(PSt .ps) ->                     PSt .ps\r
+setRangeSliderValue :: !(RangeSliderId a) !a     !(PSt .ps) ->                     PSt .ps\r
diff --git a/src/StdLibExt/RangeSlider.icl b/src/StdLibExt/RangeSlider.icl
new file mode 100644 (file)
index 0000000..7ae5ffa
--- /dev/null
@@ -0,0 +1,119 @@
+implementation module RangeSlider\r
+\r
+import StdEnv, StdIO\r
+\r
+::     RangeSliderId a\r
+       =       { sliderId      :: Id\r
+               , recId     :: R2Id (RangeSliderMsgIn a) (RangeSliderMsgOut a)\r
+               }\r
+::     RangeSliderMsgIn a\r
+       =       RSIn_GetIndex\r
+       |       RSIn_GetValue\r
+       |       RSIn_SetIndex RangeIndex\r
+       |       RSIn_SetValue a\r
+::     RangeSliderMsgOut a\r
+       =       RSOut_GetIndex RangeIndex\r
+       |       RSOut_GetValue a\r
+       |       RSOut_SetIndex\r
+       |       RSOut_SetValue\r
+::     RangeSliderSt a\r
+       :== Range a\r
+\r
+openRangeSliderId :: !*env -> (!RangeSliderId a,!*env) | Ids env\r
+openRangeSliderId env\r
+       # (sliderId,env)        = openId   env\r
+       # (recId,   env)        = openR2Id env\r
+       = ({sliderId=sliderId,recId=recId},env)\r
+\r
+instance Controls (RangeSlider a) where\r
+       controlToHandles (RangeSlider {sliderId,recId} dir width range=:{values,index} f atts) pSt\r
+               = controlToHandles impl pSt\r
+       where\r
+               f`              = liftF2 f\r
+               impl    = { addLS  = range\r
+                                 , addDef = SliderControl dir width state (action f`) [ControlId sliderId:map toLS atts]\r
+                                                               :+:\r
+                                                    Receiver2 recId (recF f`) []\r
+                                 }\r
+               state   = { sliderMin   = 0\r
+                                 , sliderMax   = length values - 1\r
+                                 , sliderThumb = index\r
+                                 }\r
+               \r
+               action f move ((range=:{values,index},ls),pSt)\r
+                               = f (values!!i) (({range & index=i},ls),appPIO (setSliderThumb sliderId i) pSt)\r
+               where\r
+                       i       = case move of\r
+                                       SliderIncSmall                  = min (index+1)                          (length values-1)\r
+                                       SliderDecSmall                  = max (index-1)                          0\r
+                                       SliderIncLarge                  = min (index+(max 1 (length values)/10)) (length values-1)\r
+                                       SliderDecLarge                  = max (index-(max 1 (length values)/10)) 0\r
+                                       SliderThumb new                 = new\r
+               \r
+               recF f RSIn_GetIndex ((range=:{index},ls),pSt)\r
+                       = (RSOut_GetIndex index,((range,ls),pSt))\r
+               recF f RSIn_GetValue ((range=:{values,index},ls),pSt)\r
+                       = (RSOut_GetValue (values!!index),((range,ls),pSt))\r
+               recF f (RSIn_SetIndex i) ((range=:{values},ls),pSt)\r
+                       = (RSOut_SetIndex,f (values!!i`) (({range & index=i`},ls),pSt))\r
+               where\r
+                       i`                                                              = min (max i 0) (length values-1)\r
+               recF f (RSIn_SetValue v) ((range=:{values,index},ls),pSt)\r
+                       = (RSOut_SetValue,f v (({range & values=updateAt index v values},ls),pSt))\r
+               \r
+               toLS (ControlActivate     f)            = ControlActivate   (liftF f)\r
+               toLS (ControlDeactivate   f)            = ControlDeactivate (liftF f)\r
+               toLS (ControlFunction     f)            = ControlFunction   (liftF f)\r
+               toLS  ControlHide                                       = ControlHide\r
+               toLS (ControlId           id)           = ControlId         id\r
+               toLS (ControlKeyboard     kF s f)       = ControlKeyboard kF s (liftF2 f)\r
+               toLS (ControlMinimumSize  s)            = ControlMinimumSize s\r
+               toLS (ControlModsFunction f)            = ControlModsFunction  (liftF2 f)\r
+               toLS (ControlMouse        mF s f)       = ControlMouse    mF s (liftF2 f)\r
+               toLS (ControlPen          p)            = ControlPen         p\r
+               toLS (ControlPos          p)            = ControlPos         p\r
+               toLS (ControlResize       f)            = ControlResize      f\r
+               toLS (ControlSelectState  s)            = ControlSelectState s\r
+               toLS (ControlTip          t)            = ControlTip         t\r
+               toLS (ControlWidth        w)            = ControlWidth       w\r
+               toLS (ControlHMargin      l r)          = ControlHMargin     l r\r
+               toLS (ControlHScroll      f)            = ControlHScroll     f\r
+               toLS (ControlItemSpace    x y)          = ControlItemSpace   x y\r
+               toLS (ControlLook         b f)          = ControlLook        b f\r
+               toLS (ControlOrigin       o)            = ControlOrigin      o\r
+               toLS (ControlOuterSize    s)            = ControlOuterSize   s\r
+               toLS (ControlViewDomain   d)            = ControlViewDomain  d\r
+               toLS (ControlViewSize     s)            = ControlViewSize    s\r
+               toLS (ControlVMargin      t b)          = ControlVMargin     t b\r
+               toLS (ControlVScroll      f)            = ControlVScroll     f\r
+               \r
+               liftF f ((add,ls),pSt)\r
+                       # (ls,pSt)      = f (ls,pSt)\r
+                       = ((add,ls),pSt)\r
+               \r
+               liftF2 f a ((add,ls),pSt)\r
+                       # (ls,pSt)      = f a (ls,pSt)\r
+                       = ((add,ls),pSt)\r
+       \r
+       getControlType _\r
+               = "RangeSlider"\r
+\r
+getRangeSliderIndex :: !(RangeSliderId a) !(PSt .ps) -> (!Maybe RangeIndex,!PSt .ps)\r
+getRangeSliderIndex {recId} pSt\r
+       = case syncSend2 recId RSIn_GetIndex pSt of\r
+               ((SendOk,Just (RSOut_GetIndex i)),pSt)  = (Just i, pSt)\r
+               (_,pSt)                                                                 = (Nothing,pSt)\r
+\r
+getRangeSliderValue :: !(RangeSliderId a) !(PSt .ps) -> (!Maybe a,!PSt .ps)\r
+getRangeSliderValue {recId} pSt\r
+       = case syncSend2 recId RSIn_GetValue pSt of\r
+               ((SendOk,Just (RSOut_GetValue v)),pSt)  = (Just v, pSt)\r
+               (_,pSt)                                                                 = (Nothing,pSt)\r
+\r
+setRangeSliderIndex :: !(RangeSliderId a) !Index !(PSt .ps) -> PSt .ps\r
+setRangeSliderIndex {recId} i pSt\r
+       = snd (syncSend2 recId (RSIn_SetIndex i) pSt)\r
+\r
+setRangeSliderValue :: !(RangeSliderId a) !a !(PSt .ps) -> PSt .ps\r
+setRangeSliderValue {recId} v pSt\r
+       = snd (syncSend2 recId (RSIn_SetValue v) pSt)\r
diff --git a/src/StdLibExt/StdEnvExt.dcl b/src/StdLibExt/StdEnvExt.dcl
new file mode 100644 (file)
index 0000000..47e0788
--- /dev/null
@@ -0,0 +1,263 @@
+definition module StdEnvExt\r
+\r
+/** Collection of generally useful functions that are not related to SoccerFun.\r
+*/\r
+import StdEnv\r
+import StdMaybe\r
+\r
+/** const2 a _ _ = a\r
+               is a frequently occurring version of the const function.\r
+*/\r
+const2 :: !.a .b .c -> .a\r
+\r
+/**    iterateSt f x\r
+               is the state based version of iterate (StdList):\r
+       iterateSt f x_0\r
+               [y_1,y_2,y_3,y_4...]\r
+       where\r
+               (y_i,x_i) = f x_i\r
+*/\r
+iterateSt :: !(s -> (a,s)) !s -> [a]\r
+\r
+/** iterateStn n f x\r
+               is the finite version of iterateSt.\r
+*/\r
+iterateStn :: !Int !(s -> (a,s)) !s -> (![a],!s)\r
+\r
+/** State strict versions of seq and seqList:\r
+*/\r
+sseq    :: ![.(.s -> .s)] !.s -> .s\r
+sseqList:: ![St .s .a]    !.s -> (![.a],!.s)\r
+\r
+/** apply x [f_0 ... f_n] = [f_0 x, ..., f_n x]\r
+*/\r
+apply :: a ![a->.b] -> [.b]\r
+\r
+/**    State passing version of map:\r
+*/\r
+mapSt  :: !(.(.a,.s) -> .(.b,.s)) !(![.a],.s) -> (![.b],.s)\r
+\r
+/**    Strict state passing version of map:\r
+*/\r
+smapSt :: !(.(.a,.s) -> .(.b,.s)) !(![.a],!.s) -> (![.b],!.s)\r
+\r
+/**    singleOutElems [a_1..a_n] = [(a_1,[a_2..a_n]),(a_2,[a_1,a_3..a_n])..(a_n,[a_1..a_(n-1)])]\r
+*/\r
+singleOutElems :: ![a] -> [(a,[a])]\r
+\r
+/**    hdtl [a:as] = (a,as)\r
+*/\r
+hdtl :: ![a] -> (a,[a])\r
+\r
+/** isSingleton [_] = True;\r
+       isSingleton  _  = False.\r
+*/\r
+isSingleton :: ![a] -> Bool\r
+\r
+/** filterSt cond xs st\r
+               filters all elements from xs using a state parameter st that is threaded along.\r
+*/\r
+filterSt     :: (a .s -> (Bool,.s)) !.[a] !.s -> (.[a],.s)\r
+\r
+/**    spanfilter cond xs = (filter cond xs, filter (not o cond) xs)\r
+       spanfilterSt cond xs st\r
+               same, but with state parameter st that is threaded along.\r
+*/\r
+spanfilter   :: (a -> Bool) !.[a] -> (.[a],.[a])\r
+spanfilterSt :: (a .s -> (Bool,.s)) !.[a] .s -> (.(.[a],.[a]),.s)\r
+\r
+/**    find1 cond (A ++ [a] ++ B) = a\r
+       where for each x in A: not (cond x) /\ cond a\r
+*/\r
+find1 :: !(a -> Bool) ![a] -> a\r
+\r
+/** break cond (A ++ B ++ C) = (A,B,C)\r
+       where for each x in A: not (cond x)     /\\r
+             for each x in B:     (cond x)     /\\r
+             if C=[x:_]:      not (cond x)\r
+*/\r
+break :: !(a -> Bool) ![a] -> (![a],![a],![a])\r
+\r
+/** break1 cond (A ++ [B] ++ C) = (A,B,C)\r
+       where for each x in A: not (cond x)     /\ \r
+                                  (cond B)     /\ \r
+             if C=[x:_]:      not (cond x)\r
+*/\r
+break1 :: !(a -> Bool) ![a] -> (![a],!a,![a])\r
+\r
+/** unbreak (a,b,c) = a ++ b ++ c\r
+*/\r
+unbreak :: !(![a],![a],![a]) -> [a]\r
+\r
+/** unbreak1 (a,b,c) = a ++ [b] ++ c\r
+*/\r
+unbreak1 :: !(![a],!a,![a]) -> [a]\r
+\r
+/** [a_1..x..a_n] ?? x = i\r
+       where\r
+               a_j <> x for all j<i\r
+               a_j == x for j==i\r
+       \r
+       [a_1..x..a_n] ??? c = i\r
+       where\r
+               not (c a_j) for all j<i\r
+                   (c a_j) for j==i\r
+*/\r
+(??) infixl 9 :: ![a] !a -> Int | == a\r
+(???)infixl 9 :: ![a] !(a -> Bool) -> Int\r
+\r
+/**    weave [a_1..a_n] [b_1..b_m]\r
+               = [a_1,b_1, a_2,b_2, ... ]\r
+*/\r
+weave :: ![a] [a] -> [a]\r
+\r
+/** unweave [a_1,a_2..a_n]\r
+               = ([a_1,a_3..],[a_2,a_4..])\r
+*/\r
+unweave :: ![a] -> ([a],[a])\r
+\r
+/** unweave_n n [a_1..a_n, a_{n+1}..a_{2n} ..]\r
+               = [[a_1,a_{n+1}..],[a_2,a_{n+2}..] ..]\r
+*/\r
+unweave_n :: !Int [a] -> [[a]]\r
+\r
+/** Immediate instances of toString for (,), (,,) and Maybe\r
+*/\r
+instance toString (a,b)     | toString a & toString b\r
+instance toString (a,b,c)   | toString a & toString b & toString c\r
+instance toString (Maybe a) | toString a\r
+\r
+/**    Useful string concatenation function\r
+*/\r
+(<+++) infixl :: !String !a -> String | toString a\r
+(+++>) infixr :: !a !String -> String | toString a\r
+\r
+/** showList  inf   [x_0 ... x_n] = "<x_0><inf>...<inf><x_n>"\r
+       showListF inf f [x_0 ... x_n] = "<f x_0><inf>...<inf><f x_n>"\r
+*/\r
+showList       :: !String                !.[a] -> String | toString a\r
+showListF      :: !String !(a -> String) !.[a] -> String\r
+\r
+/** Association lists a la Haskell.\r
+*/\r
+::     AssocList k v :== [ (!k,v)]\r
+\r
+/** lookup k [...(k,v)...] = Just v\r
+       lookup k _             = Nothing\r
+*/\r
+lookup :: !k !(AssocList k v) -> Maybe v | Eq k\r
+\r
+/** lookup _ k [...(k,v)...] = v\r
+       lookup v k _             = v\r
+*/\r
+lookupd :: v !k !(AssocList k v) -> v | Eq k\r
+\r
+/** keymember k [...(k,v)...] = True\r
+       keymember _ _             = False\r
+*/\r
+keymember :: !k !(AssocList k v) -> Bool | Eq k\r
+\r
+/** addkeyvalue (k,v) [...(k,_)...] = [...(k,v)...]\r
+       addkeyvalue _     assocl        = assocl ++ [(k,v)]\r
+*/\r
+addkeyvalue :: !(!k,v) !(AssocList k v) -> AssocList k v | Eq k\r
+\r
+/** updkeyvalue k f [...(k,v)...] = [...(k,f v)...]\r
+       updkeyvalue _ _ assocl        = assocl\r
+*/\r
+updkeyvalue :: !k !(v -> v) !(AssocList k v) -> AssocList k v | Eq k\r
+\r
+/** deletekeyvalue k [...(k,v)...] = [... ...]\r
+       deletekeyvalue _ assocl        = assocl\r
+*/\r
+deletekeyvalue :: !k !(AssocList k v) -> AssocList k v | Eq k\r
+\r
+/** isAllMember xs ys is true iff all elements of xs are member of ys.\r
+*/\r
+isAllMember :: ![a] [a] -> Bool | Eq a\r
+\r
+/** zipWith f as bs = [f a_0 b_0, f a_1 b_1, ..., f a_n b_n]\r
+*/\r
+zipWith :: (a b -> c) ![a] ![b] -> [c]\r
+\r
+/** setbetween x low up\r
+               returns x   iff low <= x <= up\r
+               returns low iff low > x\r
+               returns up  iff x > up\r
+*/\r
+setbetween :: !a !a !a -> a | Ord a\r
+\r
+/** isbetween x low up\r
+               returns True iff low <= x <= up\r
+*/\r
+isbetween :: !a !a !a -> Bool | Ord a\r
+\r
+/** minmax (a,b) = (a,b) if a<=b; (b,a) otherwise\r
+*/\r
+minmax :: !(!a,!a) -> (!a,!a) | Ord a\r
+\r
+/** swap (a,b) = (b,a)\r
+*/\r
+swap :: !(.a,.b) -> (.b,.a)\r
+\r
+/** modulo Int\r
+*/\r
+instance mod Int\r
+\r
+/**    foldl1 f xs folds f to the left over non-empty list xs.\r
+*/\r
+foldl1 :: !(a -> a -> a) ![a] -> a\r
+\r
+/** foldr1 f xs folds f to the right over non-empty list xs.\r
+*/\r
+foldr1 :: !(a -> a -> a) ![a] -> a\r
+\r
+/*     removeQuotes str removes all quotes and slashes from str.\r
+*/\r
+removeQuotes :: !{#Char} -> String\r
+\r
+/** stringStarts str prefix yields true iff str = prefix +++ s for some s.\r
+*/\r
+stringStarts :: !String !String -> Bool\r
+\r
+/** removePrefix str prefix yields (Just s) iff str = prefix +++ s, and Nothing otherwise.\r
+*/\r
+removePrefix :: !String !String -> Maybe String\r
+\r
+replaceInString :: !String !String !String -> String\r
+\r
+/** other a yields the only other value of a domain that consists of two values.\r
+*/\r
+class other a :: !a -> a\r
+\r
+/** isSorted [x_0..x_n] holds iff x_i <= x_{i+1} for each x_i in [x_0..x_{n-1}].\r
+*/\r
+isSorted :: ![a] -> Bool | Ord a\r
+\r
+/** perhaps p Nothing = False, and perhaps p (Just a) = p a\r
+*/\r
+perhaps :: !(a -> Bool) !(Maybe a) -> Bool\r
+\r
+/**    instance ~ Bool = not\r
+*/\r
+instance ~ Bool\r
+\r
+/** instance fromString Int = toInt\r
+*/\r
+instance fromString Int\r
+\r
+/** better class definitions of the trigonometry functions:\r
+*/\r
+class sinus      a :: !a -> Real\r
+class cosinus    a :: !a -> Real\r
+class tangens    a :: !a -> Real\r
+class arcsinus   a :: !Real -> a\r
+class arccosinus a :: !Real -> a\r
+class arctangens a :: !Real -> a\r
+\r
+instance sinus      Real\r
+instance cosinus    Real\r
+instance tangens    Real\r
+instance arcsinus   Real\r
+instance arccosinus Real\r
+instance arctangens Real\r
diff --git a/src/StdLibExt/StdEnvExt.icl b/src/StdLibExt/StdEnvExt.icl
new file mode 100644 (file)
index 0000000..140a6ef
--- /dev/null
@@ -0,0 +1,451 @@
+implementation module StdEnvExt\r
+\r
+/** Collection of functions of more general purpose.\r
+*/\r
+import StdEnv\r
+import StdMaybe\r
+\r
+/** const2 a _ _ = a\r
+               is a frequently occurring version of the const function.\r
+*/\r
+const2 :: !.a .b .c -> .a\r
+const2 a _ _ = a\r
+\r
+/**    iterateSt f x\r
+               is the state based version of iterate (StdList):\r
+       iterateSt f x_0\r
+               [y_1,y_2,y_3,y_4...]\r
+       where\r
+               (y_i,x_i) = f x_{i-1}\r
+*/\r
+iterateSt :: !(s -> (a,s)) !s -> [a]\r
+iterateSt f s = let (a,s1) = f s in [a:iterateSt f s1]\r
+\r
+/** iterateStn n f x\r
+               is the finite version of iterateSt.\r
+*/\r
+iterateStn :: !Int !(s -> (a,s)) !s -> (![a],!s)\r
+iterateStn 0 _ s       = ([],s)\r
+iterateStn n f s\r
+       # (a, s)                = f s\r
+       # (as,s)                = iterateStn (n-1) f s\r
+       = ([a:as],s)\r
+\r
+/** State strict version of seq:\r
+*/\r
+sseq :: ![.(.s -> .s)] !.s -> .s\r
+sseq [f:fs] s = sseq fs (f s)\r
+sseq []     s = s\r
+\r
+\r
+/** State strict version of seqList:\r
+*/\r
+sseqList:: ![St .s .a] !.s -> (![.a],!.s)\r
+sseqList [f:fs] s\r
+       #! (x, s) = f s\r
+       #! (xs,s) = sseqList fs s\r
+       =  ([x:xs],s)\r
+sseqList _ s\r
+       = ([],s)\r
+\r
+/** apply x [f_0 ... f_n] = [f_0 x, ..., f_n x]\r
+*/\r
+apply :: a ![a->.b] -> [.b]\r
+apply x fs     = [f x \\ f<-fs]\r
+\r
+/**    State passing version of map:\r
+*/\r
+mapSt :: !(.(.a,.s) -> .(.b,.s)) !(![.a],.s) -> (![.b],.s)\r
+mapSt f ([],s)\r
+       = ([],s)\r
+mapSt f ([a:as],s)\r
+       # (b, s)        = f (a,s)\r
+       # (bs,s)        = mapSt f (as,s)\r
+       = ([b:bs],s)\r
+\r
+/**    Strict state passing version of map:\r
+*/\r
+smapSt :: !(.(.a,.s) -> .(.b,.s)) !(![.a],!.s) -> (![.b],!.s)\r
+smapSt f ([],s)\r
+       = ([],s)\r
+smapSt f ([a:as],s)\r
+       #! (b, s)       = f (a,s)\r
+       #! (bs,s)       = smapSt f (as,s)\r
+       = ([b:bs],s)\r
+\r
+/**    singleOutElems [a_1..a_n] = [(a_1,[a_2..a_n]),(a_2,[a_1,a_3..a_n])..(a_n,[a_1..a_{n-1}])]\r
+*/\r
+singleOutElems :: ![a] -> [(a,[a])]\r
+singleOutElems as\r
+       = singleOut [] as\r
+where\r
+       singleOut :: [a] [a] -> [(a,[a])]\r
+       singleOut _ [] = []\r
+       singleOut prefix [a:as]\r
+               = [(a,prefix++as) : singleOut (prefix++[a]) as]\r
+\r
+/**    hdtl [a:as] = (a,as)\r
+*/\r
+hdtl :: ![a] -> (a,[a])\r
+hdtl [a:as] = (a,as)\r
+\r
+/** isSingleton [_] = True;\r
+       isSingleton  _  = False.\r
+*/\r
+isSingleton :: ![a] -> Bool\r
+isSingleton [_]                = True\r
+isSingleton  _         = False\r
+\r
+\r
+/** filterSt cond xs st\r
+               filters all elements from xs using a state parameter st that is threaded along.\r
+*/\r
+filterSt     :: (a .s -> (Bool,.s)) !.[a] !.s -> (.[a],.s)\r
+filterSt cond [] s\r
+       = ([],s)\r
+filterSt cond [x:xs] s\r
+# (b,  s)              = cond x s\r
+# (yes,s)              = filterSt cond xs s\r
+| b                            = ([x:yes],s)\r
+| otherwise            = (   yes, s)\r
+\r
+/**    spanfilter cond xs = (filter cond xs, filter (not o cond) xs)\r
+*/\r
+spanfilter :: (a -> Bool) !.[a] -> (.[a],.[a])\r
+spanfilter cond []\r
+       = ([],[])\r
+spanfilter cond [x:xs]\r
+       | cond x        = ([x:yes],no)\r
+       | otherwise     = (yes,[x:no])\r
+where\r
+       (yes,no)        = spanfilter cond xs\r
+\r
+spanfilterSt :: (a .s -> (Bool,.s)) !.[a] .s -> (.(.[a],.[a]),.s)\r
+spanfilterSt cond [] s\r
+       = (([],[]),s)\r
+spanfilterSt cond [x:xs] s\r
+       # (ok,s)                = cond x s\r
+       # ((yes,no),s)  = spanfilterSt cond xs s\r
+       | ok                    = (([x:yes],no),s)\r
+       | otherwise             = ((yes,[x:no]),s)\r
+\r
+/**    find1 cond (A ++ [a] ++ B) = a\r
+       where for each x in A: not (cond x) /\ cond a\r
+*/\r
+find1 :: !(a -> Bool) ![a] -> a\r
+find1 c as                     = case filter c as of\r
+                                               [a:_]   = a\r
+                                               none    = abort "find1: no elements found.\n"\r
+\r
+/** break cond (A ++ B ++ C) = (A,B,C)\r
+       where for each x in A: not cond x     /\\r
+             for each x in B:     cond x     /\\r
+             if C=[x:_]:      not cond x\r
+*/\r
+break :: !(a -> Bool) ![a] -> (![a],![a],![a])\r
+break c xs\r
+       # (no,yes)      = span (not o c) xs\r
+       # (yes,no`)     = span c yes\r
+       = (no,yes,no`)\r
+\r
+/** break1 cond (A ++ [B] ++ C) = (A,B,C)\r
+       where for each x in A: not cond x     /\ \r
+                                  cond B     /\ \r
+             if C=[x:_]:      not cond x\r
+*/\r
+break1 :: !(a -> Bool) ![a] -> (![a],!a,![a])\r
+break1 c xs\r
+       = case break c xs of\r
+               (a,[b],c)       = (a,b,c)\r
+               (a,b,c)         = abort ("break1: [B] is of length: " <+++ length b <+++ "\n")\r
+\r
+/** unbreak (a,b,c) = a ++ b ++ c\r
+*/\r
+unbreak :: !(![a],![a],![a]) -> [a]\r
+unbreak (a,b,c) = a ++ b ++ c\r
+\r
+\r
+/** unbreak1 (a,b,c) = a ++ [b] ++ c\r
+*/\r
+unbreak1 :: !(![a],!a,![a]) -> [a]\r
+unbreak1 (a,b,c) = a ++ [b] ++ c\r
+\r
+/** [a_1..x..a_n] x = i\r
+       where\r
+               a_j <> x for all j<i\r
+               a_j == x for j==i\r
+*/\r
+(??) infixl 9 :: ![a] !a -> Int | == a\r
+(??) ys x = search ((==) x) ys 0\r
+\r
+(???) infixl 9 :: ![a] !(a -> Bool) -> Int\r
+(???) ys c = search c ys 0\r
+\r
+search :: !(a -> Bool) ![a] !Int -> Int\r
+search _ [] _  = -1\r
+search c [y:ys] i\r
+       | c y           = i\r
+       | otherwise     = search c ys (i+1)\r
+\r
+/**    weave [a_1..a_n] [b_1..b_m]\r
+               = [a_1,b_1, a_2,b_2, ... a_k,b_k] with k = min(m,n)\r
+*/\r
+weave :: ![a] [a] -> [a]\r
+weave [a:as] [b:bs] = [a,b:weave as bs]\r
+weave _      _         = []\r
+\r
+/** unweave [a_1,a_2..a_n]\r
+               = ([a_1,a_3..],[a_2,a_4..])\r
+*/\r
+unweave :: ![a] -> ([a],[a])\r
+unweave [x,y:zs]       = ([x:xs],[y:ys])\r
+where\r
+       (xs,ys)                 = unweave zs\r
+unweave [x]                    = ([x],[])\r
+unweave []                     = ([],[])\r
+\r
+/** unweave_n n [a_1..a_n, a_{n+1}..a_{2n} ..]\r
+               = [[a_1,a_{n+1}..],[a_2,a_{n+2}..] ..]\r
+*/\r
+unweave_n :: !Int [a] -> [[a]]\r
+unweave_n nrLists zs \r
+       | length first_n < nrLists\r
+               = repeatn nrLists []\r
+       | otherwise\r
+               = glue first_n (unweave_n nrLists after_n)\r
+where\r
+       (first_n,after_n)       = splitAt nrLists zs\r
+       \r
+       glue :: ![a] [[a]] -> [[a]]             // must be non-strict in its second argument in order to work for streams\r
+       glue []     _   = []\r
+       glue [a:as] xss = [[a:hd xss]:glue as (tl xss)]\r
+\r
+\r
+/** Immediate instances of toString for (,) and (,,)\r
+*/\r
+instance toString (a,b)     | toString a & toString b              where toString (a,b)    = "(" <+++ a <+++ "," <+++ b <+++ ")"\r
+instance toString (a,b,c)   | toString a & toString b & toString c where toString (a,b,c)  = "(" <+++ a <+++ "," <+++ b <+++ "," <+++ c <+++ ")"\r
+instance toString (Maybe a) | toString a                           where toString (Just a) = "(Just " <+++ a <+++ ")"\r
+                                                                         toString nothing  = "Nothing"\r
+\r
+/**    Useful string concatenation function\r
+*/\r
+(<+++) infixl :: !String !a -> String | toString a\r
+(<+++) str x = str +++ toString x\r
+\r
+(+++>) infixr :: !a !String -> String | toString a\r
+(+++>) x str = toString x +++ str\r
+\r
+\r
+/** showList  inf   [x_0 ... x_n] = "<x_0><inf>...<inf><x_n>"\r
+       showListF inf f [x_0 ... x_n] = "<f x_0><inf>...<inf><f x_n>"\r
+*/\r
+showList :: !String !.[a] -> String | toString a\r
+showList inf []                        = ""\r
+showList inf [x]               = toString x\r
+showList inf [x:xs]            = x +++> inf +++> showList inf xs\r
+\r
+showListF :: !String !(a -> String) !.[a] -> String\r
+showListF inf f []             = ""\r
+showListF inf f [x]            = f x\r
+showListF inf f [x:xs] = f x +++> inf +++> showListF inf f xs\r
+\r
+\r
+/** lookup k [...(k,v)...] = Just v\r
+       lookup k _             = Nothing\r
+*/\r
+lookup :: !k !(AssocList k v) -> Maybe v | Eq k\r
+lookup k assocl\r
+       = case [v \\ (k`,v)<-assocl | k==k`] of\r
+               [v:_]   = Just v\r
+               _               = Nothing\r
+\r
+/** lookup _ k [...(k,v)...] = v\r
+       lookup v k _             = v\r
+*/\r
+lookupd :: v !k !(AssocList k v) -> v | Eq k\r
+lookupd v k assocl\r
+       = case [v` \\ (k`,v`)<-assocl | k==k`] of\r
+               [v`:_]  = v`\r
+               _               = v\r
+\r
+/** keymember k [...(k,v)...] = True\r
+       keymember _ _             = False\r
+*/\r
+keymember :: !k !(AssocList k v) -> Bool | Eq k\r
+keymember k assocl\r
+       = isJust (lookup k assocl)\r
+\r
+/** addkeyvalue (k,v) [...(k,_)...] = [...(k,v)...]\r
+       addkeyvalue _     assocl        = assocl ++ [(k,v)]\r
+*/\r
+addkeyvalue :: !(!k,v) !(AssocList k v) -> AssocList k v | Eq k\r
+addkeyvalue (k,v) assocl\r
+       = case span (\(k`,_) -> k<>k`) assocl of\r
+               (before,[_:after])      = before ++ [(k,v):after]\r
+               (before,empty)          = before ++ [(k,v)]\r
+\r
+/** updkeyvalue k f [...(k,v)...] = [...(k,f v)...]\r
+       updkeyvalue _ _ assocl        = assocl\r
+*/\r
+updkeyvalue :: !k !(v -> v) !(AssocList k v) -> AssocList k v | Eq k\r
+updkeyvalue k f assocl\r
+       = case span (\(k`,_) -> k<>k`) assocl of\r
+               (before,[(k,v):after])  = before ++ [(k,f v):after]\r
+               (before,empty)                  = before\r
+\r
+/** deletekeyvalue k [...(k,v)...] = [... ...]\r
+       deletekeyvalue _ assocl        = assocl\r
+*/\r
+deletekeyvalue :: !k !(AssocList k v) -> AssocList k v | Eq k\r
+deletekeyvalue k assocl\r
+       = case span (\(k`,_) -> k<>k`) assocl of\r
+               (before,[_:after])              = before ++ after\r
+               (before,empty)                  = before\r
+\r
+/** isAllMember xs ys is true iff all elements of xs are member of ys.\r
+*/\r
+isAllMember :: ![a] [a] -> Bool | Eq a\r
+isAllMember xs ys = and (map (\x -> isMember x ys) xs)\r
+\r
+/** zipWith f as bs = [f a_0 b_0, f a_1 b_1, ..., f a_n b_n]\r
+*/\r
+zipWith :: (a b -> c) ![a] ![b] -> [c]\r
+zipWith f as bs = [f a b \\ a<-as & b<-bs]\r
+\r
+/** setbetween x low up\r
+               returns x   iff low <= x <= up\r
+               returns low iff low > x\r
+               returns up  iff x > up\r
+*/\r
+setbetween :: !a !a !a -> a | Ord a\r
+setbetween x low up\r
+       | low > x       = low\r
+       | x > up        = up\r
+       | otherwise     = x\r
+\r
+/** isbetween x low up\r
+               returns True iff low <= x <= up\r
+*/\r
+isbetween :: !a !a !a -> Bool | Ord a\r
+isbetween x low up\r
+       = low <= x && x <= up\r
+\r
+/** minmax (a,b) = (a,b) if a<=b; (b,a) otherwise\r
+*/\r
+minmax :: !(!a,!a) -> (!a,!a) | Ord a\r
+minmax (a,b)\r
+       | a<=b          = (a,b)\r
+       | otherwise     = (b,a)\r
+\r
+\r
+/** swap (a,b) = (b,a)\r
+*/\r
+swap :: !(.a,.b) -> (.b,.a)\r
+swap (a,b) = (b,a)\r
+\r
+/** modulo int\r
+*/\r
+instance mod Int where\r
+       (mod) a b       = a - b * (a/b)\r
+\r
+/**    foldl1 f xs folds f to the left over non-empty list xs.\r
+*/\r
+foldl1 :: !(a -> a -> a) ![a] -> a\r
+foldl1 f [x : xs]      = foldl f x xs\r
+\r
+/** foldr1 f xs folds f to the right over non-empty list xs.\r
+*/\r
+foldr1 :: !(a -> a -> a) ![a] -> a\r
+foldr1 f [x]   = x\r
+foldr1 f [x:xs]        = f x (foldr1 f xs)\r
+               \r
+removeQuotes :: !{#Char} -> String\r
+removeQuotes "" = ""\r
+removeQuotes s = removeQuotes` s 0\r
+where\r
+       removeQuotes` :: !{#Char} Int -> String\r
+       removeQuotes` s i       \r
+               | i == size s\r
+                       = ""\r
+               | otherwise\r
+                       # c = select s i\r
+                       | c == '\"' || c == '\\'\r
+                               = removeQuotes` s (inc i)\r
+                       | otherwise\r
+                               = toString c +++ removeQuotes` s (inc i)\r
+                               \r
+replaceInString :: !String !String !String -> String\r
+replaceInString toReplace replacement s  \r
+       # result = replaceInString` (fromString toReplace) (fromString replacement) (fromString s)\r
+       = charlist2string "" result\r
+where\r
+       replaceInString` :: ![Char] ![Char] ![Char] -> [Char]\r
+       replaceInString` toReplace replacement []       = []\r
+       replaceInString` toReplace replacement s=:[x:xs]        \r
+               | length toReplace > length s   = s\r
+               # firstPart = take (length toReplace) s\r
+               # lastPart = drop (length toReplace) s\r
+               | firstPart == toReplace        = replacement ++ replaceInString` toReplace replacement lastPart\r
+               | otherwise                                     = [x:replaceInString` toReplace replacement xs]\r
+       \r
+       charlist2string :: !String ![Char] -> String\r
+       charlist2string str []  = str\r
+       charlist2string str [x:xs]      = charlist2string (str+++toString x) xs\r
+\r
+/** stringStarts s1 prefix yields true iff s1 = prefix +++ s for some s.\r
+*/\r
+stringStarts :: !String !String -> Bool\r
+stringStarts s1 prefix = size s1 >= size prefix && s1%(0,size prefix-1) == prefix\r
+\r
+/** removePrefix str prefix yields (Just s) iff str = prefix +++ s, and Nothing otherwise.\r
+*/\r
+removePrefix :: !String !String -> Maybe String\r
+removePrefix s1 prefix = if (stringStarts s1 prefix) (Just (s1%(size prefix,size s1-1))) Nothing\r
+\r
+/** isSorted [x_0..x_n] holds iff x_i <= x_{i+1} for each x_i in [x_0..x_{n-1}].\r
+*/\r
+isSorted :: ![a] -> Bool | Ord a\r
+isSorted []                            = True\r
+isSorted xs                            = and [x <= y \\ x <- xs & y <- tl xs]\r
+\r
+/** perhaps p Nothing = False, and perhaps p (Just a) = p a\r
+*/\r
+perhaps :: !(a -> Bool) !(Maybe a) -> Bool\r
+perhaps _ Nothing              = False\r
+perhaps p (Just a)             = p a\r
+\r
+/** instance ~ Bool is not\r
+*/\r
+instance ~ Bool where (~) b            = not b\r
+\r
+/** instance fromString Int = toInt\r
+*/\r
+instance fromString Int where fromString str = toInt str\r
+\r
+/**    test and access functions for choice values:\r
+*/\r
+::     ThisOrThat a b  = This a | That b\r
+\r
+isThis :: !(ThisOrThat a b) -> Bool\r
+isThis (This _)                = True\r
+isThis _                       = False\r
+\r
+isThat :: !(ThisOrThat a b) -> Bool\r
+isThat (That _)                = True\r
+isThat _                       = False\r
+\r
+this :: !(ThisOrThat a b) -> a\r
+this (This a)          = a\r
+this _                         = abort "this [StdEnvExt]: applied to That pattern instead of This pattern."\r
+\r
+that :: !(ThisOrThat a b) -> b\r
+that (That b)          = b\r
+that _                         = abort "that [StdEnvExt]: applied to This pattern instead of That pattern."\r
+\r
+instance sinus      Real where sinus      x = sin  x\r
+instance cosinus    Real where cosinus    x = cos  x\r
+instance tangens    Real where tangens    x = tan  x\r
+instance arcsinus   Real where arcsinus   a = asin a\r
+instance arccosinus Real where arccosinus a = acos a\r
+instance arctangens Real where arctangens a = atan a\r
diff --git a/src/StdLibExt/StdIOExt.dcl b/src/StdLibExt/StdIOExt.dcl
new file mode 100644 (file)
index 0000000..18c3964
--- /dev/null
@@ -0,0 +1,12 @@
+definition module StdIOExt\r
+\r
+/**    Collection of functions that extend functionality of StdIO.\r
+*/\r
+\r
+import StdIO\r
+\r
+/** makeSound path ioSt\r
+               plays a sound file, located at path. If no such file is found, the function\r
+               aborts.\r
+*/\r
+makeSound :: !String -> (IOSt .ps) -> IOSt .ps\r
diff --git a/src/StdLibExt/StdIOExt.icl b/src/StdLibExt/StdIOExt.icl
new file mode 100644 (file)
index 0000000..a02ff5b
--- /dev/null
@@ -0,0 +1,21 @@
+implementation module StdIOExt\r
+\r
+/**    Collection of functions that extend functionality of StdIO.\r
+*/\r
+import StdEnv\r
+import StdIO\r
+import clCCall_12\r
+from   iostate import appIOToolbox\r
+\r
+/** makeSound path ioSt\r
+               plays a sound file, located at path. If no such file is found, the function\r
+               aborts.\r
+*/\r
+makeSound :: !String -> (IOSt .l) -> IOSt .l\r
+makeSound file         = appIOToolbox (osSound file)\r
+where\r
+       osSound :: !String !*OSToolbox -> *OSToolbox\r
+       osSound file tb\r
+               # (ok,tb)       = winPlaySound file tb\r
+               | ok            = tb\r
+               | otherwise     = abort ("makeSound: unable to play sound file" +++ file +++ ".\n")\r
diff --git a/src/StdLibExt/fileIO.dcl b/src/StdLibExt/fileIO.dcl
new file mode 100644 (file)
index 0000000..8080102
--- /dev/null
@@ -0,0 +1,26 @@
+definition module fileIO
+
+/**    Collection of functions that extend functionality of StdFile.
+*/
+
+import StdBitmap
+
+/** getImage path env
+               expects a bitmap file at path. If this is not the case, the function
+               aborts. Otherwise, it returns the bitmap.
+*/
+getImage :: !String !*env -> (!Bitmap,!*env) | FileSystem env
+
+/** writeFile appendData path content env
+               writes content to a currently closed file, located at path, and closes it again.
+               It appends content to current content in case of appendData, and replaces content otherwise.
+               The function aborts in case of incorrect path and failing to close the file.
+*/
+writeFile :: !Bool !String !String !*env -> *env | FileSystem env
+
+/** readFile path env
+               reads the current content of the file located at path as a text file and closes it.
+               The function yields Nothing in case of incorrect path and failing to close the file
+               and (Just content) otherwise.
+*/
+readFile :: !String !*env -> (!Maybe String,*env) | FileSystem env
diff --git a/src/StdLibExt/fileIO.icl b/src/StdLibExt/fileIO.icl
new file mode 100644 (file)
index 0000000..ec80297
--- /dev/null
@@ -0,0 +1,32 @@
+implementation module fileIO
+
+import StdEnvExt
+import StdBitmap
+
+getImage                               :: !String !*env -> (!Bitmap,!*env) | FileSystem env
+getImage path env
+       = case openBitmap path env of
+               (Nothing,_)             = abort ("getImage: unable to get Image " <+++ path <+++".\n")
+               (Just bm,env)   = (bm,env)
+
+writeFile                              :: !Bool !String !String !*env -> *env | FileSystem env
+writeFile append path text env
+# (open,outputFile,env)        = fopen path (if append FAppendText FWriteText) env
+| not open                             = abort ("writeFile: could not open " <+++ path <+++ ".\n")
+# (close, env)                 = fclose (outputFile <<< text) env
+| not close                            = abort ("writeFile: could not close " <+++ path <+++".\n")
+| otherwise                            = env
+
+readFile                               :: !String !*env -> (!Maybe String,*env) | FileSystem env
+readFile path env
+# (open,inputFile,env) = fopen path FReadText env
+| not open                             = (Nothing,snd (fclose inputFile env))
+# (ok,inputFile)               = fseek inputFile 0 FSeekEnd
+| not ok                               = (Nothing,snd (fclose inputFile env))
+# (pos,inputFile)              = fposition inputFile
+# (ok,inputFile)               = fseek inputFile 0 FSeekSet
+| not ok                               = (Nothing,snd (fclose inputFile env))
+# (str,inputFile)              = freads inputFile pos
+# (ok,env)                             = fclose inputFile env
+| not ok                               = (Nothing, env)
+| otherwise                            = (Just str,env)
diff --git a/src/StdReferee/RefereeCoach_DeepPass_Assignment.dcl b/src/StdReferee/RefereeCoach_DeepPass_Assignment.dcl
new file mode 100644 (file)
index 0000000..ac0f508
--- /dev/null
@@ -0,0 +1,16 @@
+definition module RefereeCoach_DeepPass_Assignment\r
+\r
+/** This module implements a referee coach for a ball passing assignment.\r
+       Two footballers from the student team are separated by a group of opponents who are crossing\r
+       the field in north-south direction. The player at one side is in possession of the ball.\r
+       He needs to pass the ball to the other player in such a way that it can not be gained by\r
+       an opponent. \r
+       \r
+       The opponent team should be Team_Opponent_DeepPass_Assignment.\r
+       \r
+       Developed by Wanja Krah.\r
+*/\r
+\r
+import Referee\r
+\r
+RefereeCoach_DeepPass :: !FootballField -> Referee\r
diff --git a/src/StdReferee/RefereeCoach_DeepPass_Assignment.icl b/src/StdReferee/RefereeCoach_DeepPass_Assignment.icl
new file mode 100644 (file)
index 0000000..4fcf839
--- /dev/null
@@ -0,0 +1,87 @@
+implementation module RefereeCoach_DeepPass_Assignment\r
+\r
+import StdEnvExt\r
+import Referee\r
+import Team_Opponent_DeepPass_Assignment\r
+\r
+RefereeCoach_DeepPass :: !FootballField -> Referee\r
+RefereeCoach_DeepPass field    = { name  = "RefereeCoach DeepPass"\r
+                                                         , brain = { memory = initMem\r
+                                                                   , ai     = randomlessRefereeAI (brain field)\r
+                                                                   }\r
+                                                         , refActionPics    = []\r
+                                                         }\r
+\r
+::     Memory = { first                        :: !Bool\r
+                        , practiceFailed       :: !Bool\r
+                        , gameOver                     :: !Bool\r
+                        , ballKicked           :: !Bool\r
+                        , ballGained           :: !Bool\r
+                        , positions            :: !(!Position,!Position)\r
+                        }\r
+\r
+initMem :: Memory\r
+initMem   = { first                            = True\r
+                       , practiceFailed        = False\r
+                       , gameOver                      = False\r
+                       , ballKicked            = False\r
+                       , ballGained            = False\r
+                       , positions                     = (zero,zero)\r
+                       }\r
+\r
+brain :: !FootballField !(!RefereeInput,!Memory) -> (!RefereeOutput,!Memory)\r
+brain field ({RefereeInput | theBall=ballState,team1,team2},memory)\r
+| memory.gameOver                                                                                                                                      // game over because of succes or failure\r
+       = ([GameOver],memory)\r
+| memory.practiceFailed                                                                                                                                // assignment has failed\r
+       = ([TellMessage "Assignment failed, correct your team and try again."],stop memory)\r
+| length (filter isFielder studentTeam) <> 2                                                                           // check if there are indeed two fielders in the students team\r
+       = ([TellMessage "There should be two fielders in student team."],stop memory)\r
+# (refActions,memory)                                          = if memory.first                                               // when first, alter ball pos and remember all positions\r
+                                                                                            ([DirectFreeKick studentHome ballKickoff],{updateAllPos memory & first = False})\r
+                                                                                            ([],memory)\r
+# playersMovedToFar                                                    = getPlayersThatMovedTooFar memory\r
+| not (isEmpty playersMovedToFar)                                                                                                      // check if players did not move more than 10 meters from their starting positions\r
+       = (refActions ++ getMessagesForTooFarPlayers playersMovedToFar,fail memory)\r
+| ballGainedByComputer\r
+       = (refActions ++ [TellMessage ("Computer gained the ball")],fail memory)\r
+| not memory.ballKicked\r
+       | perhaps isKickedBall kickerAction             = (refActions,kick memory)\r
+       | perhaps isTackled    kickerAction             = (refActions ++ [TackleDetected kickerID, ReprimandPlayer kickerID RedCard],fail memory)\r
+       | perhaps isTackled    gainerAction             = (refActions ++ [TackleDetected gainerID, ReprimandPlayer gainerID RedCard],fail memory)\r
+       | otherwise                                                             = (refActions,memory)\r
+| not memory.ballGained\r
+       | perhaps isTackled    kickerAction             = (refActions ++ [TackleDetected kickerID, ReprimandPlayer kickerID RedCard],fail memory)\r
+       | perhaps isTackled    gainerAction             = (refActions ++ [TackleDetected gainerID, ReprimandPlayer gainerID RedCard],fail memory)\r
+       | perhaps isGainedBall gainerAction             = (refActions ++ [TellMessage "Well Done! Move on to the next assignment!"], stop memory)\r
+       | otherwise                                                             = (refActions,memory)\r
+| otherwise\r
+       = (refActions,memory)\r
+where\r
+       (compTeam,studentTeam,studentHome)              = if (stringStarts (nameOf team1) base_TeamName_Opponent_DeepPass) (team1,team2,East) (team2,team1,West)\r
+       (kicker,  gainer)                                               = let fielders = filter isFielder studentTeam in (fielders!!0,fielders!!1)\r
+       (kickerID,gainerID)                                             = (kicker.playerID,gainer.playerID)\r
+       kickerAction                                                    = getAction kickerID\r
+       gainerAction                                                    = getAction gainerID\r
+       ballKickoff                                                             = if (studentHome == West)\r
+                                                                                            {py=scale -0.05 field.fwidth, px=scale  0.06 field.flength}\r
+                                                                                            {py=scale  0.05 field.fwidth, px=scale -0.06 field.flength}\r
+       ballGainedByComputer                                    = any (\fb -> ballIsGainedBy fb.playerID ballState) compTeam\r
+       \r
+       fail memory                                                             = {memory & practiceFailed = True}\r
+       stop memory                                                             = {memory & gameOver       = True}\r
+       kick memory                                                             = {memory & ballKicked     = True}\r
+\r
+       getAction :: !FootballerID -> Maybe FootballerEffect\r
+       getAction playerID                                              = case [fb.effect \\ fb <- team1 ++ team2 | identify_player playerID fb] of\r
+                                                                                               [effect:_]      = effect\r
+                                                                                               _                       = Nothing\r
+                       \r
+       updateAllPos :: !Memory -> Memory\r
+       updateAllPos memory                                             = {memory & positions = (kicker.pos,gainer.pos)}\r
+       \r
+       getPlayersThatMovedTooFar :: !Memory -> [Footballer]\r
+       getPlayersThatMovedTooFar {positions=(kicker_pos,gainer_pos)}\r
+                                                                                       = [fb \\ (fb,pos) <- [(kicker,kicker_pos),(gainer,gainer_pos)] | dist fb pos > m 10.0]\r
+               \r
+       getMessagesForTooFarPlayers                             = map (\fb -> TellMessage ("Your player with number " <+++ fb.playerID.playerNr <+++ " moved further than 10 meters"))\r
diff --git a/src/StdReferee/RefereeCoach_Keeper_Assignment.dcl b/src/StdReferee/RefereeCoach_Keeper_Assignment.dcl
new file mode 100644 (file)
index 0000000..91572ba
--- /dev/null
@@ -0,0 +1,13 @@
+definition module RefereeCoach_Keeper_Assignment\r
+\r
+/** This module implements a referee coach for a keeper assignment.\r
+       The student team consists of a single keeper. He is challenged by TeamOpponent_Keeper_Assignment\r
+       which consists of a number of footballers who are passing the ball to each other in an attempt\r
+       to have the keeper not cover the center of the goal.\r
+       \r
+       Developed by Wanja Krah.\r
+*/\r
+\r
+import Referee\r
+\r
+RefereeCoach_Keeper :: !FootballField -> Referee\r
diff --git a/src/StdReferee/RefereeCoach_Keeper_Assignment.icl b/src/StdReferee/RefereeCoach_Keeper_Assignment.icl
new file mode 100644 (file)
index 0000000..f1e5e77
--- /dev/null
@@ -0,0 +1,122 @@
+implementation module RefereeCoach_Keeper_Assignment\r
+\r
+import StdEnvExt\r
+import Referee\r
+import Team_Opponent_Keeper_Assignment\r
+import Team_Student_Keeper_Assignment\r
+\r
+RefereeCoach_Keeper :: !FootballField -> Referee\r
+RefereeCoach_Keeper field      = { name  = "RefereeCoach Keeper"\r
+                                                         , brain = { memory = initMem\r
+                                                                               , ai     = randomlessRefereeAI (brain field)\r
+                                                                               }\r
+                                                         , refActionPics    = []\r
+                                                         }\r
+\r
+::     Memory                                  = { first                       :: !Bool\r
+                                                         , practiceFailed      :: !Bool\r
+                                                         , gameOver            :: !Bool\r
+                                                         , showHowExit         :: !Maybe Exit\r
+                                                         , timesGainedBy5      :: !Int\r
+                                                         , practiceSucceed     :: !Bool\r
+                                                         }\r
+::     Exit                                    = { student                     :: !Team\r
+                                                         , computer            :: !Team\r
+                                                         , ball                        :: !Position\r
+                                                         , exit                        :: !Position\r
+                                                         }\r
+\r
+initMem                                                :: Memory\r
+initMem                                                = { first                       = True\r
+                                                         , practiceFailed      = False\r
+                                                         , gameOver            = False\r
+                                                         , showHowExit         = Nothing\r
+                                                         , timesGainedBy5      = 0\r
+                                                         , practiceSucceed     = False\r
+                                                         }\r
+\r
+brain :: !FootballField !(!RefereeInput,!Memory) -> (!RefereeOutput,!Memory)\r
+brain field ({RefereeInput | playingTime=time,theBall=ballState,team1,team2},memory)\r
+| memory.gameOver                                                                                              // game over because of succes or failure\r
+       = ([GameOver],memory)\r
+| memory.practiceFailed && memory.practiceSucceed                              // assignment failed but you had already succeeded\r
+       = ([TellMessage "Failed, but you had already passed the test", DirectFreeKick studentHome ballKickoff],{memory & practiceFailed = False, showHowExit = Nothing})\r
+| memory.practiceFailed                                                                                        // assignment failed\r
+       = ([TellMessage "Assignment failed, correct your team and try again"],{memory & gameOver = True})\r
+| isEmpty (filter isKeeper studentTeam)                                                        // check if there is a keeper\r
+       = ([TellMessage ("No keeper in student team, please choose " <+++ base_TeamName_Student_Keeper)],{memory & gameOver = True})\r
+# (refActions,memory)          = if (time <= minutes 0.5 && not memory.practiceSucceed)\r
+                                                            ([TellMessage "Well Done! (but let's see how much longer you can gain control...)"], {memory & practiceSucceed=True})\r
+                                                        ([],memory)\r
+# (refActions,memory)          = if memory.first                                       // when this is the first round, reposition the ball\r
+                                                            (refActions ++ [DirectFreeKick studentHome ballKickoff],{memory & first = False})\r
+                                                            (refActions,memory)\r
+| isJust memory.showHowExit                                                                            // The ball could pass, show how the ball could pass the keeper\r
+       # exitInfo                              = fromJust memory.showHowExit\r
+       # directionToExit               = bearing zero exitInfo.ball exitInfo.exit      // move the ball towards exit\r
+       # nextBallPos                   = move_point {dx = m (cosinus directionToExit), dy = m (sinus directionToExit)} exitInfo.ball\r
+       | studentHome == West && nextBallPos.px < scale -0.5 field.flength || studentHome == East && nextBallPos.px > scale 0.5 field.flength\r
+                                                       = ([],{memory & practiceFailed = True})\r
+       | otherwise                             = ([DirectFreeKick West nextBallPos],{memory & showHowExit = Just {exitInfo & ball=nextBallPos}})\r
+| not memory.first && topExit.py >= scale 0.5 goal_width - spaceAllowed\r
+       # sideStr                               = if (studentHome == West) "left" "right"\r
+       = ( [TellMessage ("Keeper left the " <+++ sideStr <+++ " side of the goal open. Exit ypos could be: " <+++ topExit.py)]\r
+         , {memory & showHowExit = Just {student=studentTeam,computer=compTeam,ball=theBall.ballPos.pxy,exit=topExit}}\r
+         )\r
+| not memory.first && bottomExit.py <= scale -0.5 goal_width + spaceAllowed\r
+       # sideStr                               = if (studentHome == West) "right" "left"\r
+       = ( [TellMessage ("keeper left the " <+++ sideStr <+++ " side of the goal open. Exit ypos could be: " <+++ bottomExit.py)]\r
+         , {memory & showHowExit = Just {student=studentTeam,computer=compTeam,ball=theBall.ballPos.pxy,exit=bottomExit}}\r
+         )\r
+| otherwise                                    = (refActions,memory)\r
+where\r
+       (compTeam,studentTeam,studentHome)\r
+                                                       = if (stringStarts (nameOf team1) base_TeamName_Opponent_Keeper) (team1,team2,East) (team2,team1,West)\r
+       ballKickoff                             = if (studentHome == West)\r
+                                                            {zero & px = scale -0.5 field.flength + penalty_area_depth}\r
+                                                            {zero & px = scale  0.5 field.flength - penalty_area_depth}\r
+       \r
+/*     The keeper has to cover the entire width of the goal minus spaceAllowed at both sides in order to be succesfull enough for this assignment.\r
+*/     spaceAllowed                    = scale (1.0/6.0) goal_width\r
+       theBall                                 = getFootball ballState (team1 ++ team2)\r
+       keeper                                  = hd (filter isKeeper studentTeam)\r
+       keeperPos                               = keeper.pos\r
+       ballDirection2keeper    = bearing zero theBall keeper\r
+       (topReachKeeper,bottomReachKeeper)\r
+                                                       = getMaximumCatchPositions ballDirection2keeper\r
+       \r
+/*     Draws a line from football to keeper\r
+       determines the two directions the keeper can jump to cover max area behind him\r
+       gets the maximum distance the keeper can catch/jump\r
+       returns the two positions past which the ball can pass the keeper\r
+*/     getMaximumCatchPositions :: !Angle -> (!Position,!Position)\r
+       getMaximumCatchPositions ballDirection2keeper\r
+               # ballDirection2keeper                  = if (ballDirection2keeper < rad (1.5*pi)) (ballDirection2keeper + rad (1.5*pi)) (ballDirection2keeper - rad (0.5*pi))\r
+               # catchCorner1                                  = if (ballDirection2keeper < rad (1.5*pi)) (ballDirection2keeper + rad (1.5*pi)) (ballDirection2keeper - rad (0.5*pi))\r
+               # catchCorner2                                  = if (ballDirection2keeper > rad (0.5*pi)) (ballDirection2keeper - rad (1.5*pi)) (ballDirection2keeper + rad (0.5*pi))\r
+               # maxCatchDistance                              = maxCatchReach keeper\r
+               # maxPoint1                                             = {px=keeperPos.px + scale (sinus catchCorner1) maxCatchDistance, py=keeperPos.py + scale (~(cosinus catchCorner1)) maxCatchDistance }\r
+               # maxPoint2                                             = {px=keeperPos.px + scale (sinus catchCorner2) maxCatchDistance, py=keeperPos.py + scale (~(cosinus catchCorner2)) maxCatchDistance }\r
+               | maxPoint1.py < maxPoint2.py   = (maxPoint2,maxPoint1)\r
+               | otherwise                                             = (maxPoint1,maxPoint2)\r
+       \r
+//     What if the keeper is passed could be the lowest position to let the ball exit the field\r
+       direction2topReach                                      = bearing zero theBall topReachKeeper\r
+       topExit                                                         = getExitPos topReachKeeper theBall.ballPos.pxy direction2topReach  \r
+//     What if the keeper is passed could be the lowest position to let the ball exit the field\r
+       direction2bottomReach                           = bearing zero theBall bottomReachKeeper\r
+       bottomExit                                                      = getExitPos bottomReachKeeper theBall.ballPos.pxy direction2bottomReach\r
+\r
+       getExitPos :: !Position !Position !Angle -> Position\r
+       getExitPos reachPos ballPos direction\r
+                                                                               = while aintOut (move_point {dx=m (cosinus dir),dy=m (sinus dir)}) target\r
+       where\r
+               (dir,target)                                    = if (reachPos.px >= zero) (direction,reachPos) (oppositeDirection direction,ballPos)\r
+               aintOut                                                 = point_in_rectangle ({px = scale -0.5 field.flength, py = scale -0.5 field.fwidth}\r
+                                                                                                    ,{px = scale  0.5 field.flength, py = scale  0.5 field.fwidth}\r
+                                                                                                    )\r
+\r
+oppositeDirection :: !Angle -> Angle\r
+oppositeDirection d\r
+| d > rad pi                                                   = d - rad pi\r
+| otherwise                                                            = d + rad pi\r
diff --git a/src/StdReferee/RefereeCoach_Passing_Assignment.dcl b/src/StdReferee/RefereeCoach_Passing_Assignment.dcl
new file mode 100644 (file)
index 0000000..915ffe1
--- /dev/null
@@ -0,0 +1,15 @@
+definition module RefereeCoach_Passing_Assignment\r
+\r
+/** This module implements a referee coach for a ball passing assignment.\r
+       The student footballer team should pass the ball from one end of the field to the other\r
+       end of the field. Accepting players should not move further away than 10 metres from \r
+       their starting point. The last player should kick the ball in the goal to end the assignment.\r
+       \r
+       The opponent team should be Team_Opponent_Passing_Assignment.\r
+       \r
+       Developed by Wanja Krah.\r
+*/\r
+\r
+import Referee\r
+\r
+RefereeCoach_Passing :: !FootballField -> Referee\r
diff --git a/src/StdReferee/RefereeCoach_Passing_Assignment.icl b/src/StdReferee/RefereeCoach_Passing_Assignment.icl
new file mode 100644 (file)
index 0000000..6ab6e2f
--- /dev/null
@@ -0,0 +1,157 @@
+implementation module RefereeCoach_Passing_Assignment\r
+\r
+import StdEnvExt\r
+import Referee\r
+import Team_Opponent_Passing_Assignment\r
+\r
+RefereeCoach_Passing :: !FootballField -> Referee\r
+RefereeCoach_Passing field     = { name  = "RefereeCoach Passing"\r
+                                                         , brain = { memory = initMem\r
+                                                                   , ai     = randomlessRefereeAI (brain field)\r
+                                                                   }\r
+                                                         , refActionPics    = []\r
+                                                         }\r
+\r
+:: Memory = { first                            :: !Bool\r
+                       , kickedBy1             :: !Bool                        // PA: oh dear, you should use [Bool], or better: if in sequence: Int\r
+                       , kickedBy2             :: !Bool\r
+                       , kickedBy3             :: !Bool\r
+                       , kickedBy4             :: !Bool\r
+                       , kickedBy5             :: !Bool\r
+                       , kickedBy6             :: !Bool\r
+                       , pos1                          :: !Position            // PA: dito, but now [Position]\r
+                       , pos2                          :: !Position\r
+                       , pos3                          :: !Position\r
+                       , pos4                          :: !Position\r
+                       , pos5                          :: !Position\r
+                       , pos6                          :: !Position\r
+                       , practiceFailed        :: !Bool\r
+                       , gameOver                      :: !Bool        \r
+                       }\r
+\r
+initMem :: Memory\r
+initMem   = { first                            = True\r
+                       , kickedBy1                     = False\r
+                       , kickedBy2                     = False\r
+                       , kickedBy3                     = False\r
+                       , kickedBy4                     = False\r
+                       , kickedBy5                     = False\r
+                       , kickedBy6                     = False\r
+                       , pos1                          = zero\r
+                       , pos2                          = zero\r
+                       , pos3                          = zero\r
+                       , pos4                          = zero\r
+                       , pos5                          = zero\r
+                       , pos6                          = zero\r
+                       , practiceFailed        = False\r
+                       , gameOver                      = False\r
+                       }\r
+\r
+brain :: !FootballField !(!RefereeInput,!Memory) -> (!RefereeOutput,!Memory)\r
+brain field ({RefereeInput | theBall=ballState, team1, team2}, memory)\r
+| memory.gameOver                                                                                              // game over because of succes or failure\r
+       = ([GameOver],memory)\r
+| memory.practiceFailed                                                                                        // assignment has failed\r
+       = ([TellMessage "Assignment failed, correct your team and try again"],{memory & gameOver = True})\r
+| length players <> 6                                                                                  // Check if there are indeed six fielders (to prevent run time errors)\r
+       = ([TellMessage "Number of fielders should be six. Correct your team and try again."],{memory & gameOver = True})\r
+# (refActions,memory)  = if memory.first                                               // when first, alter ball pos and remember all positions\r
+                                                       ([DirectFreeKick studentHome ballKickoff],{updateAllPos memory & first = False})\r
+                                                       ([],memory)\r
+# playersMovedToFar            = getPlayersThatMovedTooFar memory              // check if players did not move more than 10 meters from their starting positions\r
+| not (isEmpty playersMovedToFar)\r
+       = (refActions ++ getMessagesForTooFarPlayers playersMovedToFar,{memory & practiceFailed = True})\r
+| not memory.kickedBy1                                                                                 // first player has not kicked the ball yet\r
+       # (more,memory)         = checkIfPlayerKickedBall 1 memory\r
+       = (refActions++more,memory)\r
+| not memory.kickedBy2                                                                                 // second player has not kicked the ball yet\r
+       # (more,memory)         = checkIfPlayerKickedBall 2 memory\r
+       = (refActions++more,memory)\r
+| not memory.kickedBy3                                                                                 // third player has not kicked the ball yet\r
+       # (more,memory)         = checkIfPlayerKickedBall 3 memory\r
+       = (refActions++more,memory)\r
+| not memory.kickedBy4                                                                                 // fourth player has not kicked the ball yet\r
+       # (more,memory)         = checkIfPlayerKickedBall 4 memory\r
+       = (refActions++more,memory)\r
+| not memory.kickedBy5                                                                                 // fifth player has not kicked the ball yet\r
+       # (more,memory)         = checkIfPlayerKickedBall 5 memory\r
+       = (refActions++more,memory)\r
+| not memory.kickedBy6                                                                                 // sixth player has not kicked the ball yet\r
+       # (more,memory)         = checkIfPlayerKickedBall 6 memory\r
+       = (refActions++more,memory)\r
+| ballIsGoingInWrongDirection                                                                  // ball is going in the wrong direction\r
+       = (refActions ++ [TellMessage "ball should be played towards the goal"],{memory & practiceFailed = True})\r
+| ballBehindLine                                                                                               // ball is behind the line\r
+       | theBall.ballPos.pz > goal_height                                                      // ball is over\r
+               = (refActions ++ [TellMessage "Try shooting less high, the ball went over"],{memory & practiceFailed = True})\r
+       | isbetween theBall.ballPos.pxy.py south_pole north_pole\r
+               = (refActions ++ [TellMessage "Well Done! Move on to the next assignment!"],{memory & gameOver = True})\r
+       | otherwise\r
+               = (refActions ++ [TellMessage "Ball is out, try shooting in the goal next time"],{memory & practiceFailed = True})\r
+| theBall.ballSpeed.vxy.velocity == zero                                               // ball stopped moving\r
+       = (refActions ++ [TellMessage "Try shooting harder, the ball stopped moving forwards"],{memory & practiceFailed = True})\r
+| otherwise                                                                                                            // ball may be on its way to the goal\r
+       = (refActions,memory)\r
+where\r
+       theBall                                                                         = getFootball ballState (team1 ++ team2)\r
+       (compTeam,(studentTeam,studentHome))            = if (stringStarts (nameOf team1) base_TeamName_Opponent_Passing) (team1,(team2,East)) (team2,(team1,West))\r
+       ballKickoff                                                                     = {zero & px = if (studentHome == West) (scale -0.5 field.flength + penalty_area_depth) (scale 0.5 field.flength - penalty_area_depth)}\r
+       getMessagesForTooFarPlayers                                     = map (\fb -> TellMessage ("Your player with number " <+++ fb.playerID.playerNr <+++ " moved further than 10 meters"))\r
+       (north_pole,south_pole)                                         = goal_poles field\r
+       \r
+       players                                                                         = filter isFielder studentTeam\r
+       stud1                                                                           = players!!0\r
+       stud2                                                                           = players!!1\r
+       stud3                                                                           = players!!2\r
+       stud4                                                                           = players!!3\r
+       stud5                                                                           = players!!4\r
+       stud6                                                                           = players!!5\r
+       stud1fa                                                                         = getAction stud1.playerID\r
+       stud2fa                                                                         = getAction stud2.playerID\r
+       stud3fa                                                                         = getAction stud3.playerID\r
+       stud4fa                                                                         = getAction stud4.playerID\r
+       stud5fa                                                                         = getAction stud5.playerID\r
+       stud6fa                                                                         = getAction stud6.playerID\r
+       \r
+       getAction :: !FootballerID -> Maybe FootballerEffect\r
+       getAction playerID                                                      = case [fb.effect \\ fb <- team1 ++ team2 | identify_player playerID fb] of\r
+                                                                                                       [effect:_]      = effect\r
+                                                                                                       _                       = Nothing\r
+       \r
+       ballIsGoingInWrongDirection                                     = if (studentHome == West) > < theBall.ballSpeed.vxy.direction (rad (0.5*pi)) &&\r
+                                                                                                 if (studentHome == East) < > theBall.ballSpeed.vxy.direction (rad (1.5*pi))                   \r
+       ballBehindLine                                                          = abs theBall.ballPos.pxy.px > scale 0.5 field.flength\r
+                       \r
+       updateAllPos :: !Memory -> Memory\r
+       updateAllPos memory                                                     = {memory & pos1 = stud1.pos\r
+                                                                                                         , pos2 = stud2.pos\r
+                                                                                                         , pos3 = stud3.pos\r
+                                                                                                         , pos4 = stud4.pos\r
+                                                                                                         , pos5 = stud5.pos\r
+                                                                                                         , pos6 = stud6.pos\r
+                                                                                                 }\r
+       \r
+       getPlayersThatMovedTooFar :: !Memory -> [Footballer]\r
+       getPlayersThatMovedTooFar memory\r
+               = [fb \\ fb <- players & pos <- [memory.pos1,memory.pos2,memory.pos3,memory.pos4,memory.pos5,memory.pos6] | dist fb pos > m 10.0]\r
+                                                               \r
+       checkIfPlayerKickedBall :: !Int !Memory -> (![RefereeAction],!Memory)\r
+       checkIfPlayerKickedBall i memory\r
+               # (studfa,stud)                                                 = case i of\r
+                                                                                                       1 -> (stud1fa,stud1)\r
+                                                                                                       2 -> (stud2fa,stud2)\r
+                                                                                                       3 -> (stud3fa,stud3)\r
+                                                                                                       4 -> (stud4fa,stud4)\r
+                                                                                                       5 -> (stud5fa,stud5)\r
+                                                                                                       6 -> (stud6fa,stud6)\r
+               | perhaps isKickedBall studfa                   = ([],                                                           updateMemory i memory)\r
+               | perhaps isCaughtBall studfa                   = ([Hands stud.playerID, ReprimandPlayer stud.playerID RedCard],{memory & practiceFailed = True})\r
+               | otherwise                                                             = ([],                                                           memory)\r
+       where\r
+               updateMemory :: !Int !Memory -> Memory\r
+               updateMemory 1 m        = {m & kickedBy1 = True}\r
+               updateMemory 2 m        = {m & kickedBy2 = True}\r
+               updateMemory 3 m        = {m & kickedBy3 = True}\r
+               updateMemory 4 m        = {m & kickedBy4 = True}\r
+               updateMemory 5 m        = {m & kickedBy5 = True}\r
+               updateMemory 6 m        = {m & kickedBy6 = True}\r
diff --git a/src/StdReferee/RefereeCoach_Rounds_Assignment.dcl b/src/StdReferee/RefereeCoach_Rounds_Assignment.dcl
new file mode 100644 (file)
index 0000000..4fd4c35
--- /dev/null
@@ -0,0 +1,5 @@
+definition module RefereeCoach_Rounds_Assignment\r
+\r
+import Referee\r
+\r
+RefereeCoach_Rounds :: !FootballField -> Referee\r
diff --git a/src/StdReferee/RefereeCoach_Rounds_Assignment.icl b/src/StdReferee/RefereeCoach_Rounds_Assignment.icl
new file mode 100644 (file)
index 0000000..345b090
--- /dev/null
@@ -0,0 +1,103 @@
+implementation module RefereeCoach_Rounds_Assignment\r
+\r
+import Referee\r
+\r
+RefereeCoach_Rounds                            :: !FootballField -> Referee\r
+RefereeCoach_Rounds field              = { name                        = "RefereeCoach_Rounds"\r
+                                                                 , brain                       = { memory      = mkMemory\r
+                                                                                                         , ai          = randomlessRefereeAI (brain field)\r
+                                                                                                         }\r
+                                                                 , refActionPics       = []\r
+                                                                 }\r
+\r
+::     Memory                                          = { players                     :: ![(FootballerID, [Checkpoint])]      // players and their checkpoints\r
+                                                                 , stage                       :: !Stage                                                       // current stage of training\r
+                                                                 }\r
+::     Stage                                           = Begin | Rounds | End Success\r
+::     Checkpoint                                      = { base                        :: !Position\r
+                                                                 , distance            :: !Metre\r
+                                                                 , check                       :: !Bool\r
+                                                                 }\r
+\r
+mkMemory                                               :: Memory\r
+mkMemory                                               = { players                     = []\r
+                                                                 , stage                       = Begin\r
+                                                                 }\r
+\r
+fail                                                   :: Memory -> Memory\r
+fail memory                                            = {memory & stage = End Fail}\r
+\r
+ok                                                             :: Memory -> Memory\r
+ok memory                                              = {memory & stage = End Success}\r
+\r
+rounds                                                 :: Memory -> Memory\r
+rounds memory                                  = {memory & stage = Rounds}\r
+\r
+instance toPosition3D Checkpoint\r
+where    toPosition3D {base}   = toPosition3D base\r
+\r
+cornerCheckpoints                              :: !FootballField !Metre -> [Checkpoint]\r
+cornerCheckpoints field d              = [  { base = {px = x, py = y}, distance = d, check = False } \r
+                                                                 \\ x <- [scale -0.5 field.flength, scale  0.5 field.flength]\r
+                                                                  , y <- [scale  0.5 field.fwidth,  scale -0.5 field.fwidth ]\r
+                                                                 ]\r
+\r
+checkPoint                                             :: !Position !Checkpoint -> Checkpoint\r
+checkPoint pos checkpoint              = {checkpoint & check = checkpoint.check || dist pos checkpoint <= checkpoint.distance}\r
+\r
+checkpointsCleared                             :: ![Checkpoint] -> Bool\r
+checkpointsCleared checks              = and [check \\ {check} <- checks]\r
+\r
+distanceFromEdges                              :== m 5.0\r
+\r
+isIllegal                                              :: !FootballField !Position !Metre -> Bool\r
+isIllegal field pos distance   = point_in_rectangle ({px = scale -0.5 field.flength + distance, py = scale -0.5 field.fwidth + distance}\r
+                                                                                    ,{px = scale  0.5 field.flength - distance, py = scale  0.5 field.fwidth - distance}\r
+                                                                                    ) pos\r
+\r
+brain                                                  :: !FootballField !(!RefereeInput,!Memory) -> (!RefereeOutput,!Memory)\r
+\r
+//     Assignment has started. Locate all players and their checkpoints.\r
+brain field ({RefereeInput | team1,team2},memory=:{stage = Begin})\r
+| isEmpty players                              = verdict [TellMessage "No players selected."] (fail memory)\r
+| otherwise                                            = ([], rounds {memory & players = players})\r
+where\r
+       players                                         = [(player.playerID,cornerCheckpoints field distanceFromEdges) \\ player <- team1 ++ team2]\r
+\r
+//     Assignment is in the running stage. Monitor players and provide feedback.\r
+brain field ({RefereeInput | playingTime=time,unittime=dt,team1,team2},memory=:{players,stage = Rounds})\r
+| time <= minutes dt                   = verdict msg` (next next_memory)\r
+                                                               with\r
+                                                                       (msg`,next)     = if (all (checkpointsCleared o snd) checked) \r
+                                                                                                        ([], ok)\r
+                                                                                                        ([TellMessage "Not all checkpoints have been cleared."],fail)\r
+| isEmpty illegal_positions            = ([], next_memory)\r
+| otherwise                                            = ([TellMessage (length illegal_positions +++> " players have moved too far from edge.")], fail next_memory)\r
+where\r
+       next_memory                                     = { memory & players = checked }\r
+       checked                                         = [ (playerID, map (checkPoint pos) checkpoints) \\ (playerID,checkpoints) <- players\r
+                                                                                                                 & pos                    <- positions\r
+                                                                 ]\r
+       positions                                       = [ (find_player playerID all_players).pos       \\ (playerID,_)           <- players\r
+                                                                 ]\r
+       illegal_positions                       = [ (playerID,pos)                               \\ (playerID,_)           <- players\r
+                                                                                                                 & pos                    <- positions\r
+                                                                                                                 | isIllegal field pos distanceFromEdges\r
+                                                                 ]\r
+       all_players                                     = team1 ++ team2\r
+\r
+//     Assignment has ended. Stop training session and give final verdict.\r
+brain _ (_,memory)                             = verdict [] memory\r
+\r
+verdict                                                        :: ![RefereeAction] !Memory -> (![RefereeAction],!Memory)\r
+verdict actions memory=:{stage=End how}\r
+                                                               = (actions ++ [TellMessage msg,GameOver], memory)\r
+where\r
+       msg                                                     = if (how == Success) "Well done! Move on to next exercise."\r
+                                                                                     "Improve your assignment and try again."\r
+verdict actions memory                 = (actions ++ [GameOver], fail memory)\r
+\r
+find_player                                            :: FootballerID [Footballer] -> Footballer\r
+find_player playerID players   = case filter (identify_player playerID) players of\r
+                                                                       [player : _]    = player\r
+                                                                       no_one                  = abort ("player " <+++ playerID <+++ " lost in oblivion...")\r
diff --git a/src/StdReferee/RefereeCoach_Slalom_Assignment.dcl b/src/StdReferee/RefereeCoach_Slalom_Assignment.dcl
new file mode 100644 (file)
index 0000000..21c5274
--- /dev/null
@@ -0,0 +1,5 @@
+definition module RefereeCoach_Slalom_Assignment\r
+\r
+import Referee\r
+\r
+RefereeCoach_Slalom    :: !FootballField -> Referee\r
diff --git a/src/StdReferee/RefereeCoach_Slalom_Assignment.icl b/src/StdReferee/RefereeCoach_Slalom_Assignment.icl
new file mode 100644 (file)
index 0000000..1fabe4b
--- /dev/null
@@ -0,0 +1,126 @@
+implementation module RefereeCoach_Slalom_Assignment\r
+\r
+import Referee\r
+\r
+RefereeCoach_Slalom                            :: !FootballField -> Referee\r
+RefereeCoach_Slalom field              = { name  = "RefereeCoach_Slalom"\r
+                                                                 , brain = { memory    = mkMemory\r
+                                                                           , ai                = randomlessRefereeAI (brain field)\r
+                                                                           }\r
+                                                                 , refActionPics               = []\r
+                                                                 }\r
+\r
+::     Stage                                           = Begin | Slalom | Kick | End Success\r
+instance == Stage where                        == Begin    Begin               = True\r
+                                                               == Slalom   Slalom              = True\r
+                                                               == Kick     Kick                = True\r
+                                                               == (End s1) (End s2)    = s1 == s2\r
+                                                               == _        _                   = False\r
+\r
+::     Memory                                          = { positions   :: ![Position]          // all positions of student player, in reverse order\r
+                                                                 , stage               :: !Stage                       // the current stage of the training\r
+                                                                 , home                :: Home                         // home of student player, determined at Begin\r
+                                                                 }\r
+\r
+mkMemory                                               :: Memory\r
+mkMemory                                               = { positions   = []\r
+                                                                 , stage               = Begin\r
+                                                                 , home                = undef\r
+                                                                 }\r
+\r
+slalom                                                 :: Memory -> Memory\r
+slalom memory                                  = {memory & stage = Slalom}\r
+\r
+after_kick                                             :: Memory -> Memory\r
+after_kick memory                              = {memory & stage = Kick}\r
+\r
+fail                                                   :: Memory -> Memory\r
+fail memory                                            = {memory & stage = End Fail}\r
+\r
+ok                                                             :: Memory -> Memory\r
+ok memory                                              = {memory & stage = End Success}\r
+\r
+position                                               :: Position Memory -> Memory\r
+position p memory                              = {memory & positions = [p:memory.positions]}\r
+\r
+knownHome                                              :: Home Memory -> Memory\r
+knownHome home memory                  = {memory & home = home}\r
+\r
+brain                                                  :: !FootballField !(!RefereeInput,!Memory) -> (!RefereeOutput,!Memory)\r
+//     Assignment has started. Check teams and determine home of student player.\r
+brain field ({RefereeInput | team1,team2},memory=:{stage = Begin})\r
+| not ok_teams                                 = ([TellMessage "Wrong teams selected."],fail memory)\r
+| otherwise                                            = ([DirectFreeKick home ball],position student.pos (slalom (knownHome home memory)))\r
+where\r
+       (ok_teams,home)                         = case (team1,team2) of\r
+                                                                       ([p],[_,_:_])                   = (True, West)\r
+                                                                       ([_,_:_],[p])                   = (True, East)\r
+                                                                       otherwise                               = (False,undef)\r
+       student                                         = if (home == West) (hd team1) (hd team2)\r
+       west_ball_pos                           = {zero & px = scale -0.5 field.flength + penalty_area_depth}\r
+       ball                                            = if (home == West) (mirror field west_ball_pos) west_ball_pos\r
+//     Assignment has ended. Stop training session.\r
+brain _ (_,memory=:{stage = End how})\r
+                                                               = ([TellMessage msg, GameOver],memory)\r
+where\r
+       msg                                                     = if (how == Success) "Well done! Move on to next exercise."\r
+                                                                                     "Improve your assignment and try again."\r
+//     Assignment is in slalom or kicking stage.\r
+brain field ({RefereeInput | playingTime=time, theBall=ballState, team1, team2}, memory=:{home,positions,stage})\r
+| time <= zero                                 = ([TellMessage "Out of time."],fail memory)                                                    // time's up\r
+| ballIsFree ballState && ballIsOut field ball                                                                                                                 // ball is out\r
+       # ball_pos                                      = ball.ballPos.pxy\r
+       # (north,south)                         = goal_poles field\r
+       | not (isbetween ball_pos.py south north)                                                                                                                       // student did not kick ball in goal\r
+                                                               = ([TellMessage "You should play the ball in the goal."],fail memory)\r
+       | home == West && ball_pos.px < scale -0.5 field.flength + m 1.0 || \r
+         home == East && ball_pos.px > scale  0.5 field.flength - m 1.0                                                                        // student kicked ball in wrong goal\r
+                                                               = ([TellMessage "You should play the ball in the other goal."],fail memory)\r
+       | otherwise                                     = ([ContinueGame],ok memory)                                                                                    // student ended exercise correctly\r
+| isMoved action\r
+       | compare_pos student.pos last_pos                                                                                                                                      // student is moving in wrong direction\r
+                                                               = ([TellMessage "You're moving in the wrong direction."],fail memory)\r
+       | any (\other -> dist other student < m 0.5) others                                                                                                     // student moves too close to opponents\r
+                                                               = ([TellMessage "Don't move so close to opponents."],fail memory)\r
+       | not up_and_down                       = ([TellMessage "You're not doing a slalom."],fail memory)                              // student is not doing slalom\r
+       | otherwise                                     = ([ContinueGame],memory)\r
+| isKickedBall action\r
+       | stage == Kick                         = ([TellMessage "Don't kick the ball twice."],fail memory)                              // kick the ball only once\r
+       | otherwise                                     = ([ContinueGame],after_kick memory)\r
+| otherwise                                            = ([TellMessage ("Illegal action. Perform only Move and KickBall. You did: " <+++ typeOfAction action)],fail memory)\r
+where\r
+       ball                                            = getFootball ballState (team1 ++ team2)\r
+       (student,others)                        = if (home == West) (hd team1,team2) (hd team2,team1)\r
+       action                                          = fromJust student.effect\r
+       last_pos                                        = hd positions\r
+       new_positions                           = [student.pos : positions]\r
+       compare_px                                      = if (home == West) < >\r
+       compare_pos pos1 pos2           = compare_px pos1.px pos2.px\r
+       close_px    pos1 pos2           = abs (pos1.px - pos2.px) <= m 1.0\r
+       line_up_others                          = sortBy compare_pos (map (\{Footballer | pos} -> pos) others)\r
+       close_encounters                        = takeWhile (not o isEmpty) [filter (close_px other_pos) new_positions \\ other_pos <- line_up_others]\r
+       up_and_down                                     = isAlternating \r
+                                                                 [  map (\studentpos -> studentpos.py < other_pos.py) close_encounter\r
+                                                                 \\ close_encounter <- close_encounters\r
+                                                                  & other_pos       <- line_up_others\r
+                                                                 ]\r
+\r
+ballIsOut                                              :: !FootballField !Football -> Bool\r
+ballIsOut field ball                   = not (point_in_rectangle ({px = scale -0.5 field.flength, py = scale -0.5 field.fwidth}\r
+                                                                                         ,{px = scale  0.5 field.flength, py = scale  0.5 field.fwidth}\r
+                                                                                         ) ball.ballPos.pxy)\r
+\r
+typeOfAction                                   :: !FootballerEffect -> String\r
+typeOfAction (Moved _ _)               = "Move"\r
+typeOfAction (GainedBall _)            = "GainBall"\r
+typeOfAction (KickedBall _)            = "KickBall"\r
+typeOfAction (HeadedBall _)            = "HeadBall"\r
+typeOfAction (Feinted _)               = "Feint"\r
+typeOfAction (Tackled _ _ _)   = "Tackle"\r
+typeOfAction (CaughtBall _)            = "Catch"\r
+\r
+isAlternating                                  :: [[a]] -> Bool | Eq, ~ a\r
+isAlternating sequences                        = isEmpty sequences || all isSingleton singletons && map hd singletons == take n (iterate ~ (hd (hd singletons)))\r
+where\r
+       singletons                                      = map removeDup sequences\r
+       n                                                       = length sequences\r
diff --git a/src/StdReferee/RefereeFunctions.dcl b/src/StdReferee/RefereeFunctions.dcl
new file mode 100644 (file)
index 0000000..4625e3d
--- /dev/null
@@ -0,0 +1,29 @@
+definition module RefereeFunctions\r
+\r
+/**    Functions for creating miniscule refereeing brains:\r
+*/\r
+\r
+import Referee\r
+\r
+/** ball_left_field_at field:\r
+       if the ball left the field, it returns (Just edge location) of the field where that happened;\r
+       if the ball is inside the field, Nothing is returned.\r
+*/\r
+ball_left_field_at :: !FootballField -> RefereeAI` (Maybe Position)\r
+\r
+/** ball_in_goal field:\r
+       if the ball is in a goal, it returns the home of the field where the ball is;\r
+       if the ball is not in a goal, Nothing is returned.\r
+*/\r
+ball_in_goal :: !FootballField -> RefereeAI` (Maybe Home)\r
+\r
+/** half_of_game total_playing_time:\r
+       returns which half of the game is currently being played, assuming that @total_playing_time\r
+       is the correct time of the entire match.\r
+*/\r
+half_of_game :: !PlayingTime -> RefereeAI` Half\r
+\r
+/** offside_players field home:\r
+       returns the players from @home that are in offside position.\r
+*/\r
+players_in_offside_position :: !FootballField !Home -> RefereeAI` (AssocList FootballerID Position)\r
diff --git a/src/StdReferee/RefereeFunctions.icl b/src/StdReferee/RefereeFunctions.icl
new file mode 100644 (file)
index 0000000..be34336
--- /dev/null
@@ -0,0 +1,60 @@
+implementation module RefereeFunctions\r
+\r
+import Referee\r
+\r
+ball_left_field_at :: !FootballField -> RefereeAI` (Maybe Position)\r
+ball_left_field_at field=:{fwidth,flength}\r
+       = \{RefereeInput | theBall}\r
+               -> case theBall of\r
+                     Free ball = if (point_in_rectangle field_coordinates ball.ballPos.pxy)\r
+                                    Nothing\r
+                                    (Just (point_to_rectangle field_coordinates ball.ballPos.pxy))\r
+                     gained    = Nothing               // footballers are incapable of leaving the football field\r
+where\r
+       field_coordinates       = ({px = scale -0.5 flength, py = scale -0.5 fwidth}, {px = scale 0.5 flength, py = scale 0.5 fwidth})\r
+\r
+ball_in_goal :: !FootballField -> RefereeAI` (Maybe Home)\r
+ball_in_goal field=:{flength}\r
+       = \{RefereeInput | theBall}\r
+               -> case theBall of\r
+                     Free ball = let ball_inside       = isbetween ball.ballPos.pxy.py south north && ball.ballPos.pz <= goal_height\r
+                                  in if (ball.ballPos.pxy.px < scale -0.5 flength && ball_inside) (Just West)\r
+                                    (if (ball.ballPos.pxy.px > scale  0.5 flength && ball_inside) (Just East)\r
+                                                                                                  Nothing\r
+                                    )\r
+                     gained    = Nothing               // footballers must kick the ball in the goal to score\r
+where\r
+       (north,south)           = goal_poles field\r
+\r
+half_of_game :: !PlayingTime -> RefereeAI` Half\r
+half_of_game total_time\r
+       = \{RefereeInput | playingTime}\r
+               -> if (playingTime >= scale 0.5 total_time) FirstHalf SecondHalf\r
+\r
+players_in_offside_position :: !FootballField !Home -> RefereeAI` (AssocList FootballerID Position)\r
+players_in_offside_position field home\r
+       = \{RefereeInput | theBall,playingHalf,team1,team2}\r
+               -> let (players1,players2)      = if (home == West && playingHalf == FirstHalf || home == East && playingHalf == SecondHalf)\r
+                                                (displacements team1, displacements team2)\r
+                                                (displacements team2, displacements team1)\r
+                      ball                                     = getFootball theBall (team1 ++ team2)\r
+                   in offside_players field ball home players1 players2\r
+\r
+/** offside_players field ball home team opponents:\r
+       returns the players from @team that are in offside position.\r
+       @home is the current home of @team, and @opponents are the current opponents.\r
+       @ball is the current ball.\r
+*/\r
+offside_players :: !FootballField !Football !Home !Displacements !Displacements -> Displacements\r
+offside_players field ball home team opponents\r
+       = [(player,pos) \\  (player,pos) <- team             // a player is in offside position if:\r
+                        |  team_ord pos.px middle_x         // he is at the opponent's half of the field, and\r
+                        && team_ord pos.px opponent_x       // he is closer to the opponent's base line than the 2nd-last opponent, and\r
+                        && team_ord pos.px ball_x           // he is closer to the opponent's base line than the ball\r
+         ]\r
+where\r
+       middle_x                = zero\r
+       ball_x                  = ball.ballPos.pxy.px\r
+       team_ord                = if (home == West) (>) (<)\r
+       opponent_x              = (snd ((sortBy opponent_ord opponents) !! 1)).px\r
+       opponent_ord    = if (home == West) (\(_,p1) (_,p2) -> p1.px >= p2.px) (\(_,p1) (_,p2) -> p1.px <= p2.px)\r
diff --git a/src/StdReferee/Umpire.dcl b/src/StdReferee/Umpire.dcl
new file mode 100644 (file)
index 0000000..393faea
--- /dev/null
@@ -0,0 +1,5 @@
+definition module Umpire\r
+\r
+import Referee\r
+\r
+umpire :: !FootballField -> Referee\r
diff --git a/src/StdReferee/Umpire.icl b/src/StdReferee/Umpire.icl
new file mode 100644 (file)
index 0000000..643624e
--- /dev/null
@@ -0,0 +1,276 @@
+implementation module Umpire\r
+\r
+import RefereeFunctions\r
+\r
+umpire                                         :: !FootballField -> Referee\r
+umpire field                           = { name                        = "Umpire"\r
+                                                         , brain                       = {memory = Nothing, ai = brain field}\r
+                                                         , refActionPics       = []\r
+                                                         }\r
+\r
+::     Memory                                  = { total_time          :: !PlayingTime                                                 // the playing time\r
+                                                         , current_half        :: !Half                                                                // the current playing half (initially FirstHalf)\r
+                                                         , placing1            :: !Displacements                                               // the placing of team1 at the start of the match\r
+                                                         , placing2            :: !Displacements                                               // the placing of team2 at the start of the match\r
+                                                         , forbidden           :: !Maybe Home                                                  // players from (Just home) are not allowed to play the ball\r
+                                                         , offside                     :: ![FootballerID]                                              // players that are offside and thus should not play the ball\r
+                                                         , reprimands          :: !AssocList FootballerID [Reprimand]  // the reprimands collected by each player\r
+                                                         , situation           :: !Maybe (Situation,Pending)                   // the situation of the game\r
+                                                         }\r
+::     Situation                               = IsCenterKick | IsCornerKick | IsDirectFreeKick | IsGoalKick | IsPenaltyKick | IsThrowIn | IsKeeperBall !Home\r
+::     Pending                                 = IsPending !Deadline | IsExecuted\r
+::     Deadline                          :== Seconds\r
+\r
+brain                                          :: !FootballField !(!RefereeInput,!(!Maybe Memory,!RandomSeed)) -> (!RefereeOutput,!(!Maybe Memory,!RandomSeed))\r
+//     Referee enters the game, so (s)he needs to be filled in on the game details:\r
+brain field (input=:{RefereeInput | team1,team2,playingTime},(Nothing,seed))\r
+| team1_ok && team2_ok         = ([CenterKick West,DisplacePlayers ds], (Just memory,seed))\r
+| otherwise                                    = ([TellMessage wrong_team,GameOver],    (Nothing,    seed))\r
+where\r
+       team1_ok                                = isValidTeam team1 && allPlayersAtHome field West team1\r
+       team2_ok                                = isValidTeam team2 && allPlayersAtHome field East team2\r
+       wrong_team                              = if (not team1_ok) (nameOf team1 +++ " is invalid. ") "" +++\r
+                                                         if (not team2_ok) (nameOf team2 +++ " is invalid. ") ""\r
+       memory                                  = { total_time   = playingTime\r
+                                                         , current_half = FirstHalf\r
+                                                         , placing1     = displacements team1\r
+                                                         , placing2     = displacements team2\r
+                                                         , forbidden    = Just East\r
+                                                         , offside      = []\r
+                                                         , reprimands   = []\r
+                                                         , situation    = Just (IsCenterKick,IsPending center_kick_deadline)\r
+                                                         }\r
+       ds                                              = center_kick_positions field West memory\r
+\r
+//     Referee stops the game when a team has less than 7 players:\r
+brain field (input=:{RefereeInput | team1, team2},(Just memory,seed))\r
+| too_few_players                      = ([GameCancelled winner,TellMessage ("Game cancelled." <+++ msg)],(Just memory,seed))\r
+where\r
+       too_few_players                 = too_few_team1 || too_few_team2\r
+       too_few_team1                   = length team1 < 7\r
+       too_few_team2                   = length team2 < 7\r
+       (winner,msg)                    = if (too_few_team1 && too_few_team2) (Nothing,   "Both teams have less than 7 players left.")\r
+                                                        (if  too_few_team1                   (Just East, nameOf team1 +++> " has less than 7 players left.")\r
+                                                                                             (Just West, nameOf team2 +++> " has less than 7 players left.")\r
+                                                        )\r
+\r
+//     Referee checks whether the game is at the first half, second half, or completely over:\r
+brain field (input=:{RefereeInput | playingTime},(Just memory=:{current_half,total_time},seed))\r
+| playingTime <= zero          = ([GameOver],                                   (Just memory_no_offside,seed))\r
+| current_half <> half         = ([EndHalf,CenterKick West,DisplacePlayers ds], (Just memory_2nd_half,  seed))\r
+where\r
+       half                                    = half_of_game total_time input\r
+       memory_no_offside               = { memory            & situation = Nothing, offside = [] }\r
+       memory_2nd_half                 = { memory_no_offside & situation = Just (IsCenterKick,IsPending center_kick_deadline), current_half = half, forbidden = Just East }\r
+       ds                                              = center_kick_positions field West memory_2nd_half\r
+\r
+//     Referee checks whether a team has scored a goal:\r
+brain field (input,(Just memory=:{current_half},seed))\r
+| isJust in_goal                       = ([Goal scoring_team,CenterKick (other scoring_team),DisplacePlayers ds],(Just memory_goal,seed))\r
+where\r
+       in_goal                                 = ball_in_goal field input\r
+       goal                                    = fromJust in_goal\r
+       scoring_team                    = other goal\r
+       ds                                              = center_kick_positions field goal memory\r
+       memory_goal                             = { memory & forbidden = Just scoring_team, offside = [], situation = Just (IsCenterKick,IsPending center_kick_deadline) }\r
+\r
+//     Referee checks whether the keeper has caught the ball.\r
+//     In that case the keeper is obliged to play the ball within 6 seconds.\r
+brain field (input=:{RefereeInput | team1, team2},(Just memory=:{situation},seed))\r
+| keeper_catches_ball          = ([],(Just memory_keeper_ball,seed))\r
+where\r
+       keeper_catches_ball             = not (isEmpty catchers) && catcher.playerNr == 1 && ball_was_uncaught\r
+       ball_was_uncaught               = isNothing situation || isJust situation && fst (fromJust situation) <> IsKeeperBall team_of_catcher\r
+       catchers                                = [playerID \\ {playerID,effect=Just action} <- team1 ++ team2 | isCaughtBall action]\r
+       catcher                                 = hd catchers\r
+       team_of_catcher                 = home_of_player catcher input\r
+       memory_keeper_ball              = { memory & situation = Just (IsKeeperBall team_of_catcher,IsPending keeper_deadline)\r
+                                                                  , forbidden = Just (other team_of_catcher)\r
+                                                                  , offside   = []\r
+                                                         }\r
+\r
+//     Referee checks whether the ball has exited the football field.\r
+//     If the last player who played the ball is not known, then the ball is thrown in by the team playing on the half of the field where the ball left the field.\r
+brain field (input=:{RefereeInput | lastContact},(Just memory=:{current_half},seed))\r
+| isJust ball_exit                     =  if is_throw_in ([ThrowIn  (other team) exit_pos], (Just {memory_enter & situation = Just (IsThrowIn,   IsPending restart_deadline)},seed))\r
+                                 (if is_corner   ([Corner   (other team) edge],     (Just {memory_enter & situation = Just (IsCornerKick,IsPending restart_deadline)},seed))\r
+                                                     ([GoalKick (other team)],          (Just {memory_enter & situation = Just (IsGoalKick,  IsPending keeper_deadline )},seed))\r
+                                     )\r
+where\r
+       ball_exit                               = ball_left_field_at field input\r
+       exit_pos                                = fromJust ball_exit\r
+       team                                    = case lastContact of\r
+                                                            Just fID   = home_of_player fID input\r
+                                                            unknown    = if (home == West) (if (current_half == FirstHalf) West East) (if (current_half == FirstHalf) East West)\r
+       is_throw_in                             = abs exit_pos.py >= scale 0.5 field.fwidth\r
+       is_corner                               = exit_pos.px <= scale -0.5 field.flength && team == West || exit_pos.px >= scale 0.5 field.flength && team == East\r
+       home                                    = if (exit_pos.px < zero) West  East\r
+       edge                                    = if (exit_pos.py > zero) North South\r
+       memory_enter                    = { memory & forbidden = Just team, offside = [] }\r
+\r
+//     Referee checks whether the ball is not played correctly:\r
+brain field (input=:{RefereeInput | team1, team2, playingHalf},(Just memory=:{forbidden},seed))\r
+| improper_team                                = ([OwnBallIllegally ball_player,DirectFreeKick (other team) player_pos,DisplacePlayers ds:map (ReprimandPlayer ball_player) new_reprimands]\r
+                                                         ,(Just memory_illegal,seed)\r
+                                                         )\r
+where\r
+       improper_team                   = isJust forbidden && ball_is_played && team_of_ball_player == team\r
+       ball_players                    = [(playerID,pos) \\ {playerID,pos,effect=Just action} <- team1 ++ team2 | isBallAction action]\r
+       ball_is_played                  = not (isEmpty ball_players)\r
+       (ball_player,player_pos)= hd ball_players\r
+       team_of_ball_player             = home_of_player ball_player input\r
+       team                                    = fromJust forbidden\r
+       ds                                              = direct_free_kick_positions team player_pos input\r
+       (new_reprimands,memory_reprimanded)\r
+                                                       = reprimand_player ball_player Warning { memory & offside = [], situation = Just (IsDirectFreeKick,IsPending free_kick_deadline) }\r
+       expel                                   = isMember RedCard new_reprimands\r
+       memory_illegal                  = if expel (expel_player ball_player team_of_ball_player playingHalf memory_reprimanded) memory_reprimanded\r
+\r
+//     Referee checks whether the hands-rule has been offended:\r
+brain field (input=:{RefereeInput | team1, team2, playingHalf},(Just memory=:{current_half},seed))\r
+| hands_offense                                = ([Hands catcher,DirectFreeKick (other team) catcher_pos,DisplacePlayers ds:map (ReprimandPlayer catcher) new_reprimands]\r
+                                                         ,(Just memory_hands,seed)\r
+                                                         )\r
+where\r
+       hands_offense                   = ball_is_caught && (catcher.playerNr <> 1 || not (inPenaltyArea field team catcher_pos))\r
+       catchers                                = [(playerID,pos) \\ {playerID,pos,effect=Just action} <- team1 ++ team2 | isCaughtBall action]\r
+       (catcher,catcher_pos)   = hd catchers\r
+       ball_is_caught                  = not (isEmpty catchers)\r
+       team                                    = home_of_player catcher input\r
+       ds                                              = direct_free_kick_positions team catcher_pos input\r
+       (new_reprimands,memory_reprimanded)\r
+                                                       = reprimand_player catcher YellowCard { memory & forbidden = Just team, offside = [], situation = Just (IsDirectFreeKick,IsPending free_kick_deadline) }\r
+       expel                                   = isMember RedCard new_reprimands\r
+       memory_hands                    = if expel (expel_player catcher team playingHalf memory_reprimanded) memory_reprimanded\r
+\r
+//     Referee checks whether the offside-rule has been offended:\r
+brain field (input=:{RefereeInput | team1, team2},(Just memory=:{offside},seed))\r
+| offside_offense                      = ([Offside offender,DirectFreeKick (other team) player_pos,DisplacePlayers ds],(Just memory_offside_lifted,seed))      // this should really be an indirect free kick, but that is not implemented yet\r
+where\r
+       offside_offense                 = ball_is_played && isMember offender offside   // offside is activated by a player in offside position playing the ball\r
+       ball_players                    = [(playerID,pos) \\ {playerID,pos,effect=Just action} <- team1 ++ team2 | isPlayBallAction action]\r
+       ball_is_played                  = not (isEmpty ball_players)\r
+       (offender,player_pos)   = hd ball_players\r
+       team                                    = home_of_player offender input\r
+       ds                                              = direct_free_kick_positions team player_pos input\r
+       memory_offside_lifted   = { memory & forbidden = Just team, offside = [], situation = Just (IsDirectFreeKick,IsPending free_kick_deadline) }\r
+\r
+//     Referee checks whether a team is passive:\r
+brain field (input=:{RefereeInput | theBall, team1, team2, playingHalf},(Just memory=:{forbidden=Just team,situation=Just (state,IsPending dt)},seed))\r
+| passivity                                    = ([TellMessage msg,DirectFreeKick team ball.ballPos.pxy,DisplacePlayers ds],(Just memory_passive,seed))\r
+where\r
+       passivity                               = dt < zero\r
+       memory_passive                  = { memory & forbidden = Just (other team), offside = [], situation = Just (IsDirectFreeKick,IsPending free_kick_deadline)}\r
+       ball                                    = getFootball theBall (team1 ++ team2)\r
+       ds                                              = direct_free_kick_positions (other team) ball.ballPos.pxy input\r
+       msg                                             = "Passive play by " <+++ nameOf (if (team == West && playingHalf == FirstHalf || team == East && playingHalf == SecondHalf) team2 team1)\r
+\r
+//     Referee checks the status of the rules and remains silent to let the game continue:\r
+brain field (input=:{RefereeInput | theBall, team1, team2},(Just memory=:{situation,forbidden},seed))\r
+# memory                                       = decrease_pending_time input memory\r
+# memory                                       = if  ball_is_played                              { memory & situation = new_situation } memory\r
+# memory                                       = if (ball_is_played && not no_offside_situation) { memory & offside   = at_offside    } memory\r
+# memory                                       = if (ball_is_played && lift_forbidden_rule)      { memory & forbidden = Nothing       } memory\r
+= ([],(Just memory,seed))\r
+where\r
+       new_situation                   = if (isJust situation) (case pending of\r
+                                                                                   IsPending _ = Just (state,IsExecuted)\r
+                                                                                   _           = Nothing\r
+                                                                               ) Nothing\r
+       no_offside_situation    = isJust situation && isMember state [IsCornerKick,IsGoalKick,IsThrowIn]\r
+       lift_forbidden_rule             = isJust forbidden && team_of_ball_player == other forbidden_team\r
+       (state,pending)                 = fromJust situation\r
+       forbidden_team                  = fromJust forbidden\r
+       ball_players                    = [playerID \\ {playerID,effect=Just action} <- team1 ++ team2 | isBallAction action]\r
+       ball_is_played                  = not (isEmpty ball_players)\r
+       ball_player                             = hd ball_players\r
+       team_of_ball_player             = home_of_player ball_player input\r
+       at_offside                              = [playerID \\ (playerID,_) <- players_in_offside_position field team_of_ball_player input | playerID <> ball_player]\r
+\r
+decrease_pending_time          :: !RefereeInput !Memory -> Memory\r
+decrease_pending_time input=:{RefereeInput | unittime} memory=:{situation = Just (state,IsPending dt)}\r
+                                                       = { memory & situation = Just (state,IsPending (dt - unittime)) }\r
+decrease_pending_time _ memory\r
+                                                       = memory\r
+\r
+expel_player                           :: !FootballerID !Home !Half !Memory -> Memory\r
+expel_player player team half memory=:{placing1,placing2}\r
+| team == West && half == FirstHalf || team == East && half == SecondHalf\r
+                                                       = { memory & placing1 = deletekeyvalue player placing1 }\r
+| otherwise                                    = { memory & placing2 = deletekeyvalue player placing2 }\r
+\r
+reprimand_player                       :: !FootballerID !Reprimand !Memory -> (![Reprimand],!Memory)\r
+reprimand_player player reprimand memory=:{reprimands}\r
+# new_reprimands                       = [reprimand]\r
+# new_reprimands                       = if (length (filter ((==) Warning)    (new_reprimands ++ player_reprimands)) >= 3) (new_reprimands ++ [YellowCard]) new_reprimands\r
+# new_reprimands                       = if (length (filter ((==) YellowCard) (new_reprimands ++ player_reprimands)) >= 2) (new_reprimands ++ [RedCard])    new_reprimands\r
+= (new_reprimands, {memory & reprimands = addkeyvalue (player,player_reprimands ++ new_reprimands) reprimands})\r
+where\r
+       player_reprimands               = lookupd [] player reprimands\r
+\r
+home_of_player                         :: !FootballerID !RefereeInput -> Home\r
+home_of_player player {RefereeInput | playingHalf,team1}\r
+| sameClub player (hd team1).playerID\r
+                                                       = if (playingHalf == FirstHalf) West East\r
+| otherwise                                    = if (playingHalf == FirstHalf) East West\r
+\r
+isPlayBallAction                       :: !FootballerEffect -> Bool\r
+isPlayBallAction action                = isKickedBall action || isHeadedBall action\r
+\r
+isBallAction                           :: !FootballerEffect -> Bool\r
+isBallAction action                    = isKickedBall action || isHeadedBall action || isGainedBall action || isCaughtBall action\r
+\r
+center_kick_positions          :: !FootballField !Home !Memory -> Displacements\r
+center_kick_positions field home_kicking_off {placing1,placing2,current_half}\r
+| home_kicking_off == West     = kick_off positions1 ++ map repell_from_center positions2\r
+| otherwise                                    = map repell_from_center positions1 ++ kick_off positions2\r
+where\r
+       (positions1,positions2) = if (current_half == FirstHalf) (placing1,placing2)\r
+                                                                                        ([(playerID,mirror field pos) \\ (playerID,pos) <- placing2]\r
+                                                                                        ,[(playerID,mirror field pos) \\ (playerID,pos) <- placing1]\r
+                                                                                        )\r
+       center                                  = zero\r
+       repell_from_center              = \(player,pos) -> (player,repell  radius_centre_circle center pos)\r
+       attract_to_center               = \(player,pos) -> (player,attract (m 0.5) center pos)\r
+       kick_off placement              = map attract_to_center closest ++ map repell_from_center others\r
+       where\r
+               sorted                          = sortBy (\(_,pos1) (_,pos2) -> dist pos1 center < dist pos2 center) placement\r
+               (closest,others)        = splitAt 2 sorted\r
+\r
+/**    direct_free_kick_positions home pos input:\r
+               move players of @home away from @pos, and attract the closest fielder of (other @home) to @pos.\r
+*/\r
+direct_free_kick_positions     :: !Home !Position !RefereeInput -> Displacements\r
+direct_free_kick_positions team free_kick_pos input=:{RefereeInput | team1, team2, playingHalf}\r
+       = [attract_kicker : push_away_offenders]\r
+where\r
+       (offenders,free_kickers)= if (team == West && playingHalf == FirstHalf || team == East && playingHalf == SecondHalf) (team1,team2) (team2,team1)\r
+       push_away_offenders             = map (\{playerID,pos} -> (playerID,repell repell_distance free_kick_pos pos)) offenders\r
+       closest_player                  = snd (hd (sortBy (\(d1,_) (d2,_) -> d1 < d2) [(dist free_kick_pos player,player) \\ player <- free_kickers | isFielder player]))\r
+       attract_kicker                  = (closest_player.playerID,attract (m 1.0) free_kick_pos closest_player.pos)\r
+\r
+keeper_deadline                                :== s  6.0\r
+center_kick_deadline           :== s  1.0\r
+free_kick_deadline                     :== s  1.0\r
+restart_deadline                       :== s 20.0\r
+\r
+instance ==       Situation    where == IsCenterKick      IsCenterKick      = True\r
+                                                             == IsCornerKick      IsCornerKick      = True\r
+                                                             == IsDirectFreeKick  IsDirectFreeKick  = True\r
+                                                             == IsGoalKick        IsGoalKick        = True\r
+                                                             == IsPenaltyKick     IsPenaltyKick     = True\r
+                                                             == IsThrowIn         IsThrowIn         = True\r
+                                                             == (IsKeeperBall t1) (IsKeeperBall t2) = t1 == t2\r
+                                                             == _                 _                 = False\r
+instance ==       Pending      where == (IsPending t1)    (IsPending t2)    = t1 == t2\r
+                                                             == IsExecuted        IsExecuted        = True\r
+                                                             == _                 _                 = False\r
+instance toString Situation    where toString IsCenterKick                  = "IsCenterKick"\r
+                                                             toString IsCornerKick                  = "IsCornerKick"\r
+                                                             toString IsDirectFreeKick              = "IsDirectFreeKick"\r
+                                                             toString IsGoalKick                    = "IsGoalKick"\r
+                                                             toString IsPenaltyKick                 = "IsPenaltyKick"\r
+                                                             toString IsThrowIn                     = "IsThrowIn"\r
+                                                             toString (IsKeeperBall h)              = "(IsKeeperBall " <+++ h <+++ ")"\r
+instance toString Pending      where toString (IsPending t)                 = "(IsPending "    <+++ t <+++ ")"\r
+                                                             toString IsExecuted                    = "IsExecuted"\r
diff --git a/src/StdTeam/Buffer.dcl b/src/StdTeam/Buffer.dcl
new file mode 100644 (file)
index 0000000..13b172c
--- /dev/null
@@ -0,0 +1,11 @@
+definition module Buffer\r
+\r
+/**    This module implements a footballer who only runs in north-south direction on the \r
+       football field. This player can be used for assignments, such as the deep pass\r
+       assignments.\r
+       \r
+       Developed by Wanja Krah.\r
+*/\r
+import Footballer\r
+\r
+buffer :: !FootballField !Home !Edge !FootballerID -> Footballer\r
diff --git a/src/StdTeam/Buffer.icl b/src/StdTeam/Buffer.icl
new file mode 100644 (file)
index 0000000..b82a022
--- /dev/null
@@ -0,0 +1,41 @@
+implementation module Buffer\r
+\r
+import StdEnvExt\r
+import Footballer\r
+\r
+buffer :: !FootballField !Home !Edge !FootballerID -> Footballer\r
+buffer field home edge playerID = {defaultFootballer playerID & name   = "buffer"\r
+                                                              , length = m 2.2\r
+                                                              , skills = (Running, Gaining, Rotating)\r
+                                                              , brain  = { memory = {curDir = if (edge == North) (rad (0.5*pi)) (rad (-0.5*pi))}\r
+                                                                         , ai     = the_mind_of_a_buffer field home\r
+                                                                         }\r
+                                                              }\r
+\r
+::     Memory  =       { curDir :: !Angle\r
+                               }\r
+\r
+the_mind_of_a_buffer :: !FootballField !Home !(!BrainInput,!Memory) -> (!BrainOutput,!Memory)\r
+the_mind_of_a_buffer field home ({football,others,me},memory)\r
+| dist ball me < maxGainReach me                                                                                                                       // I can gain the ball\r
+                                               = (GainBall,memory)\r
+| dist ball me < m 30.0 && ballIsInZone                                                                                                                // I can not gain the ball, but I can run to it\r
+                                               = (runTowardsBall,memory)\r
+| abs me.pos.py > scale 0.5 field.fwidth - sidebuffer                                                                          // near the edge, turn around\r
+                                               = (Move {velocity = ms 25.0,direction=new_direction} zero, {memory & curDir = new_direction})\r
+                                               with\r
+                                                       new_direction   = if (me.speed.direction < zero) (rad (0.5*pi)) (rad (-0.5*pi))\r
+| otherwise                            = (Move {velocity = ms 25.0,direction=memory.curDir} zero,memory)       // no ball, no turning, just keep running\r
+where\r
+       sidebuffer                      = scale 0.01 field.fwidth\r
+       ball                            = getFootball football [me:others]\r
+       ball_x                          = ball.ballPos.pxy.px\r
+       ballIsInZone            = if (home == East) (isbetween ball_x (scale  0.15 field.flength) (scale  0.20 field.flength))\r
+                                                                   (isbetween ball_x (scale -0.10 field.flength) (scale -0.10 field.flength))\r
+       nextBallPos                     = (nextpos ball).ballPos\r
+       direction2ball          = bearing me.speed.direction me nextBallPos.pxy\r
+       runTowardsBall          = Move {direction=direction2ball,velocity=ms 10.0} zero\r
+\r
+nextpos :: !Football -> Football\r
+nextpos ball=:{ballSpeed={vxy={velocity=v,direction=d},vz=v3},ballPos}\r
+       = {ball & ballPos   = move_point3D {zero & dxy={dx=m (cosinus d * toReal v),dy=m (sinus d * toReal v)}} ballPos}\r
diff --git a/src/StdTeam/KeeperChallenger.dcl b/src/StdTeam/KeeperChallenger.dcl
new file mode 100644 (file)
index 0000000..6022faa
--- /dev/null
@@ -0,0 +1,5 @@
+definition module KeeperChallenger\r
+\r
+import Footballer\r
+\r
+keeperChallenger :: !FootballerID -> Footballer\r
diff --git a/src/StdTeam/KeeperChallenger.icl b/src/StdTeam/KeeperChallenger.icl
new file mode 100644 (file)
index 0000000..427fd07
--- /dev/null
@@ -0,0 +1,39 @@
+implementation module KeeperChallenger\r
+\r
+import Team\r
+\r
+keeperChallenger                                       :: !FootballerID -> Footballer\r
+keeperChallenger playerID                      = { defaultFootballer playerID & name   = "Zidane"\r
+                                                                                              , length = m 2.2\r
+                                                                                              , skills = (Gaining, Catching, Kicking)\r
+                                                                                              , brain  = {memory = {waitToKick = 0}, ai = mind}\r
+                                                                 }\r
+\r
+::     Memory                                                  = { waitToKick  :: !Int }\r
+\r
+decreaseWait                                           :: !Memory -> Memory\r
+decreaseWait memory=:{waitToKick}      = {memory & waitToKick = max 0 (waitToKick-1)}\r
+\r
+startWaiting                                           :: !Memory -> Memory\r
+startWaiting memory                                    = {memory & waitToKick = 20}\r
+\r
+mind                                                           :: !(!BrainInput,!Memory) -> (!BrainOutput,!Memory)\r
+mind ({football,others,me},memory)\r
+| memory.waitToKick > 0                                = (Move zero zero,decreaseWait memory)\r
+| ballIsGainedBy me.playerID football\r
+                                                                       = (KickBall {vxy={direction=bearing zero me next_pos,velocity=ms (max 5.0 (toReal (dist me next_pos)))},vz=ms 1.0},startWaiting memory)\r
+| ballIsFree football && i_am_closest_to_ball\r
+       | dist_to_free_ball <= maxGainReach me\r
+                                                                       = (GainBall,memory)\r
+       | otherwise                                             = (Move {direction=angle_with_free_ball,velocity=ms 4.0} (angle_with_free_ball - me.nose),memory)\r
+| otherwise                                                    = (Move zero zero,memory)\r
+where\r
+       team_players                                    = filter (sameClub me) others\r
+       my_nr                                                   = me.playerID.playerNr\r
+       next_nr                                                 = ((my_nr-1) rem (length team_players)) + 2\r
+       next_player                                             = hd (filter (identify_player {me.playerID & playerNr=next_nr}) team_players)\r
+       next_pos                                                = next_player.pos\r
+       free_ball                                               = getFootball football [me:others]\r
+       angle_with_free_ball                    = bearing zero me free_ball\r
+       dist_to_free_ball                               = dist me free_ball\r
+       i_am_closest_to_ball                    = dist_to_free_ball <= minList (map (dist free_ball) team_players)\r
diff --git a/src/StdTeam/TeamMiniEffie.dcl b/src/StdTeam/TeamMiniEffie.dcl
new file mode 100644 (file)
index 0000000..5d3910f
--- /dev/null
@@ -0,0 +1,10 @@
+definition module TeamMiniEffie\r
+\r
+/**    This module implements a team of simple minded football players.\r
+       Use it for testing Soccer-Fun.\r
+*/\r
+\r
+import Team\r
+\r
+Team_MiniEffies                        :: !Home !FootballField -> Team\r
+base_TeamName_MiniEffie        :: String\r
diff --git a/src/StdTeam/TeamMiniEffie.icl b/src/StdTeam/TeamMiniEffie.icl
new file mode 100644 (file)
index 0000000..13929cb
--- /dev/null
@@ -0,0 +1,69 @@
+implementation module TeamMiniEffie\r
+\r
+import StdEnv, StdIO, Footballer, FootballerFunctions\r
+\r
+Team_MiniEffies :: !Home !FootballField -> Team\r
+Team_MiniEffies 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
+base_TeamName_MiniEffie                :: String\r
+base_TeamName_MiniEffie                = "MiniEffies"                                                    \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
diff --git a/src/StdTeam/Team_Opponent_DeepPass_Assignment.dcl b/src/StdTeam/Team_Opponent_DeepPass_Assignment.dcl
new file mode 100644 (file)
index 0000000..2c232d7
--- /dev/null
@@ -0,0 +1,10 @@
+definition module Team_Opponent_DeepPass_Assignment\r
+\r
+/**    Team_Opponent_DeepPass creates a team of opponents to be used in the deep pass assignment.\r
+       The base name of that team is base_TeamName_Opponent_DeepPass1.\r
+*/\r
+\r
+import Team\r
+\r
+Team_Opponent_DeepPass                 :: !Home FootballField -> Team\r
+base_TeamName_Opponent_DeepPass        :: String\r
diff --git a/src/StdTeam/Team_Opponent_DeepPass_Assignment.icl b/src/StdTeam/Team_Opponent_DeepPass_Assignment.icl
new file mode 100644 (file)
index 0000000..1871f1f
--- /dev/null
@@ -0,0 +1,37 @@
+implementation module Team_Opponent_DeepPass_Assignment\r
+\r
+import StdEnvExt\r
+import Team\r
+from   Buffer import buffer\r
+\r
+Team_Opponent_DeepPass :: !Home FootballField -> Team\r
+Team_Opponent_DeepPass home field\r
+                                       = map tagName fielders\r
+where\r
+       club                    = base_TeamName_Opponent_DeepPass +++ if (home == West) "_W" "_E"\r
+       fielders                = getFielders club home field\r
+\r
+base_TeamName_Opponent_DeepPass :: String\r
+base_TeamName_Opponent_DeepPass = "Opp_Deep_Pass"\r
+\r
+getFielders :: String Home FootballField -> [Footballer]\r
+getFielders club home field\r
+       # buf1                  = {buffer field home south {clubName=club,playerNr=2 } & pos={px=scale 0.07 field.flength, py=scale  0.40 field.fwidth}}\r
+       # buf2                  = {buffer field home south {clubName=club,playerNr=3 } & pos={px=scale 0.12 field.flength, py=scale  0.08 field.fwidth}}\r
+       # buf3                  = {buffer field home north {clubName=club,playerNr=4 } & pos={px=scale 0.06 field.flength, py=scale  0.00 field.fwidth}}\r
+       # buf4                  = {buffer field home south {clubName=club,playerNr=5 } & pos={px=scale 0.11 field.flength, py=scale -0.20 field.fwidth}}\r
+       # buf5                  = {buffer field home north {clubName=club,playerNr=6 } & pos={px=scale 0.12 field.flength, py=scale  0.20 field.fwidth}}\r
+       # buf6                  = {buffer field home south {clubName=club,playerNr=7 } & pos={px=scale 0.13 field.flength, py=scale  0.00 field.fwidth}}\r
+       # buf7                  = {buffer field home south {clubName=club,playerNr=8 } & pos={px=scale 0.10 field.flength, py=scale -0.19 field.fwidth}}\r
+       # buf8                  = {buffer field home north {clubName=club,playerNr=9 } & pos={px=scale 0.15 field.flength, py=scale  0.07 field.fwidth}}\r
+       # buf9                  = {buffer field home north {clubName=club,playerNr=10} & pos={px=scale 0.05 field.flength, py=scale -0.08 field.fwidth}}\r
+       # buf10                 = {buffer field home south {clubName=club,playerNr=11} & pos={px=scale 0.15 field.flength, py=scale  0.22 field.fwidth}}\r
+       # buf11                 = {buffer field home north {clubName=club,playerNr=12} & pos={px=scale 0.08 field.flength, py=scale -0.14 field.fwidth}}\r
+       # fielders              = [buf1,buf2,buf3,buf4,buf5,buf6,buf7,buf8,buf9,buf10,buf11]\r
+       | home == East  = fielders\r
+       | otherwise             = mirror field fielders\r
+where\r
+       (south,north)   = if (home == West) (North,South) (South,North)\r
+               \r
+tagName :: !Footballer -> Footballer\r
+tagName fb=:{playerID,name}    = {Footballer | fb & name = name <+++ "_" <+++ playerID.playerNr}\r
diff --git a/src/StdTeam/Team_Opponent_Keeper_Assignment.dcl b/src/StdTeam/Team_Opponent_Keeper_Assignment.dcl
new file mode 100644 (file)
index 0000000..e187581
--- /dev/null
@@ -0,0 +1,10 @@
+definition module Team_Opponent_Keeper_Assignment\r
+\r
+/**    Team_Opponent_Keeper creates a team of opponents that can be used to train a keeper.\r
+       The base name of that team is base_TeamName_Opponent_Keeper.\r
+*/\r
+\r
+import Team\r
+\r
+Team_Opponent_Keeper                   :: !Home FootballField -> Team\r
+base_TeamName_Opponent_Keeper  :: String\r
diff --git a/src/StdTeam/Team_Opponent_Keeper_Assignment.icl b/src/StdTeam/Team_Opponent_Keeper_Assignment.icl
new file mode 100644 (file)
index 0000000..7551174
--- /dev/null
@@ -0,0 +1,39 @@
+implementation module Team_Opponent_Keeper_Assignment\r
+\r
+import Team\r
+from   KeeperChallenger import keeperChallenger\r
+\r
+Team_Opponent_Keeper :: !Home FootballField -> Team\r
+Team_Opponent_Keeper home field\r
+                                       = getFielders club home field\r
+where\r
+       club                    = base_TeamName_Opponent_Keeper +++ if (home==West) "_W" "_E"\r
+\r
+base_TeamName_Opponent_Keeper :: String\r
+base_TeamName_Opponent_Keeper = "Opp_Keeper"\r
+\r
+getFielders :: String Home FootballField -> [Footballer]\r
+getFielders club home field\r
+       # chal1                 = {keeperChallenger {clubName=club,playerNr=2} & pos   = {px=west_edge + scale 0.025 field.flength,py=scale 0.20 field.fwidth}\r
+                                                                                          , speed = {(keeperChallenger {clubName=club,playerNr=2}).speed & direction = rad (1.4*pi)}\r
+                                         }\r
+       # chal2                 = {keeperChallenger {clubName=club,playerNr=3} & pos   = {px=west_edge + scale 0.060 field.flength,py=scale 0.15 field.fwidth}}\r
+       # chal3                 = {keeperChallenger {clubName=club,playerNr=4} & pos   = {px=west_edge + scale 0.080 field.flength,py=scale 0.00 field.fwidth}\r
+                                                                                          , speed = {(keeperChallenger {clubName=club,playerNr=4}).speed & direction = rad (0.0*pi)}\r
+                                         }\r
+       # chal4                 = {keeperChallenger {clubName=club,playerNr=5} & pos   = {px=west_edge + scale 0.060 field.flength,py=scale -0.15 field.fwidth}}\r
+       # chal5                 = {keeperChallenger {clubName=club,playerNr=6} & pos   = {px=west_edge + scale 0.025 field.flength,py=scale -0.20 field.fwidth}\r
+                                                                                          , speed = {(keeperChallenger {clubName=club,playerNr=6}).speed & direction = rad (0.6*pi)}\r
+                                         }\r
+       # fielders              = [chal1,chal2,chal3,chal4,chal5]\r
+       # fielders              = map (mirrorDirection home) fielders\r
+       | home == East  = fielders\r
+       | otherwise             = mirror field fielders\r
+where\r
+       west_edge               = scale -0.5 field.flength\r
+               \r
+mirrorDirection :: !Home !Footballer -> Footballer\r
+mirrorDirection home fielder\r
+       = {fielder & speed = {fielder.speed & direction = if (d > rad pi) (d - rad pi) (d + rad pi)}}\r
+where\r
+       d                               = fielder.speed.direction\r
diff --git a/src/StdTeam/Team_Opponent_Passing_Assignment.dcl b/src/StdTeam/Team_Opponent_Passing_Assignment.dcl
new file mode 100644 (file)
index 0000000..a268f19
--- /dev/null
@@ -0,0 +1,10 @@
+definition module Team_Opponent_Passing_Assignment\r
+\r
+/**    Team_Opponent_Passing creates a team of opponents to be used in the passing assignment.\r
+       The base name of that team is base_TeamName_Opponent_Passing.\r
+*/\r
+\r
+import Team\r
+\r
+Team_Opponent_Passing                  :: !Home FootballField -> Team\r
+base_TeamName_Opponent_Passing :: String\r
diff --git a/src/StdTeam/Team_Opponent_Passing_Assignment.icl b/src/StdTeam/Team_Opponent_Passing_Assignment.icl
new file mode 100644 (file)
index 0000000..38907f0
--- /dev/null
@@ -0,0 +1,12 @@
+implementation module Team_Opponent_Passing_Assignment\r
+\r
+import Footballer\r
+\r
+Team_Opponent_Passing :: !Home FootballField -> Team\r
+Team_Opponent_Passing home field\r
+                       = [defaultFootballer {clubName=club,playerNr=2}]\r
+where\r
+       club    = base_TeamName_Opponent_Passing +++ if (home == West) "_W" "_E"\r
+\r
+base_TeamName_Opponent_Passing :: String\r
+base_TeamName_Opponent_Passing = "Opp_Passing"\r
diff --git a/src/StdTeam/Team_Opponent_Slalom_Assignment.dcl b/src/StdTeam/Team_Opponent_Slalom_Assignment.dcl
new file mode 100644 (file)
index 0000000..cc14ce4
--- /dev/null
@@ -0,0 +1,10 @@
+definition module Team_Opponent_Slalom_Assignment\r
+\r
+/**    Team_Opponent_Slalom creates a team of opponents to be used in the slalom assignment.\r
+       The base name of that team is base_TeamName_Opponent_Slalom.\r
+*/\r
+\r
+import Team\r
+\r
+Team_Opponent_Slalom                   :: !Home FootballField -> Team\r
+base_TeamName_Opponent_Slalom  :: String\r
diff --git a/src/StdTeam/Team_Opponent_Slalom_Assignment.icl b/src/StdTeam/Team_Opponent_Slalom_Assignment.icl
new file mode 100644 (file)
index 0000000..c193d11
--- /dev/null
@@ -0,0 +1,21 @@
+implementation module Team_Opponent_Slalom_Assignment\r
+\r
+import StdReal\r
+import Footballer\r
+\r
+Team_Opponent_Slalom :: !Home FootballField -> Team\r
+Team_Opponent_Slalom home field\r
+                               = if (home == West) dummies (mirror field dummies)\r
+where\r
+       club            = base_TeamName_Opponent_Slalom +++ if (home == West) "_W" "_E"\r
+       keeper          = Nothing\r
+       dummies         = [dummy1,dummy2,dummy3,dummy4,dummy5]\r
+       dummy1          = {defaultFootballer {clubName=club,playerNr=2} & pos={zero & px = west_edge + scale 0.09 field.flength}}\r
+       dummy2          = {defaultFootballer {clubName=club,playerNr=3} & pos={zero & px = west_edge + scale 0.19 field.flength}}\r
+       dummy3          = {defaultFootballer {clubName=club,playerNr=4} & pos={zero & px = west_edge + scale 0.24 field.flength}}\r
+       dummy4          = {defaultFootballer {clubName=club,playerNr=5} & pos={zero & px =             scale 0.11 field.flength}}\r
+       dummy5          = {defaultFootballer {clubName=club,playerNr=6} & pos={zero & px =             scale 0.15 field.flength}}\r
+       west_edge       = scale -0.5 field.flength\r
+\r
+base_TeamName_Opponent_Slalom :: String\r
+base_TeamName_Opponent_Slalom = "Opp_Slalom"\r
diff --git a/src/StdTeam/Team_Student_DeepPass_Assignment.dcl b/src/StdTeam/Team_Student_DeepPass_Assignment.dcl
new file mode 100644 (file)
index 0000000..455aba6
--- /dev/null
@@ -0,0 +1,13 @@
+definition module Team_Student_DeepPass_Assignment\r
+\r
+/**    This module is supposed to implement a solution to the deep passing assignment.\r
+       For testing purposes, use the RefereeCoach_DeepPass_assignment referee and\r
+       Team_Opponent_Pass_Assignment opponent team.\r
+       \r
+       Further instructions are in the .icl module (press Ctrl+/).\r
+*/\r
+\r
+import Team\r
+\r
+Team_Student_DeepPass                  :: !Home FootballField -> Team\r
+base_TeamName_Student_DeepPass :: String\r
diff --git a/src/StdTeam/Team_Student_DeepPass_Assignment.icl b/src/StdTeam/Team_Student_DeepPass_Assignment.icl
new file mode 100644 (file)
index 0000000..9d735b1
--- /dev/null
@@ -0,0 +1,25 @@
+implementation module Team_Student_DeepPass_Assignment\r
+\r
+/**    Implement a solution to the deep passing assignment.\r
+\r
+       Your team consists of two players, with player's numbers 2 and 3 respectively.\r
+       Below you should only change the definition of footballer to your solution.\r
+       Do not change the positions and player identifications. \r
+       Do not change the implementation of base_TeamName_Student_DeepPass.\r
+*/\r
+\r
+import Footballer\r
+\r
+Team_Student_DeepPass :: !Home FootballField -> Team\r
+Team_Student_DeepPass home field       = if (home == West) team (mirror field team)\r
+where\r
+       team                                                    = [  {footballer {clubName=club,playerNr=nr} & pos = toPosition (scale (0.5*x) field.flength,scale (0.5*y) field.fwidth)}\r
+                                                                         \\ (x,y) <- positions\r
+                                                                          & nr    <- [2,3]\r
+                                                                         ]\r
+       club                                                    = base_TeamName_Student_DeepPass +++ if (home==West) "_W" "_E"\r
+       positions                                               = [(0.05,-0.05),(0.35,0.05)]\r
+       footballer playerID                             = defaultFootballer playerID            // implement your footballer here\r
+\r
+base_TeamName_Student_DeepPass :: String\r
+base_TeamName_Student_DeepPass = "Student Deep Pass"\r
diff --git a/src/StdTeam/Team_Student_Keeper_Assignment.dcl b/src/StdTeam/Team_Student_Keeper_Assignment.dcl
new file mode 100644 (file)
index 0000000..a3e89ed
--- /dev/null
@@ -0,0 +1,13 @@
+definition module Team_Student_Keeper_Assignment\r
+\r
+/**    This module is supposed to implement a solution to the keeper assignment.\r
+       For testing purposes, use the RefereeCoach_Keeper_Assignment referee and\r
+       Team_Opponent_Keeper_Assignment opponent team.\r
+       \r
+       Further instructions are in the .icl module (press Ctrl+/).\r
+*/\r
+\r
+import Team\r
+\r
+Team_Student_Keeper                            :: !Home FootballField -> Team\r
+base_TeamName_Student_Keeper   :: String\r
diff --git a/src/StdTeam/Team_Student_Keeper_Assignment.icl b/src/StdTeam/Team_Student_Keeper_Assignment.icl
new file mode 100644 (file)
index 0000000..13e8459
--- /dev/null
@@ -0,0 +1,22 @@
+implementation module Team_Student_Keeper_Assignment\r
+\r
+/**    Implement a solution to the keeper assignment.\r
+\r
+       Your team consists of a single keeper, with player's number 1.\r
+       Below you should only change the definition of footballer to your solution.\r
+       Do not change the positions and player identifications. \r
+       Do not change the implementation of base_TeamName_Student_Keeper.\r
+*/\r
+\r
+import Footballer\r
+\r
+Team_Student_Keeper                            :: !Home FootballField -> Team\r
+Team_Student_Keeper home field = if (home == West) team (mirror field team)\r
+where\r
+       team                                            = [{footballer {clubName=club,playerNr=1} & pos = {zero & px = scale -0.485 field.flength}}]\r
+       club                                            = base_TeamName_Student_Keeper +++ if (home == West) "_W" "_E"\r
+       footballer playerID                     = defaultFootballer playerID            // implement your footballer here\r
+\r
+base_TeamName_Student_Keeper   :: String\r
+base_TeamName_Student_Keeper   = "Student Keeper"\r
+\r
diff --git a/src/StdTeam/Team_Student_Passing_Assignment.dcl b/src/StdTeam/Team_Student_Passing_Assignment.dcl
new file mode 100644 (file)
index 0000000..c8bb7a0
--- /dev/null
@@ -0,0 +1,13 @@
+definition module Team_Student_Passing_Assignment\r
+\r
+/**    This module is supposed to implement a solution to the passing assignment.\r
+       For testing purposes, use the RefereeCoach_Passing_Assignment referee and\r
+       Team_Opponent_Passing_Assignment opponent team.\r
+       \r
+       Further instructions are in the .icl module (press Ctrl+/).\r
+*/\r
+\r
+import Team\r
+\r
+Team_Student_Passing                   :: !Home FootballField -> Team\r
+base_TeamName_Student_Passing  :: String\r
diff --git a/src/StdTeam/Team_Student_Passing_Assignment.icl b/src/StdTeam/Team_Student_Passing_Assignment.icl
new file mode 100644 (file)
index 0000000..ce8f846
--- /dev/null
@@ -0,0 +1,33 @@
+implementation module Team_Student_Passing_Assignment\r
+\r
+/**    Implement a solution to the passing assignment.\r
+\r
+       Your team consists of six players, with player's numbers 2 upto 7.\r
+       Below you should only change the definition of footballer to your solution.\r
+       Do not change the positions, player identifications, nor noses. \r
+       Do not change the implementation of base_TeamName_Student_Passing.\r
+*/\r
+\r
+import Footballer\r
+\r
+Team_Student_Passing :: !Home FootballField -> Team\r
+Team_Student_Passing home field        = if (home == West) team (mirror field team)\r
+where\r
+       team                                            = [  {footballer {clubName=club,playerNr=nr} & pos = toPosition (scale (0.5*x) field.flength,scale (0.5*y) field.fwidth),nose = rad (dir*pi)}\r
+                                                                 \\ (x,y) <- positions\r
+                                                                  & nr    <- [2..]\r
+                                                                  & dir   <- noses\r
+                                                                 ]\r
+       club                                            = base_TeamName_Student_Passing +++ if (home==West) "_W" "_E"\r
+       positions                                       = [(-0.43, 0.00)\r
+                                                                 ,(-0.35, 0.30)\r
+                                                                 ,( 0.00,-0.10)\r
+                                                                 ,( 0.15, 0.20)\r
+                                                                 ,( 0.32, 0.10)\r
+                                                                 ,( 0.43,-0.05)\r
+                                                                 ]\r
+       noses                                           = [1.8,0.0,1.5,0.5,1.2,0.2]\r
+       footballer playerID                     = defaultFootballer playerID            // implement your footballer here\r
+\r
+base_TeamName_Student_Passing :: String\r
+base_TeamName_Student_Passing = "Student Passing"\r
diff --git a/src/StdTeam/Team_Student_Rounds_Assignment.dcl b/src/StdTeam/Team_Student_Rounds_Assignment.dcl
new file mode 100644 (file)
index 0000000..07ee5d5
--- /dev/null
@@ -0,0 +1,13 @@
+definition module Team_Student_Rounds_Assignment\r
+\r
+/**    This module is supposed to implement a solution to the rounds running assignment.\r
+       For testing purposes, use the RefereeCoach_Rounds_Assignment referee.\r
+       Your opponent can also be the Team_Student_Rounds_Assignment.\r
+       \r
+       Further instructions are in the .icl module (press Ctrl+/).\r
+*/\r
+\r
+import Team\r
+\r
+Team_Student_Rounds                    :: !Home !FootballField -> Team\r
+base_TeamName_Student_Rounds   :: String\r
diff --git a/src/StdTeam/Team_Student_Rounds_Assignment.icl b/src/StdTeam/Team_Student_Rounds_Assignment.icl
new file mode 100644 (file)
index 0000000..8c0e333
--- /dev/null
@@ -0,0 +1,24 @@
+implementation module Team_Student_Rounds_Assignment\r
+\r
+/** Implement a solution to the rounds running assignment.\r
+\r
+       Your team consists of one player.\r
+       Below you only need to change the definition of footballer to your solution.\r
+       Do not change the position and player identification.\r
+       Do not change the implementation of base_TeamName_Student_Rounds.\r
+*/\r
+import Footballer\r
+\r
+Team_Student_Rounds :: !Home !FootballField -> Team\r
+Team_Student_Rounds home field         = if (home == West) team (mirror field team)\r
+where\r
+       team                                                    = [  {footballer {clubName=club,playerNr=nr} & pos = toPosition (scale x field.flength,scale y field.fwidth)}\r
+                                                                         \\ (x,y) <- positions\r
+                                                                          & nr    <- [2..]\r
+                                                                         ]\r
+       club                                                    = base_TeamName_Student_Rounds +++ if (home==West) "_W" "_E"\r
+       positions                                               = [(-0.49,0.00)]\r
+       footballer playerID                             = defaultFootballer playerID            // implement your footballer here\r
+\r
+base_TeamName_Student_Rounds :: String\r
+base_TeamName_Student_Rounds = "Student Rounds"\r
diff --git a/src/StdTeam/Team_Student_Slalom_Assignment.dcl b/src/StdTeam/Team_Student_Slalom_Assignment.dcl
new file mode 100644 (file)
index 0000000..64f442f
--- /dev/null
@@ -0,0 +1,12 @@
+definition module Team_Student_Slalom_Assignment\r
+\r
+/**    This module is supposed to implement a solution to the slalom assignment.\r
+       For testing purposes, use the RefereeCoach_Slalom_Assignment referee and\r
+       Team_Opponent_Slalom_Assignment opponent team.\r
+       \r
+       Further instructions are in the .icl module (press Ctrl+/).\r
+*/\r
+import Team\r
+\r
+Team_Student_Slalom                            :: !Home FootballField -> Team\r
+base_TeamName_Student_Slalom   :: String\r
diff --git a/src/StdTeam/Team_Student_Slalom_Assignment.icl b/src/StdTeam/Team_Student_Slalom_Assignment.icl
new file mode 100644 (file)
index 0000000..a77671d
--- /dev/null
@@ -0,0 +1,23 @@
+implementation module Team_Student_Slalom_Assignment\r
+\r
+/**    Implement a solution to the slalom assignment.\r
+\r
+       Your team consists of one field player, with player's number 2.\r
+       Below you should only change the definition of footballer to your solution.\r
+       Do not change the position and player identification. \r
+       Do not change the implementation of base_TeamName_Student_Slalom.\r
+*/\r
+\r
+import Footballer\r
+import FootballerFunctions\r
+\r
+Team_Student_Slalom :: !Home FootballField -> Team\r
+Team_Student_Slalom home field = team\r
+where\r
+       team                                            = [{footballer {clubName=club,playerNr=2} & pos = if (home == West) position (mirror field position)}]\r
+       club                                            = base_TeamName_Student_Slalom +++ if (home == West) "_W" "_E"\r
+       position                                        = {zero & px = scale -0.5 field.flength + penalty_area_depth}\r
+       footballer player_id            = defaultFootballer player_id   // implement your footballer here\r
+\r
+base_TeamName_Student_Slalom :: String\r
+base_TeamName_Student_Slalom   = "Student Slalom"\r
diff --git a/src/afbeeldingen/AmsterdamArenA.bmp b/src/afbeeldingen/AmsterdamArenA.bmp
new file mode 100644 (file)
index 0000000..5833760
Binary files /dev/null and b/src/afbeeldingen/AmsterdamArenA.bmp differ
diff --git a/src/afbeeldingen/Thumbs.db b/src/afbeeldingen/Thumbs.db
new file mode 100644 (file)
index 0000000..42778ae
Binary files /dev/null and b/src/afbeeldingen/Thumbs.db differ
diff --git a/src/afbeeldingen/hands.bmp b/src/afbeeldingen/hands.bmp
new file mode 100644 (file)
index 0000000..e52144b
Binary files /dev/null and b/src/afbeeldingen/hands.bmp differ
diff --git a/src/afbeeldingen/ivanov_badluck.bmp b/src/afbeeldingen/ivanov_badluck.bmp
new file mode 100644 (file)
index 0000000..d2d316c
Binary files /dev/null and b/src/afbeeldingen/ivanov_badluck.bmp differ
diff --git a/src/afbeeldingen/ivanov_fluit.bmp b/src/afbeeldingen/ivanov_fluit.bmp
new file mode 100644 (file)
index 0000000..0707e3b
Binary files /dev/null and b/src/afbeeldingen/ivanov_fluit.bmp differ
diff --git a/src/afbeeldingen/ivanov_look.bmp b/src/afbeeldingen/ivanov_look.bmp
new file mode 100644 (file)
index 0000000..d0542c2
Binary files /dev/null and b/src/afbeeldingen/ivanov_look.bmp differ
diff --git a/src/afbeeldingen/ivanov_red.bmp b/src/afbeeldingen/ivanov_red.bmp
new file mode 100644 (file)
index 0000000..a525b52
Binary files /dev/null and b/src/afbeeldingen/ivanov_red.bmp differ
diff --git a/src/afbeeldingen/ivanov_theater.bmp b/src/afbeeldingen/ivanov_theater.bmp
new file mode 100644 (file)
index 0000000..e4dd3c7
Binary files /dev/null and b/src/afbeeldingen/ivanov_theater.bmp differ
diff --git a/src/afbeeldingen/ivanov_warning.bmp b/src/afbeeldingen/ivanov_warning.bmp
new file mode 100644 (file)
index 0000000..c9ed917
Binary files /dev/null and b/src/afbeeldingen/ivanov_warning.bmp differ
diff --git a/src/afbeeldingen/ivanov_wijst_links.bmp b/src/afbeeldingen/ivanov_wijst_links.bmp
new file mode 100644 (file)
index 0000000..9be93cb
Binary files /dev/null and b/src/afbeeldingen/ivanov_wijst_links.bmp differ
diff --git a/src/afbeeldingen/ivanov_wijst_rechts.bmp b/src/afbeeldingen/ivanov_wijst_rechts.bmp
new file mode 100644 (file)
index 0000000..bb89aa4
Binary files /dev/null and b/src/afbeeldingen/ivanov_wijst_rechts.bmp differ
diff --git a/src/afbeeldingen/ivanov_yellow.bmp b/src/afbeeldingen/ivanov_yellow.bmp
new file mode 100644 (file)
index 0000000..392c51c
Binary files /dev/null and b/src/afbeeldingen/ivanov_yellow.bmp differ
diff --git a/src/sound/CenterKick.wav b/src/sound/CenterKick.wav
new file mode 100644 (file)
index 0000000..8b7b781
Binary files /dev/null and b/src/sound/CenterKick.wav differ
diff --git a/src/sound/ballOut.wav b/src/sound/ballOut.wav
new file mode 100644 (file)
index 0000000..f4fdf59
Binary files /dev/null and b/src/sound/ballOut.wav differ
diff --git a/src/sound/callToTossCoin.wav b/src/sound/callToTossCoin.wav
new file mode 100644 (file)
index 0000000..004b459
Binary files /dev/null and b/src/sound/callToTossCoin.wav differ
diff --git a/src/sound/endGameOrHalf.wav b/src/sound/endGameOrHalf.wav
new file mode 100644 (file)
index 0000000..e380d0b
Binary files /dev/null and b/src/sound/endGameOrHalf.wav differ
diff --git a/src/sound/offside.wav b/src/sound/offside.wav
new file mode 100644 (file)
index 0000000..04051b5
Binary files /dev/null and b/src/sound/offside.wav differ
diff --git a/src/sound/stopBecauseOfFoul.wav b/src/sound/stopBecauseOfFoul.wav
new file mode 100644 (file)
index 0000000..26beedc
Binary files /dev/null and b/src/sound/stopBecauseOfFoul.wav differ
diff --git a/src/sound/tackles_ed.wav b/src/sound/tackles_ed.wav
new file mode 100644 (file)
index 0000000..4e376a0
Binary files /dev/null and b/src/sound/tackles_ed.wav differ
diff --git a/src/sound/wrongPosition2restartFrom.wav b/src/sound/wrongPosition2restartFrom.wav
new file mode 100644 (file)
index 0000000..acdd9cc
Binary files /dev/null and b/src/sound/wrongPosition2restartFrom.wav differ