(DEFINE-FILE-INFO PACKAGE "IL" READTABLE "INTERLISP" BASE 10)
(FILECREATED "11-May-93 16:22:08" {DSK}<usr>local>lde>loops>system>TRUCKINP.;2 12564  

      previous date%: "17-Dec-87 08:28:32" 
|{POGO:AISNORTH:XEROX}<LOOPSCORE>LYRIC>USERS>TRUCKIN>TRUCKINP.;3|)


(* ; "
Copyright (c) 1985, 1987, 1993 by Xerox Corporation.  All rights reserved.
")

(PRETTYCOMPRINT TRUCKINPCOMS)

(RPAQQ TRUCKINPCOMS
       ((DECLARE%: DONTCOPY (PROP MAKEFILE-ENVIRONMENT TRUCKINP))
                                                             (* ; 
                                                         "Copyright (c) 1983 by Xerox Corporation.")
        
        (* ;; "Generic Players and Trucks for the TRUCKIN game. TRUCKIN is a mini-expert system for teaching knowledge representation techniques in the Loops programming system. Truckin provides a simple simulation environment for novice Loops users in which small bodies of knowledge can be created and tested interactively. Knowledge in Truckin is in the form of rules for controlling a game piece to maximize profit.")

                                                             (* ; 
     "Written in January 1983 by the Loops Group -- Daniel Bobrow, Sanjay Mittal, and Mark Stefik.")
                                                             (* ; 
                               "System classes for Players. Includes an interactive manual player.")
        (CLASSES * TRUCKINPCLASSES)
        (VARS * TRUCKINPVARS)
                                                             (* ; "Kinds of Trucks.")
        (CLASSES * Trucks)
                                                             (* ; "Bandit Classes")
        (CLASSES * BANDITCLASSES)
                                                             (* ; "Lisp Fns.")
        (FNS * TRUCKINPFNS)
        (METHODS Bandit.CanBuy Bandit.NewInstance Bandit.SelectTruck BanditCar.VisitUnionHall 
               BanditCarMeta.New GasPlayer.NewInstance GasPlayer.SelectTruck 
               InteractivePlayer.Interact InteractivePlayer.PositionWindow InteractivePlayer.TakeTurn
               Player.Buyers Player.CheckTruck Player.NewInstance Player.RemovePlayer 
               Player.SelectTruck Player.SetUpGauges Player.Show Player.StartGame Player.Summarize 
               Player.TakeTurn PlayerMeta.TurnOff PlayerMeta.TurnOn RemotePlayer.NewInstance 
               RemotePlayer.Summarize SystemPlayer.CanBuy SystemPlayer.CanBuyFuel 
               SystemPlayer.CheckTruck SystemPlayer.Initialize SystemPlayer.MakeIcon 
               SystemPlayer.MakeIcons SystemPlayer.NewInstance SystemPlayer.SetUpPlayer)))
(DECLARE%: DONTCOPY 

(PUTPROPS TRUCKINP MAKEFILE-ENVIRONMENT (:PACKAGE "IL" :READTABLE "INTERLISP" :BASE 10))
)



(* ; "Copyright (c) 1983 by Xerox Corporation.")




(* ;; 
"Generic Players and Trucks for the TRUCKIN game. TRUCKIN is a mini-expert system for teaching knowledge representation techniques in the Loops programming system. Truckin provides a simple simulation environment for novice Loops users in which small bodies of knowledge can be created and tested interactively. Knowledge in Truckin is in the form of rules for controlling a game piece to maximize profit."
)




(* ; "Written in January 1983 by the Loops Group -- Daniel Bobrow, Sanjay Mittal, and Mark Stefik.")




(* ; "System classes for Players. Includes an interactive manual player.")


(RPAQQ TRUCKINPCLASSES (GasPlayer InteractivePlayer Player PlayerMeta RemotePlayer SystemPlayer))

(DEFCLASSES GasPlayer InteractivePlayer Player PlayerMeta RemotePlayer SystemPlayer)
(DEFCLASS GasPlayer
   (MetaClass GameClass doc "SystemPlayer used to refresh qty at GasStations." Edited%: 
                                                             (* sm%: "28-JUN-83 14:14"))
   (Supers SystemPlayer))

(DEFCLASS InteractivePlayer
   (MetaClass PlayerMeta doc "Specialization of Player used for debugging. Pops up an interactive window for getting the Player moves directly from the the mouse instead of using knowledge encoded in rules."
          Edited%:                                       (* sm%: " 5-JUL-83 18:47"))
   (Supers Player)
   (ClassVariables (UnChangedIVs (name driver truck icon reverseIcon window x y)
                          doc "list of IVs not to be changed")
          (Handicap 600000 doc "Free time allowed to compensate for slowness"))
   (InstanceVariables (window NIL doc "Window in which User interaction takes place." dontSave Value)
          (x NIL doc "x Origin of interaction window")
          (y NIL doc "y Origin of interaction window.")))

(DEFCLASS Player
   (MetaClass PlayerMeta doc "Participant in the Truckin Simulation." Edited%: 
                                                             (* sm%: "16-SEP-83 15:42"))
   (Supers SystemPlayer)
   (ClassVariables (Handicap 0 doc "Free time allowed to compensate for slowness"))
   (InstanceVariables (timeUsed 0 DefaultGauge LCD doc "total time used so far")
          (movesMade 0 DefaultGauge LCD doc "actual number of moves made. Used by TimeGameMaster")
          (pendingRequest NIL inProcess NIL whenSent 0 doc "pending request. inProcess - is the request already sent to Master for processing. whenSent - time when process sent in IDATE form"
                 )
          (maxMove 0 doc "maxMove that can be made in current attempt")
          (processHandle NIL doc "process handle for the player's UserProcess")
          (startedAt 0 doc "CLOCK time when player process was last started")
          (unchargedTime 0 doc "time not charged for in a given move")
          (wakeReason NIL doc "value to be returned when player process is resumed")
          (staySuspend NIL doc "set to T when player suspended pending request completion")
          (schCount 0 doc "number of times player was scheduled")
          (remoteMachine NIL doc "name of mc on which running")))

(DEFCLASS PlayerMeta
   (MetaClass GameMetaClass doc 
          "MetaClass for Player. Provides interactive method for defining new players." Edited%: 
                                                             (* mjs%: "16-MAR-83 16:19"))
   (Supers GameClass))

(DEFCLASS RemotePlayer
   (MetaClass PlayerMeta Edited%:                        (* sm%: "29-JUN-83 12:49")
          doc "Used for players which are running on a separate machine but simulated on this m/c")
   (Supers Player)
   (ClassVariables (CopyCV NIL)
          (UnChangedIVs #,($A (realClass) UnionSuperValue NIL) doc "list of IVs not to be changed"))
   (InstanceVariables (realClass NIL doc "name of real player class")))

(DEFCLASS SystemPlayer
   (MetaClass GameAbstractClass Edited%:                 (* dgb%: "14-JUL-83 18:24"))
   (Supers GameObject)
   (ClassVariables (UnChangedIVs (name driver truck icon reverseIcon)
                          doc "list of IVs not to be changed")
          (Width 35 doc "Width of a player icon in pixels.")
          (Height 25 doc "Height of a player icon in pixels."))
   (InstanceVariables (truck NIL doc "Truck object used by player.")
          (reverseIcon NIL doc "Cache for BitMap for player's truck going backwards.")
          (icon NIL doc "Cache for BitMap containing icon for player's truck as well as player's name. Created by MakeIcon msg."
                )
          (driver "Name1" doc 
           "String name to appear with the truck on the first line on the board. Six chars or fewer."
                 )
          (maxMove 0)
          (movesMade 0 doc "number of MoveMade msgs received for player")))


(RPAQQ TRUCKINPVARS (RemotePlayerGaugeFlg (interactiveGameMenu NIL)))

(RPAQQ RemotePlayerGaugeFlg NIL)

(RPAQQ interactiveGameMenu NIL)



(* ; "Kinds of Trucks.")


(RPAQQ Trucks (MacTruck GMCTruck GasTruck FordTruck PeterBiltTruck))

(DEFCLASSES MacTruck GMCTruck GasTruck FordTruck PeterBiltTruck)
(DEFCLASS MacTruck
   (MetaClass GameClass doc "Good Workhorse truck. Medium in range, weight, and speed." Edited%: 
                                                             (* sm%: "21-FEB-83 15:56"))
   (Supers Truck)
   (ClassVariables (InitCash 10000)
          (Icon MacTruckIcon)
          (Gpm 2)
          (MaxDist 30)
          (MaxWeight 2000)
          (MaxVolume 2000)
          (MaxFuel 160)))

(DEFCLASS GMCTruck
   (MetaClass GameClass doc "GMC is a big fast mover, but spends a lot on fuel." Edited%: 
                                                             (* sm%: "21-FEB-83 15:56"))
   (Supers Truck)
   (ClassVariables (InitCash 10000)
          (Icon GMCTruckIcon)
          (Gpm 3)
          (MaxDist 24)
          (MaxWeight 4000)
          (MaxVolume 2000)
          (MaxFuel 240)))

(DEFCLASS GasTruck
   (MetaClass Class doc "Truck used by Gas Player." Edited%: 
                                                             (* mjs%: "16-MAR-83 14:45"))
   (Supers SystemTruck)
   (ClassVariables (Icon GasTruckIcon)))

(DEFCLASS FordTruck
   (MetaClass GameClass doc 
          "Ford is a good lightweight truck. Fast with high mileage, but a low capacity." Edited%: 
                                                             (* sm%: "14-FEB-83 08:46"))
   (Supers Truck)
   (ClassVariables (InitCash 10000)
          (Icon FordTruckIcon)
          (Gpm 1)
          (MaxDist 50)
          (MaxWeight 500)
          (MaxVolume 500)
          (MaxFuel 80)))

(DEFCLASS PeterBiltTruck
   (MetaClass GameClass doc 
          "PeterBilt is a good heavy long distance mover, with an efficient engine. But he is slow."
          Edited%:                                       (* smL "19-Dec-85 18:10"))
   (Supers Truck)
   (ClassVariables (Icon PeterBiltTruckIcon)
          (Gpm 4)
          (MaxDist 15)
          (MaxWeight 5000)
          (MaxVolume 5000)
          (MaxFuel 320)))




(* ; "Bandit Classes")


(RPAQQ BANDITCLASSES (BanditCarMeta BanditCar Bandit))

(DEFCLASSES BanditCarMeta BanditCar Bandit)
(DEFCLASS BanditCarMeta
   (MetaClass GameMetaClass Edited%:                     (* sm%: "26-JAN-83 16:38"))
   (Supers GameClass))

(DEFCLASS BanditCar
   (MetaClass BanditCarMeta Edited%:                     (* sm%: " 7-JUN-83 14:18"))
   (Supers SystemTruck)
   (ClassVariables (CopyCV (InitCash MaxFuel MaxVolume MaxWeight MaxDamage MaxDist Gpm Icon))
          (Icon BlackMariaIcon)
          (Gpm 1)
          (MaxDist 100)
          (MaxDamage 100)
          (MaxWeight 1000)
          (MaxVolume 1000)
          (MaxFuel 10000)
          (InitCash 0)))

(DEFCLASS Bandit
   (MetaClass GameClass Edited%:                         (* sm%: "28-JUN-83 14:07"))
   (Supers SystemPlayer Consumer)
   (ClassVariables (CopyCV (Pr Qty Commodity))
          (Commodity Commodity)
          (Qty 100)
          (Pr 0.0))
   (InstanceVariables (pr 0.0)
          (qty 100)
          (driver Capone)
          (direction F doc "direction in which bandit is moving")))




(* ; "Lisp Fns.")


(RPAQQ TRUCKINPFNS (FindPlayer ListPlayers REPlayer))
(DEFINEQ

(FindPlayer
  [LAMBDA (playerName)                                   (* dgb%: " 1-FEB-83 11:00")
    (for player in (@ gameMaster players) do (COND
                                                            ((EQ playerName (@ player driver))
                                                             (RETURN player])

(ListPlayers
  [LAMBDA NIL                                            (* dgb%: " 1-FEB-83 12:38")
    (for player in (@ gameMaster players) collect (@ player driver)])

(REPlayer
  [LAMBDA (name)                                         (* dgb%: " 1-FEB-83 12:38")
    (PROG (player (playerName name))
          (COND
             ((NULL playerName)
              (GO ASK)))
      LP  [COND
             ((NULL (SETQ player (FindPlayer playerName)))
              (WRITE "Players must be one of: " (ListPlayers)))
             (T (RETURN (REObject player]
      ASK (COND
             ((EQ NIL (SETQ playerName (INTTY 
                                       "What is the name of the driver
of the truck to be examined? " NIL "Name of driver of truck" T)))
              (WRITE "Returning.")
              (RETURN)))
          (GO LP])
)

(\BatchMethodDefs)

(\UnbatchMethodDefs)
(PUTPROPS TRUCKINP COPYRIGHT ("Xerox Corporation" 1985 1987 1993))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (11197 12432 (FindPlayer 11207 . 11551) (ListPlayers 11553 . 11744) (REPlayer 11746 . 
12430)))))
STOP
