(FILECREATED "26-Mar-85 19:36:17" {INDIGO}<LOOPS>SOURCES>TRUCKIN>TRUCKINM.;2 210137 changes to: (METHODS TruckinBoard.DrawRoadMarks) (FNS TruckinBoard.DrawRoadMarks) previous date: "14-Jan-85 17:06:54" {INDIGO}<LOOPS>SOURCES>TRUCKIN>TRUCKINM.;1) (* Copyright (c) 1985 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT TRUCKINMCOMS) (RPAQQ TRUCKINMCOMS ((* Copyright (c) 1983 Xerox Corporation) (* Classes for MultiMachineTruckin Knowledge System) (* Programmed by LoopsDesignTeam in June 1983.0 Maintained by Sanjay Mittal) (* This version of Truckin supersedes the older versions) (CLASSES BWTruckin ColorTruckin DisplayTruckinS GameCommInterface GameDecisionMaker GamePlayerInterface GameSimulator MainCommInterface MasterTruckin MoveTruckinDM MoveTruckinPI NoDisplayTruckinS RemoteMasterComm RemoteSlaveComm SlaveTruckin TimeTruckinDM TimeTruckinPI Truckin TruckinBoard TruckinCommInterface TruckinDecisionMaker TruckinPlayerInterface TruckinSimulator) (FNS MoveTruckinPI.BeginGame RemoteMasterComm.StartWorldProcess RemoteSlaveComm.StartWorldProcess SlaveTruckin TimeTruckinPI.BeginGame TruckinCommInterface.NewInstance) (VARS GameBrowse (GameProcRestFlg T) (PlayerProcRestFlg (QUOTE HARDRESET))) (METHODS BWTruckin.InitializeGameWindow ColorTruckin.CreateGameBoard ColorTruckin.InitializeGameWindow ColorTruckin.MakeDriveBitMaps DisplayTruckinS.NewGame DisplayTruckinS.ReUseGame GameCommInterface.NewInstance GameDecisionMaker.NewInstance GamePlayerInterface.ChangeGameParameters GamePlayerInterface.NewInstance GameSimulator.NewInstance MainCommInterface.AddBandit MainCommInterface.AddPlayer MainCommInterface.AddPlayerRequest MainCommInterface.BeginGameRequest MainCommInterface.BreakCargo MainCommInterface.BuyMade MainCommInterface.BuyRequest MainCommInterface.GameOver MainCommInterface.GasFill MainCommInterface.MaxMove MainCommInterface.MoveMade MainCommInterface.MoveRequest MainCommInterface.NewGame MainCommInterface.NewGameRequest MainCommInterface.ParkedAtAlice MainCommInterface.ReUseGame MainCommInterface.ReUseGameRequest MainCommInterface.RemovePlayer MainCommInterface.RemovePlayerRequest MainCommInterface.SellMade MainCommInterface.SellRequest MainCommInterface.SetInitialParameters MainCommInterface.SetUp MainCommInterface.SpoilCargo MainCommInterface.StartGame MainCommInterface.WorldProcess MoveTruckinDM.InitializeGameParameters MoveTruckinDM.MoveBandits MoveTruckinPI.RunGame NoDisplayTruckinS.AttachBoard NoDisplayTruckinS.DrivePlayer NoDisplayTruckinS.UpdateRS RemoteMasterComm.AddBandit RemoteMasterComm.AddPlayer RemoteMasterComm.AddPlayerRequest RemoteMasterComm.BeginGameRequest RemoteMasterComm.BreakCargo RemoteMasterComm.BuyMade RemoteMasterComm.BuyRequest RemoteMasterComm.GameOver RemoteMasterComm.GasFill RemoteMasterComm.InterimWorldProcess RemoteMasterComm.MaxMove RemoteMasterComm.MoveMade RemoteMasterComm.MoveRequest RemoteMasterComm.NewGame RemoteMasterComm.NewGameRequest RemoteMasterComm.ParkedAtAlice RemoteMasterComm.ReUseGame RemoteMasterComm.ReUseGameRequest RemoteMasterComm.RemovePlayer RemoteMasterComm.RemovePlayerRequest RemoteMasterComm.SellMade RemoteMasterComm.SellRequest RemoteMasterComm.SetInitialParameters RemoteMasterComm.SetUp RemoteMasterComm.SpoilCargo RemoteMasterComm.StartGame RemoteMasterComm.StartInterimWorldProcess RemoteMasterComm.WorldProcess RemoteSlaveComm.AddBandit RemoteSlaveComm.AddPlayer RemoteSlaveComm.AddPlayerRequest RemoteSlaveComm.BeginGameRequest RemoteSlaveComm.BreakCargo RemoteSlaveComm.BuyMade RemoteSlaveComm.BuyRequest RemoteSlaveComm.GameOver RemoteSlaveComm.GasFill RemoteSlaveComm.InterimWorldProcess RemoteSlaveComm.MaxMove RemoteSlaveComm.MoveMade RemoteSlaveComm.MoveRequest RemoteSlaveComm.NewGame RemoteSlaveComm.NewGameRequest RemoteSlaveComm.ParkedAtAlice RemoteSlaveComm.ReUseGame RemoteSlaveComm.ReUseGameRequest RemoteSlaveComm.RemovePlayer RemoteSlaveComm.RemovePlayerRequest RemoteSlaveComm.SellMade RemoteSlaveComm.SellRequest RemoteSlaveComm.SetInitialParameters RemoteSlaveComm.SetUp RemoteSlaveComm.SpoilCargo RemoteSlaveComm.StartGame RemoteSlaveComm.StartInterimWorldProcess RemoteSlaveComm.WorldProcess TimeTruckinDM.ChargeTime TimeTruckinDM.CheckAlice TimeTruckinDM.InitializeGameParameters TimeTruckinDM.MoveBandits TimeTruckinDM.RedoGameParameters TimeTruckinDM.ReplenishQty TimeTruckinPI.RunGame TruckinBoard.AssignRoadStops TruckinBoard.AttachToGame TruckinBoard.CreateGameBoard TruckinBoard.DisplayGameBoard TruckinBoard.DrawRoadMarks TruckinBoard.InitializeRoadStops TruckinBoard.MakeDriveBitMaps TruckinBoard.NewBoard TruckinBoard.PlaceRoadStops TruckinBoard.ReInitializeRoadStops TruckinBoard.ReUseBoard TruckinBoard.RemovePlayer TruckinCommInterface.CleanGameWorld TruckinCommInterface.CreateDecisionMaker TruckinCommInterface.CreateGateWay TruckinCommInterface.CreatePlayerInterface TruckinCommInterface.CreateSimulator TruckinCommInterface.SetInitialParameters TruckinCommInterface.StartWorldProcess TruckinCommInterface.TellMe TruckinDecisionMaker.AddBandit TruckinDecisionMaker.AddPlayer TruckinDecisionMaker.AddPlayerRequest TruckinDecisionMaker.AttachSimulator TruckinDecisionMaker.BeginGameRequest TruckinDecisionMaker.BuyMade TruckinDecisionMaker.BuyRequest TruckinDecisionMaker.ChangeGameParameters TruckinDecisionMaker.CheckAlice TruckinDecisionMaker.ForcedMove TruckinDecisionMaker.GameOver TruckinDecisionMaker.GiveAliceBonus TruckinDecisionMaker.InitializeGameParameters TruckinDecisionMaker.MonitorGame TruckinDecisionMaker.MonitorProcess TruckinDecisionMaker.MoveBandits TruckinDecisionMaker.MoveCheckingHazards TruckinDecisionMaker.MoveMade TruckinDecisionMaker.MoveRequest TruckinDecisionMaker.MoveTruck TruckinDecisionMaker.NewGameRequest TruckinDecisionMaker.ReUseGameRequest TruckinDecisionMaker.RedoGameParameters TruckinDecisionMaker.RemovePlayer TruckinDecisionMaker.RemovePlayerRequest TruckinDecisionMaker.ReplenishQty TruckinDecisionMaker.SellMade TruckinDecisionMaker.SellRequest TruckinDecisionMaker.StartGame TruckinDecisionMaker.StartMonitorProcess TruckinDecisionMaker.UpdateAlice TruckinPlayerInterface.AddPlayer TruckinPlayerInterface.AddPlayerRequest TruckinPlayerInterface.BeginGame TruckinPlayerInterface.Buy TruckinPlayerInterface.BuyMade TruckinPlayerInterface.ChargeTime TruckinPlayerInterface.CheckLocalPlayers TruckinPlayerInterface.ContinueGame TruckinPlayerInterface.CreatePlayerProcess TruckinPlayerInterface.DeletePlayerProcesses TruckinPlayerInterface.Move TruckinPlayerInterface.MoveMade TruckinPlayerInterface.NewGame TruckinPlayerInterface.NewGameRequest TruckinPlayerInterface.PlayerRequestComplete TruckinPlayerInterface.ReUseGame TruckinPlayerInterface.RemovePlayer TruckinPlayerInterface.RemovePlayerRequest TruckinPlayerInterface.RunNextPlayer TruckinPlayerInterface.ScheduleNextPlayer TruckinPlayerInterface.SelectPlayers TruckinPlayerInterface.Sell TruckinPlayerInterface.SellMade TruckinPlayerInterface.StartGame TruckinPlayerInterface.StartPlayerProcesses TruckinPlayerInterface.SuspendPlayer TruckinPlayerInterface.WakePlayer TruckinSimulator.AddBandit TruckinSimulator.AddPlayer TruckinSimulator.AttachBoard TruckinSimulator.BreakCargo TruckinSimulator.BuyMade TruckinSimulator.ClockProcess TruckinSimulator.DrivePlayer TruckinSimulator.GameOver TruckinSimulator.GasFill TruckinSimulator.GiveAliceBonus TruckinSimulator.Initialize TruckinSimulator.MaxMove TruckinSimulator.MoveMade TruckinSimulator.NewGame TruckinSimulator.ParkedAtAlice TruckinSimulator.ReUseGame TruckinSimulator.RedoGameParameters TruckinSimulator.RemovePlayer TruckinSimulator.SellMade TruckinSimulator.SetUpGauges TruckinSimulator.SpoilCargo TruckinSimulator.StartClockProcess TruckinSimulator.StartGame TruckinSimulator.UnattachBoard TruckinSimulator.UpdateRS TruckinSimulator.WhoWon))) (* Copyright (c) 1983 Xerox Corporation) (* Classes for MultiMachineTruckin Knowledge System) (* Programmed by LoopsDesignTeam in June 1983.0 Maintained by Sanjay Mittal) (* This version of Truckin supersedes the older versions) (DEFCLASSES BWTruckin ColorTruckin DisplayTruckinS GameCommInterface GameDecisionMaker GamePlayerInterface GameSimulator MainCommInterface MasterTruckin MoveTruckinDM MoveTruckinPI NoDisplayTruckinS RemoteMasterComm RemoteSlaveComm SlaveTruckin TimeTruckinDM TimeTruckinPI Truckin TruckinBoard TruckinCommInterface TruckinDecisionMaker TruckinPlayerInterface TruckinSimulator) [DEFCLASS BWTruckin (MetaClass GameClass Edited: (* sm: "27-JUN-83 17:31")) (Supers TruckinBoard) (ClassVariables (CopyCV NIL))] [DEFCLASS ColorTruckin (MetaClass GameClass Edited: (* sm: "27-JUN-83 17:32")) (Supers TruckinBoard) (ClassVariables (numRows 4 doc (* number of RoadStops arranged vertically on the game board.)) (numColumns 7 doc (* number of RoadStops arranged horizontally on the game board.)) (colorP T doc (* This indicates that the display will be on the color screen)) (CopyCV NIL))] [DEFCLASS DisplayTruckinS (MetaClass GameClass Edited: (* sm: "27-JUN-83 17:10")) (Supers TruckinSimulator) (ClassVariables (CopyCV (Icon)) (Icon ?))] [DEFCLASS GameCommInterface (MetaClass GameClass Edited: (* edited: "12-JUL-83 11:36") doc (* General class for Game Communications) ) (Supers GameObject) (ClassVariables (CopyCV)) (InstanceVariables (simulator NIL doc (* instance of GameSimulator)) (playerInterface NIL doc (* instance of PlayerInterface)) (broadcastList NIL doc (* list of objects which will get copies of incoming messages)) (machineID NIL doc (* unique ID for identifying different machines in the multiMC Truckin)) (worldProcess NIL doc (* handle of the WorldProcess)) (interimWP NIL doc (* handle of Interim World Process)))] [DEFCLASS GameDecisionMaker (MetaClass GameClass Edited: (* sm: "30-JUN-83 18:53") doc (* Makes all decisions in the game) ) (Supers GameObject) (ClassVariables (CopyCV)) (InstanceVariables (gameParameters DMParameters doc (* class for changing game parameters at DecisionMaker level)))] [DEFCLASS GamePlayerInterface (MetaClass GameClass Edited: (* sm: "30-JUN-83 15:34") doc (* All players's messages go to this class) ) (Supers GameObject) (ClassVariables (CopyCV)) (InstanceVariables (localPlayers NIL doc (* list of players locally connected to this interface) ) (suspendedPlayers NIL doc (* list of players suspended pending completion of their requests)))] [DEFCLASS GameSimulator (MetaClass GameClass Edited: (* sm: "27-JUN-83 15:33") doc (* Handles the game simulation and keeps the game world in sync) ) (Supers GameObject) (ClassVariables (CopyCV (Icon)) (Icon ?))] [DEFCLASS MainCommInterface (MetaClass GameClass Edited: (* sm: " 8-JUL-83 15:34")) (Supers TruckinCommInterface) (ClassVariables (CopyCV NIL)) (InstanceVariables (decisionMaker NIL DefaultClass TimeTruckinDM doc (* instance of GameDecisionMaker)) (gameStarted NIL))] [DEFCLASS MasterTruckin (MetaClass GameClass Edited: (* sm: "10-JUL-83 20:51")) (Supers RemoteMasterComm) (ClassVariables (CopyCV NIL))] [DEFCLASS MoveTruckinDM (MetaClass GameClass Edited: (* sm: "29-JUN-83 10:17")) (Supers TruckinDecisionMaker) (ClassVariables (CopyCV) (PlayerInterface MoveTruckinPI doc (* name of class of this type associated with this DecisionMaker))) (InstanceVariables (aliceStay 3 doc (* how many moves can stay at Alices)) (banditFreq 5 doc (* how often bandits move)) (numMovesRemaining 200 DefaultGauge DigiMeter GaugeLimit (0 200) GaugePos (852 . 465) SetByUser NIL doc (* number of moves remaining in the game. SetByUser is used to flag that value is not to be reinitialized)) (replenishFreq 40 doc (* how often gas is replenished)))] [DEFCLASS MoveTruckinPI (MetaClass GameClass Edited: (* sm: "29-JUN-83 10:16")) (Supers TruckinPlayerInterface) (ClassVariables (CopyCV) (DecisionMaker MoveTruckinDM doc (* name of associated DecisionMaker class) ))] [DEFCLASS NoDisplayTruckinS (MetaClass GameClass Edited: (* sm: "27-JUN-83 17:10")) (Supers TruckinSimulator) (ClassVariables (CopyCV (Icon)) (Icon ?))] [DEFCLASS RemoteMasterComm (MetaClass GameClass Edited: (* sm: " 8-JUL-83 12:16")) (Supers TruckinCommInterface) (ClassVariables (CopyCV NIL)) (InstanceVariables (decisionMaker NIL DefaultClass TimeTruckinDM doc (* instance of GameDecisionMaker)) (postman NIL DefaultClass MasterGateway doc (* instance of Master GateWay)) (gameStarted NIL))] [DEFCLASS RemoteSlaveComm (MetaClass GameClass Edited: (* sm: " 8-JUL-83 12:14")) (Supers TruckinCommInterface) (ClassVariables (CopyCV (Icon)) (Icon ?)) (InstanceVariables (postman NIL DefaultClass SlaveGateway doc (* instance of Slave GateWay)) (gameStarted NIL doc (* set to T when StartGame msg received)) )] [DEFCLASS SlaveTruckin (MetaClass GameClass Edited: (* sm: "10-JUL-83 20:51")) (Supers RemoteSlaveComm) (ClassVariables (CopyCV (Icon)) (Icon ?))] [DEFCLASS TimeTruckinDM (MetaClass GameClass Edited: (* sm: " 4-AUG-83 13:14")) (Supers TruckinDecisionMaker) (ClassVariables (MinMoveTime 1 doc (* min time everyone is charged)) (MaxMoveTime 30 doc (* max time per move, after which player yanked from game)) (AliceBonus 2 doc (* cashBox multiplied by this for reaching Alice) ) (CopyCV) (PlayerInterface TimeTruckinPI)) (InstanceVariables (aliceStay 3 MaxTime 30 AliceFactor 8 doc (* aliceStay - max conseq turns at Alice. MaxTime - Max time allowed at Alice during a conseq stay) ) (gameParameters TDMTParameters) (banditFreq 50 LastTime 3000 BanditFactor 15 doc (* freq of bandits move)) (replenishFreq 300 LastTime 3000 ReplenishFactor 30 doc (* how freq are gas stations filled)))] [DEFCLASS TimeTruckinPI (MetaClass GameClass Edited: (* sm: "29-JUN-83 10:16")) (Supers TruckinPlayerInterface) (ClassVariables (CopyCV) (DecisionMaker TimeTruckinDM doc (* name of associated DecisionMaker class) ))] [DEFCLASS Truckin (MetaClass GameClass Edited: (* sm: "10-JUL-83 20:50")) (Supers MainCommInterface) (ClassVariables (CopyCV NIL))] [DEFCLASS TruckinBoard (MetaClass GameClass Edited: (* sm: "27-JUN-83 17:31")) (Supers GameBoard) (ClassVariables (numRows 6 doc (* number of RoadStops arranged vertically on the game board.)) (numColumns 11 doc (* number of RoadStops arranged horizontally on the game board.)) (colorP NIL doc (* This indicates that this is not a colordisplay) ) (CopyCV NIL)) (InstanceVariables (roadStops NIL doc (* List of RoadStops on gameBoard.)))] [DEFCLASS TruckinCommInterface (MetaClass GameClass Edited: (* sm: " 8-JUL-83 15:35") doc (* Class for handling Truckin Communications on a single machine) ) (Supers GameCommInterface) (ClassVariables (CopyCV) (InitializeIVs (gameStarted))) (InstanceVariables (simulator NIL DefaultClass DisplayTruckinS) (playerInterface NIL DefaultClass TimeTruckinPI) (gameStarted NIL))] [DEFCLASS TruckinDecisionMaker (MetaClass GameClass Edited: (* dgb: "11-JUL-83 13:35")) (Supers GameDecisionMaker) (ClassVariables (CopyCV (PlayerInterface)) (PlayerInterface NIL doc (* name of class of this type associated with this DecisionMaker)) (InitializeIVs (bandits timeLeft players playerNames beginTime endTime timeLeft lastMoved loseTurn gameDuration startsAfter)) (AliceBonus 2)) (InstanceVariables (gameParameters TruckinDMParameters) (gameSeed NIL doc (* random number generator seed used for creating game) ) (simulator NIL doc (* instance of GameSimulator used by DecisionMaker) ) (alices NIL doc (* actual AlicesRestaurant's on board)) (bandits NIL nextTime NIL doc (* list of bandits currently on board. nextTime is a list of locs to be used for placing bandits in next turn)) (lastMoved NIL doc (* last player who issued Move command)) (loseTurn NIL doc (* List of players that lose the next turn.) ) (players NIL doc (* List of the players for this simulation.) ) (playerNames NIL doc (* list of names of players already in game) ) (roadStops NIL doc (* same roadStops as in (gameBoard roadStops)) ) (unionHall NIL doc (* actual instance of UnionHall on board) ) (beginTime 0 doc (* real clock time when game begins)) (endTime 0 doc (* real clock time when game ends)) (gameDuration 15 doc (* duration of game: endTime-beginTime)) (startsAfter 0 doc (* mins from now when game starts)) (timeLeft 1800 DefaultGauge SSDigiMeter DefaultLimit (0 1800) GaugePos (852 . 465)))] [DEFCLASS TruckinPlayerInterface (MetaClass GameClass Edited: (* sm: "10-JUL-83 21:59")) (Supers GamePlayerInterface) (ClassVariables (CopyCV (DecisionMaker)) (DecisionMaker NIL doc (* name of associated DecisionMaker class) ) (InitializeIVs (endTime beginTime unchargedTime lastMoved loseTurn localPlayers suspendedPlayers runningPlayer playerMenuWindow)) (MinMoveTime 1) (MaxMoveTime 30)) (InstanceVariables (localPlayers NIL doc (* list of players locally controlled by this PI) ) (suspendedPlayers NIL doc (* players suspended pending response from DM) ) (unchargedTime 0) (roadStops NIL) (lastMoved NIL) (loseTurn NIL) (beginTime 0) (endTime 0) (runningPlayer NIL doc (* player currently running)) (playerMenuWindow NIL position (650 . 720) doc (* Window for Menu to interrupt player processes) ))] [DEFCLASS TruckinSimulator (MetaClass GameClass Edited: (* dgb: "11-JUL-83 14:02")) (Supers GameSimulator) (ClassVariables (CopyCV) (InitializeIVs (gameRunningFlg bandits timeLeft players unchargedTime beginTime endTime timeLeft barChart clock)) (AliceBonus 2)) (InstanceVariables (barChart NIL doc (* barchart for players cash)) (gameBoard NIL doc DefaultClass BWTruckin (* instance of GameBoard)) (gameRunningFlg NIL doc (* this flag is set to T when game starts and back to NIL when it ends)) (roadStops NIL doc (* same roadStops as in (gameBoard roadStops)) ) (alices NIL doc (* actual AlicesRestaurant's on board)) (bandits NIL nextTime NIL doc (* list of bandits currently on board. nextTime is a list of locs to be used for placing bandits in next turn)) (gameParameters TruckinParameters doc (* pointer to gameParameters object)) (players NIL doc (* List of the players for this simulation.) ) (unchargedTime 0 doc (* time not charged because used by Execs or Breaks) ) (unionHall NIL doc (* actual instance of UnionHall on board) ) (beginTime 0) (endTime 0) (timeLeft 1800 DefaultGauge SSDigiMeter GaugeLimit (0 2000) GaugePos (852 . 465)) (clock NIL doc (* gauge attached to timeLeft)))] (DEFINEQ (MoveTruckinPI.BeginGame [LAMBDA (self players moves) (* sm: "27-JUN-83 11:03") (* * Starts a new game. Players is either the number of players or a list of Player objects. If players is NIL, but the gameMaster has previous players, it uses those.) (PROG NIL [COND ((NUMBERP moves) (←@ numMovesRemaining moves) (PutValue self (QUOTE numMovesRemaining) T (QUOTE SetByUser] (RETURN (←Super self BeginGame players]) (RemoteMasterComm.StartWorldProcess [LAMBDA (self) (* edited: "12-JUL-83 12:27") (* Starts world process) (PROG (hand) (DEL.PROCESS (FIND.PROCESS (QUOTE WorldProcess))) (SETQ hand (ADD.PROCESS (LIST (QUOTE ←) self (QUOTE WorldProcess)) (QUOTE NAME) (QUOTE WorldProcess) (QUOTE RESTARTABLE) T)) (←@ worldProcess hand) (←@ gameStarted T) (GameControlMenu) (RETURN hand]) (RemoteSlaveComm.StartWorldProcess [LAMBDA (self) (* edited: "12-JUL-83 12:26") (* Starts world process) (PROG (hand) (DEL.PROCESS (FIND.PROCESS (QUOTE WorldProcess))) (SETQ hand (ADD.PROCESS (LIST (QUOTE ←) self (QUOTE WorldProcess)) (QUOTE NAME) (QUOTE WorldProcess) (QUOTE RESTARTABLE) T)) (←@ worldProcess hand) (←@ gameStarted T) (GameControlMenu) (RETURN hand]) (SlaveTruckin [LAMBDA (displayFlg) (* sm: "16-SEP-83 15:05") (* Sets up the Slave M/c with or without display) [← ($ SlaveTruckin) New NIL NIL (COND (displayFlg NIL) (T (QUOTE NoDisplayTruckinS] (SETQ debugMode NIL) (SETQ PlayerProcRestFlg (QUOTE HARDRESET]) (TimeTruckinPI.BeginGame [LAMBDA (self players moves time) (* sm: "27-JUN-83 11:02") (* * Starts a new game. Players is either the number of players or a list of Player objects. If players is NIL, but the gameMaster has previous players, it uses those.) (PROG NIL (COND ((NUMBERP moves) (←@ avgNumMoves moves))) [COND ((NUMBERP time) (←@ timeRemaining time) (PutValue self (QUOTE timeRemaining) T (QUOTE SetByUser] (RETURN (←Super self BeginGame players]) (TruckinCommInterface.NewInstance [LAMBDA (self) (* sm: "27-JUN-83 15:39") (* Received when new instance is created) (* Any specialization must return self) (PROG NIL (←Super self NewInstance) (RETURN self]) ) (RPAQQ GameBrowse (GameBoard GameSimulator GameDecisionMaker GameCommInterface GamePlayerInterface)) (RPAQQ GameProcRestFlg T) (RPAQQ PlayerProcRestFlg HARDRESET) [METH BWTruckin InitializeGameWindow NIL (* Clears window and puts in proper background)] [METH ColorTruckin CreateGameBoard (region title) (* * Creates a new Window for the gameBoard.)] [METH ColorTruckin InitializeGameWindow (region) (* Initializes gamewindow and puts in proper background)] [METH ColorTruckin MakeDriveBitMaps NIL (* Creates Bit maps for Trucks)] [METH DisplayTruckinS NewGame (seed board) (* Generates a new game based on seed and board specified by DecisionMaster)] [METH DisplayTruckinS ReUseGame (seed) (* Sends message to GameBoard to reuse)] [METH GameCommInterface NewInstance (gameType boardType displayType dlist) (* Received when new instance is created)] [METH GameDecisionMaker NewInstance NIL (* Received when new instance is created)] [METH GamePlayerInterface ChangeGameParameters NIL (* Changes gameParameters via inspector)] [METH GamePlayerInterface NewInstance NIL (* Does initialization when created)] [METH GameSimulator NewInstance NIL (* Received when new instance is created)] [METH MainCommInterface AddBandit (name) (* Add bandit to game)] [METH MainCommInterface AddPlayer (reqID name type truck deniedFlg) (* Forwards to PI, Simulator, and DecisionMaker)] [METH MainCommInterface AddPlayerRequest (reqID name type truck) (* Forwards to DecisionMaker)] [METH MainCommInterface BeginGameRequest NIL (* Request for starting game - forwarded to DecisionMaker)] [METH MainCommInterface BreakCargo (playerName cargoPos) (* Forwards to Simulator)] [METH MainCommInterface BuyMade (playerName roadPosition reqQty qty reason penaltyAmt fragility lifetime) (* Forwards to Simulator)] [METH MainCommInterface BuyRequest (player roadPosition qty) (* Forwards to DecisionMaker)] [METH MainCommInterface GameOver NIL (* Sent to Simulator)] [METH MainCommInterface GasFill (prev new qty pr) (* Forwards to Simulator)] [METH MainCommInterface MaxMove (player maxMove) (* Forwards to Simulator)] [METH MainCommInterface MoveMade (playerName fromStop toStop reason penaltyAmount missTurns) (* Forwards to Simulator)] [METH MainCommInterface MoveRequest (player from to reason) (* Forwards to DecisionMaker)] [METH MainCommInterface NewGame (seed boardType gameType) (* Forwards to Simulator)] [METH MainCommInterface NewGameRequest (board) (* Forwards to DecisionMaker)] [METH MainCommInterface ParkedAtAlice (player time) (* Forwards to Simulator)] [METH MainCommInterface ReUseGame (seed) (* Forwards to Simulator and other recipients)] [METH MainCommInterface ReUseGameRequest NIL (* Forwards to DecisionMaker for reusing existing game board)] [METH MainCommInterface RemovePlayer (playerName reason) (* Forwards to Simulator)] [METH MainCommInterface RemovePlayerRequest (player reason) (* Request to remove player)] [METH MainCommInterface SellMade (playerName roadPosition reqQty qty cargoPos reason penaltyAmt) (* Forwards to Simulator, DecisionMaker, PlayerInterface)] [METH MainCommInterface SellRequest (player roadPosition commodityIndex qty) (* Forwards to DecisionMaker)] [METH MainCommInterface SetInitialParameters NIL (* Sets initial parameters)] [METH MainCommInterface SetUp (game board display) (* Sets up the Standard configuration)] [METH MainCommInterface SpoilCargo (playerName cargoPos) (* Forwards to Simulator)] [METH MainCommInterface StartGame (begTime endTime) (* Forwards to simulator, PI, DM, and then starts WorldProcess)] [METH MainCommInterface WorldProcess NIL (* This is the World Process)] [METH MoveTruckinDM InitializeGameParameters NIL (* Initializes critical variables for new game to run)] [METH MoveTruckinDM MoveBandits NIL (* randomly moves bandits around on the board before each turn)] [METH MoveTruckinPI RunGame (players) (* This is the main loop that runs the game)] [METH NoDisplayTruckinS AttachBoard (gameBoard) (* Attaches gameBoard to game)] [METH NoDisplayTruckinS DrivePlayer (curLoc finalLoc player) (* Noop for NoDisplay case)] [METH NoDisplayTruckinS UpdateRS (roadStop) (* Sent when any RoadStop's data changes)] [METH RemoteMasterComm AddBandit (name) (* Add bandit to game)] [METH RemoteMasterComm AddPlayer (reqID name type truck deniedFlg) (* Forwards to PI, Simulator, and DecisionMaker)] [METH RemoteMasterComm AddPlayerRequest (reqID name type truck) (* Forwards to DecisionMaker)] [METH RemoteMasterComm BeginGameRequest NIL (* Request for starting game - forwarded to DecisionMaker)] [METH RemoteMasterComm BreakCargo (playerName cargoPos) (* Forwards to Simulator)] [METH RemoteMasterComm BuyMade (playerName roadPosition reqQty qty reason penaltyAmt fragility lifetime) (* Forwards to Simulator)] [METH RemoteMasterComm BuyRequest (player roadPosition qty) (* Forwards to DecisionMaker)] [METH RemoteMasterComm GameOver NIL (* Sent to Simulator)] [METH RemoteMasterComm GasFill (prev new qty pr) (* Forwards to Simulator)] [METH RemoteMasterComm InterimWorldProcess NIL (* Interim world process)] [METH RemoteMasterComm MaxMove (player maxMove) (* Forwards to Simulator)] [METH RemoteMasterComm MoveMade (playerName fromStop toStop reason penaltyAmount missTurns) (* Forwards to Simulator)] [METH RemoteMasterComm MoveRequest (player from to reason) (* Forwards to DecisionMaker)] [METH RemoteMasterComm NewGame (seed boardType gameType) (* Forwards to Simulator)] [METH RemoteMasterComm NewGameRequest (board) (* Forwards to DecisionMaker)] [METH RemoteMasterComm ParkedAtAlice (player time) (* Forwards to Simulator)] [METH RemoteMasterComm ReUseGame (seed) (* Forwards to Simulator and other recipients)] [METH RemoteMasterComm ReUseGameRequest NIL (* Forwards to DecisionMaker for reusing existing game board)] [METH RemoteMasterComm RemovePlayer (playerName reason) (* Forwards to Simulator)] [METH RemoteMasterComm RemovePlayerRequest (player reason) (* Request to remove player)] [METH RemoteMasterComm SellMade (playerName roadPosition reqQty qty cargoPos reason penaltyAmt) (* Forwards to Simulator, DecisionMaker, PlayerInterface)] [METH RemoteMasterComm SellRequest (player roadPosition commodityIndex qty) (* Forwards to DecisionMaker)] [METH RemoteMasterComm SetInitialParameters NIL (* Sets initial parameters)] [METH RemoteMasterComm SetUp (game board display) (* Sets up the Standard configuration)] [METH RemoteMasterComm SpoilCargo (playerName cargoPos) (* Forwards to Simulator)] [METH RemoteMasterComm StartGame (begTime endTime) (* Forwards to simulator, PI, DM, and then starts WorldProcess)] [METH RemoteMasterComm StartInterimWorldProcess NIL (* Starts Interim World Process)] [METH RemoteMasterComm WorldProcess NIL (* This is the World Process.)] [METH RemoteSlaveComm AddBandit (name) (* Add bandit to game)] [METH RemoteSlaveComm AddPlayer (reqID name type truck deniedFlg) (* Forwards to PI, Simulator, and DecisionMaker)] [METH RemoteSlaveComm AddPlayerRequest (reqID name type truck) (* Forwards to DecisionMaker)] [METH RemoteSlaveComm BeginGameRequest NIL (* Blocks it.)] [METH RemoteSlaveComm BreakCargo (playerName cargoPos) (* Forwards to Simulator)] [METH RemoteSlaveComm BuyMade (playerName roadPosition reqQty qty reason penaltyAmt fragility lifetime) (* Forwards to Simulator)] [METH RemoteSlaveComm BuyRequest (player roadPosition qty) (* Forwards to DecisionMaker)] [METH RemoteSlaveComm GameOver NIL (* Sent to Simulator)] [METH RemoteSlaveComm GasFill (prev new qty pr) (* Forwards to Simulator)] [METH RemoteSlaveComm InterimWorldProcess NIL (* Interim world process)] [METH RemoteSlaveComm MaxMove (player maxMove) (* Forwards to Simulator)] [METH RemoteSlaveComm MoveMade (playerName fromStop toStop reason penaltyAmount missTurns) (* Forwards to Simulator)] [METH RemoteSlaveComm MoveRequest (player from to reason) (* Forwards to DecisionMaker)] [METH RemoteSlaveComm NewGame (seed boardType gameType) (* Forwards to Simulator)] [METH RemoteSlaveComm NewGameRequest (board) (* Blocks it)] [METH RemoteSlaveComm ParkedAtAlice (player time) (* Forwards to Simulator)] [METH RemoteSlaveComm ReUseGame (seed) (* Forwards to Simulator and other recipients)] [METH RemoteSlaveComm ReUseGameRequest NIL (* Blocks it)] [METH RemoteSlaveComm RemovePlayer (playerName reason) (* Forwards to Simulator)] [METH RemoteSlaveComm RemovePlayerRequest (player reason) (* Request to remove player)] [METH RemoteSlaveComm SellMade (playerName roadPosition reqQty qty cargoPos reason penaltyAmt) (* Forwards to Simulator, DecisionMaker, PlayerInterface)] [METH RemoteSlaveComm SellRequest (player roadPosition commodityIndex qty) (* Forwards to DecisionMaker)] [METH RemoteSlaveComm SetInitialParameters NIL (* Sets initial parameters)] [METH RemoteSlaveComm SetUp (game board display) (* Sets up the Standard configuration)] [METH RemoteSlaveComm SpoilCargo (playerName cargoPos) (* Forwards to Simulator)] [METH RemoteSlaveComm StartGame (begTime endTime) (* Forwards to simulator, PI, DM, and then starts WorldProcess)] [METH RemoteSlaveComm StartInterimWorldProcess NIL (* Starts Interim World Process)] [METH RemoteSlaveComm WorldProcess NIL (* This is the World Process)] [METH TimeTruckinDM ChargeTime (player clockTime) (* Calculates the actual time to be charged to player)] [METH TimeTruckinDM CheckAlice (player) (* check AlicesRestaurant's before each turn)] [METH TimeTruckinDM InitializeGameParameters NIL (* Initializes critical variables for new game to run)] [METH TimeTruckinDM MoveBandits NIL (* randomly moves bandits around on the board before each turn)] [METH TimeTruckinDM RedoGameParameters NIL (* Change game parameters based on players in the game)] [METH TimeTruckinDM ReplenishQty NIL (* Checks if time to replenish)] [METH TimeTruckinPI RunGame (players) (* This is the main loop that runs the game)] [METH TruckinBoard AssignRoadStops NIL (* * Assign RoadStops to the current GameBoard)] [METH TruckinBoard AttachToGame (game) (* attaches self to game)] [METH TruckinBoard CreateGameBoard (region title) (* * Creates a new Window for the gameBoard.)] [METH TruckinBoard DisplayGameBoard NIL (* * Displays the gameBoard. ReAllocates gameBoard window if needed.)] [METH TruckinBoard DrawRoadMarks NIL (* * Draw the dotted Lines in the road above the RoadStops.)] [METH TruckinBoard InitializeRoadStops (seed) (* Initializes RoadStop qty and pr)] [METH TruckinBoard MakeDriveBitMaps NIL (* Creates Bit maps for Trucks)] [METH TruckinBoard NewBoard (seed) (* Creates and displays a new game board)] [METH TruckinBoard PlaceRoadStops NIL (* mjs: "17-JAN-83 10:34")] [METH TruckinBoard ReInitializeRoadStops (seed) (* Reinitializes roadstops)] [METH TruckinBoard ReUseBoard (seed) (* Reuses game board: displaying afresh)] [METH TruckinBoard RemovePlayer (player) (* Sent to game board so it can remove player from board)] [METH TruckinCommInterface CleanGameWorld NIL (* Cleans up the game world after game over)] [METH TruckinCommInterface CreateDecisionMaker (game) (* Creates a new DecisionMaker)] [METH TruckinCommInterface CreateGateWay (machineName postalAddress) (* creates a gateway and links it)] [METH TruckinCommInterface CreatePlayerInterface (gameType) (* Create a PlayerInterface (if needed) matching gameType)] [METH TruckinCommInterface CreateSimulator (display) (* Creates a new simulator)] [METH TruckinCommInterface SetInitialParameters NIL (* Sets initial parameters)] [METH TruckinCommInterface StartWorldProcess NIL (* Starts world process)] [METH TruckinCommInterface TellMe (obj) (* Adds obj to broadcastList)] [METH TruckinDecisionMaker AddBandit (name) (* Add bandit to list)] [METH TruckinDecisionMaker AddPlayer (reqID name type truck deniedFlg) (* If player added, do initial placing for him)] [METH TruckinDecisionMaker AddPlayerRequest (reqID name type truck) (* Decides if a new player can be added or not)] [METH TruckinDecisionMaker AttachSimulator (sim) (* Attaches local simulator by copying relevant info)] [METH TruckinDecisionMaker BeginGameRequest NIL (* Starts the game)] [METH TruckinDecisionMaker BuyMade (player roadPosition reqQty qty reason penaltyAmt fragility lifetime) (* Dummy for now)] [METH TruckinDecisionMaker BuyRequest (player roadPosition qty) (* message sent to DecisionMaker to BUY qty at roadPosition)] [METH TruckinDecisionMaker ChangeGameParameters NIL (* Changes gameParameters via inspector)] [METH TruckinDecisionMaker CheckAlice NIL (* check AlicesRestaurant's before each turn)] [METH TruckinDecisionMaker ForcedMove (player curLoc maxMilePost reason) (* determines the loc to move currentPlayer as a forced move close to maxMilePost)] [METH TruckinDecisionMaker GameOver NIL (* Sent when game is over)] [METH TruckinDecisionMaker GiveAliceBonus (atAlice) (* Dummy method)] [METH TruckinDecisionMaker InitializeGameParameters NIL (* Initializes critical variables for new game to run)] [METH TruckinDecisionMaker MonitorGame (gameOverFlg) (* Monitors the game to move bandits, replenish qty, check alice, and signal game end.)] [METH TruckinDecisionMaker MonitorProcess NIL (* Monitors the game to move bandits, replenish qty, check alice, and signal game end)] [METH TruckinDecisionMaker MoveBandits NIL (* randomly moves bandits around on the board before each turn)] [METH TruckinDecisionMaker MoveCheckingHazards (player curLoc newLoc reason) (* moves truck checking for hazards along the way. Called by GameMaster.MoveTruck)] [METH TruckinDecisionMaker MoveMade (player fromStop toStop reason penaltyAmount missTurns) (* Generates new MaxMove for player and checks for Alice overstay)] [METH TruckinDecisionMaker MoveRequest (player from to reason) (* sent to DecisionMaker for deciding if move can be made)] [METH TruckinDecisionMaker MoveTruck (player curLoc newLoc reason) (* actually moves the currentPlayer's truck)] [METH TruckinDecisionMaker NewGameRequest (board) (* Generates seed for a new game)] [METH TruckinDecisionMaker ReUseGameRequest NIL (* Generates a new seed for reusing existing game)] [METH TruckinDecisionMaker RedoGameParameters NIL (* Dummy. Needed if some game parameters need to be changed after the players are known)] [METH TruckinDecisionMaker RemovePlayer (player reason) (* removes player from game)] [METH TruckinDecisionMaker RemovePlayerRequest (player reason) (* Request to remove player)] [METH TruckinDecisionMaker ReplenishQty NIL (* replenish GasStations qty)] [METH TruckinDecisionMaker SellMade (player roadPosition reqQty qty cargoPos reason penaltyAmt) (* Dummy for now)] [METH TruckinDecisionMaker SellRequest (player roadPosition commodityIndex qty) (* message sent to DecisionMaker to sell qty of commodity at the player's roadPosition.)] [METH TruckinDecisionMaker StartGame NIL (* Starts game)] [METH TruckinDecisionMaker StartMonitorProcess NIL (* Start the monitor process)] [METH TruckinDecisionMaker UpdateAlice (player) (* Decides when parked at Alice)] [METH TruckinPlayerInterface AddPlayer (reqID name type truck deniedFlg) (* New player being added to game)] [METH TruckinPlayerInterface AddPlayerRequest (playerName playerType truckType) (* A request to create a new Player)] [METH TruckinPlayerInterface BeginGame (players moves) (* * Starts a new game. Players is either the number of players or a list of Player objects. If players is NIL, but the gameMaster has previous players, it uses those.)] [METH TruckinPlayerInterface Buy (player qty) (* message sent by currentPlayer to BUY qty at its current location)] [METH TruckinPlayerInterface BuyMade (player roadPosition reqQty qty reason penaltyAmt fragility lifetime) (* check if for local player)] [METH TruckinPlayerInterface ChargeTime (player clockTime) (* Calculates the actual time to be charged to player)] [METH TruckinPlayerInterface CheckLocalPlayers NIL (* Checks to make sure that all local players have processes)] [METH TruckinPlayerInterface ContinueGame (noRedrawFlg) (* to resume a game in the middle.)] [METH TruckinPlayerInterface CreatePlayerProcess (player staySuspendFlg) (* Creates a process for player and suspends the process)] [METH TruckinPlayerInterface DeletePlayerProcesses NIL (* Deletes players processes after the game)] [METH TruckinPlayerInterface Move (player newLoc) (* sent by to move to newLoc)] [METH TruckinPlayerInterface MoveMade (player fromStop toStop reason penaltyAmount missTurns) (* check if for local player)] [METH TruckinPlayerInterface NewGame (seed boardType gameType) (* Adds roadStops locally)] [METH TruckinPlayerInterface NewGameRequest (board) (* Request for creating a new game of existing type)] [METH TruckinPlayerInterface PlayerRequestComplete (player reason) (* if player passed as arg, set wakeReason)] [METH TruckinPlayerInterface ReUseGame NIL (* Received when the current board is used for a new game)] [METH TruckinPlayerInterface RemovePlayer (player reason) (* New method template)] [METH TruckinPlayerInterface RemovePlayerRequest (player reason) (* Request to remove player)] [METH TruckinPlayerInterface RunNextPlayer NIL (* Decides who to run next -)] [METH TruckinPlayerInterface ScheduleNextPlayer NIL (* Decides who to run next -)] [METH TruckinPlayerInterface SelectPlayers (players) (* Asks user to select players)] [METH TruckinPlayerInterface Sell (player commodity qty) (* message sent by currentPlayer to sell qty of commodity at the player's current location.)] [METH TruckinPlayerInterface SellMade (player roadPosition reqQty qty cargoPos reason penaltyAmt) (* check if for local player)] [METH TruckinPlayerInterface StartGame (begTime endTime) (* Starts the game at begTime)] [METH TruckinPlayerInterface StartPlayerProcesses NIL (* starts players in separate processes)] [METH TruckinPlayerInterface SuspendPlayer (player staySuspend) (* Suspends player after a Buy/Move/Sell request)] [METH TruckinPlayerInterface WakePlayer (player) (* Wakes player so it can be run at next BLOCK)] [METH TruckinSimulator AddBandit (name) (* Add bandit to game)] [METH TruckinSimulator AddPlayer (reqID name type truck deniedFlg) (* Adds player to its list - assumes player created by PlayerInterface)] [METH TruckinSimulator AttachBoard (gameBoard) (* Attaches gameBoard to game)] [METH TruckinSimulator BreakCargo (player commodIndex) (* Sent by a commodity when it breaks)] [METH TruckinSimulator BuyMade (player roadPosition reqQty qty reason penalty fragility lifetime) (* Indicates a definite BUY to be made, or reasons for not carrying out a BuyRequest)] [METH TruckinSimulator ClockProcess NIL (* Monitors game clock)] [METH TruckinSimulator DrivePlayer (curLoc finalLoc player) (* Drives player from curLoc to finalLoc)] [METH TruckinSimulator GameOver NIL (* Game Over)] [METH TruckinSimulator GasFill (prevStop gsStop qty pr) (* Instructions for moving a gas truck and filling GasStation)] [METH TruckinSimulator GiveAliceBonus (atAlice) (* Give bonus for reaching Alices)] [METH TruckinSimulator Initialize NIL (* Initializes)] [METH TruckinSimulator MaxMove (player maxMove) (* Puts maxMove in player)] [METH TruckinSimulator MoveMade (player from to reason penaltyAmt missTurn) (* Actually makes the move after all checks are done)] [METH TruckinSimulator NewGame (seed board) (* Generates a new game based on seed and board specified by DecisionMaster)] [METH TruckinSimulator ParkedAtAlice (player time) (* Marks when player parked at alice)] [METH TruckinSimulator ReUseGame (seed) (* Sends message to GameBoard to reuse)] [METH TruckinSimulator RedoGameParameters NIL (* Change anything after all game info is known - prior to game start)] [METH TruckinSimulator RemovePlayer (player reason) (* Sent to game board so it can remove player from board)] [METH TruckinSimulator SellMade (player roadPosition reqQty qty cargoPosition reason penalty) (* Performs an actual Sell, once all checking is done)] [METH TruckinSimulator SetUpGauges NIL (* Sets up gauges)] [METH TruckinSimulator SpoilCargo (player commodIndex) (* Sent by commodity when it spoils)] [METH TruckinSimulator StartClockProcess NIL (* Starts the clock process)] [METH TruckinSimulator StartGame (begTime endTime) (* SetsUp IVs for time left etc and starts game clock process)] [METH TruckinSimulator UnattachBoard NIL (* Removes game board)] [METH TruckinSimulator UpdateRS (roadStop) (* Sent when any RoadStop's data changes)] [METH TruckinSimulator WhoWon NIL (* summarizes the game results)] (DEFINEQ (BWTruckin.InitializeGameWindow (Method ((BWTruckin InitializeGameWindow) self) (* sm: "29-JUN-83 15:52") (* Clears window and puts in proper background) (CLEARW (@ gameWindow)) (BITBLT NIL NIL NIL (@ gameWindow) NIL NIL NIL NIL (QUOTE TEXTURE) (QUOTE REPLACE) boardShade))) (ColorTruckin.CreateGameBoard (Method ((ColorTruckin CreateGameBoard) self region title) (* sm: " 5-JUL-83 18:37") (* * Creates a new Window for the gameBoard.) (PROG (screen) [COND ((OR (NULL (COLORDISPLAYP)) (NULL (SETQ screen (COLORSCREENBITMAP))) (NEQ 4 (fetch (BITMAP BITMAPBITSPERPIXEL) of screen))) (COLORDISPLAY T 4) (SETQ screen (COLORSCREENBITMAP] (SETQ gameWindow (DSPCREATE screen)) (←@ gameWindow gameWindow) (← self InitializeGameWindow region) (← self MakeDriveBitMaps) (RETURN gameWindow)))) (ColorTruckin.InitializeGameWindow (Method ((ColorTruckin InitializeGameWindow) self region) (* sm: " 5-JUL-83 18:37") (* Initializes gamewindow and puts in proper background) (PROG NIL (SETQ gameWindow (@ gameWindow)) (BITBLT NIL NIL NIL gameWindow NIL NIL NIL NIL (QUOTE TEXTURE) (QUOTE REPLACE) borderColor) (DSPXOFFSET (IQUOTIENT (IDIFFERENCE 640 (fetch (REGION WIDTH) of region)) 2) gameWindow) (DSPYOFFSET (IQUOTIENT (IDIFFERENCE 480 (fetch (REGION HEIGHT) of region)) 2) gameWindow) (DSPCLIPPINGREGION (create REGION LEFT ← 0 BOTTOM ← 0 WIDTH ←(fetch (REGION WIDTH) of region) HEIGHT ←(fetch (REGION HEIGHT) of region)) gameWindow) (BITBLT NIL NIL NIL gameWindow NIL NIL NIL NIL (QUOTE TEXTURE) (QUOTE REPLACE) roadColor) (RETURN gameWindow)))) (ColorTruckin.MakeDriveBitMaps (Method ((ColorTruckin MakeDriveBitMaps) self) (* sm: "27-JUN-83 17:33") (* Creates Bit maps for Trucks) (MakeDriveBitMaps 4))) (DisplayTruckinS.NewGame (Method ((DisplayTruckinS NewGame) self seed board) (* sm: "28-JUN-83 09:13") (* Generates a new game based on seed and board specified by DecisionMaster) (←Super self NewGame seed board) (← (@ gameBoard) DisplayGameBoard))) (DisplayTruckinS.ReUseGame (Method ((DisplayTruckinS ReUseGame) self seed) (* sm: " 1-JUL-83 18:14") (* Sends message to GameBoard to reuse) (←Super self ReUseGame seed) (← (@ gameBoard) DisplayGameBoard))) (GameCommInterface.NewInstance (Method ((GameCommInterface NewInstance) self gameType boardType displayType dlist) (* dgb: "22-SEP-83 15:16") (* Received when new instance is created) (* Any specialization must return self) (←Super self NewInstance) (SETQ Communicator self) (* gameType - type of Game) (* boardType - type of board, e.g., BW or Color) (* displayType - type of display, e.g., Display or Silent) (* dlist - broadcastList) (←@ broadcastList dlist) (← self SetUp gameType boardType displayType) self)) (GameDecisionMaker.NewInstance (Method ((GameDecisionMaker NewInstance) self) (* dgb: "22-SEP-83 15:17") (* Received when new instance is created) (* Any specialization must return self) (←Super self NewInstance))) (GamePlayerInterface.ChangeGameParameters (Method ((GamePlayerInterface ChangeGameParameters) self) (* sm: "29-JUN-83 13:45") (* Changes gameParameters via inspector) (PROG (gp) (SETQ gp (GetItHere self (QUOTE gameParameters))) (COND ((EQ gp NotSetValue) (SETQ gp (← (GetObjectRec (@ gameParameters)) New)) (←@ gameParameters gp))) (PROMPT "Change Game Parameters by using the displayed Inspector." "When done, click DONE") (← gp SetUp) (while (NOT GameParaSet) do (TOTOPW GameParamW) (TOTOPW GameCommandW) (DISMISS 500)) (RETURN T)))) (GamePlayerInterface.NewInstance (Method ((GamePlayerInterface NewInstance) self) (* dgb: "22-SEP-83 15:15") (* Does initialization when created) (* Any specialization must return self) (* later may set gameMaster to self too) (←Super self NewInstance) (SETQ gameMaster self))) (GameSimulator.NewInstance (Method ((GameSimulator NewInstance) self) (* dgb: "22-SEP-83 15:17") (* Received when new instance is created) (* Any specialization must return self) (←Super self NewInstance))) (MainCommInterface.AddBandit (Method ((MainCommInterface AddBandit) self name) (* sm: "10-JUL-83 18:38") (* Add bandit to game) (← (@ simulator) AddBandit name) (← (@ decisionMaker) AddBandit name) (MailOut self (LIST (QUOTE AddBandit) name)))) (MainCommInterface.AddPlayer (Method ((MainCommInterface AddPlayer) self reqID name type truck deniedFlg) (* sm: "10-JUL-83 18:40") (* Forwards to PI, Simulator, and DecisionMaker) (← (@ playerInterface) AddPlayer reqID name type truck deniedFlg) (← (@ simulator) AddPlayer reqID name type truck deniedFlg) (MailOut self (LIST (QUOTE AddPlayer) reqID name type truck deniedFlg)) (← (@ decisionMaker) AddPlayer reqID name type truck deniedFlg))) (MainCommInterface.AddPlayerRequest (Method ((MainCommInterface AddPlayerRequest) self reqID name type truck) (* sm: "30-JUN-83 17:33") (* Forwards to DecisionMaker) (← (@ decisionMaker) AddPlayerRequest reqID name type truck))) (MainCommInterface.BeginGameRequest (Method ((MainCommInterface BeginGameRequest) self) (* sm: " 1-JUL-83 17:13") (* Request for starting game - forwarded to DecisionMaker) (← (@ decisionMaker) BeginGameRequest))) (MainCommInterface.BreakCargo (Method ((MainCommInterface BreakCargo) self playerName cargoPos) (* sm: "10-JUL-83 18:41") (* Forwards to Simulator) (← (@ simulator) BreakCargo playerName cargoPos) (MailOut self (LIST (QUOTE BreakCargo) (GetObjectRec playerName) cargoPos)))) (MainCommInterface.BuyMade (Method ((MainCommInterface BuyMade) self playerName roadPosition reqQty qty reason penaltyAmt fragility lifetime) (* sm: "10-JUL-83 18:42") (* Forwards to Simulator) (← (@ simulator) BuyMade (GetObjectRec playerName) roadPosition reqQty qty reason penaltyAmt fragility lifetime) (← (@ decisionMaker) BuyMade (GetObjectRec playerName) roadPosition reqQty qty reason penaltyAmt fragility lifetime) (← (@ playerInterface) BuyMade (GetObjectRec playerName) roadPosition reqQty qty reason penaltyAmt fragility lifetime) (MailOut self (LIST (QUOTE BuyMade) (GetObjectRec playerName) roadPosition reqQty qty reason penaltyAmt fragility lifetime)))) (MainCommInterface.BuyRequest (Method ((MainCommInterface BuyRequest) self player roadPosition qty) (* sm: " 5-JUL-83 17:22") (* Forwards to DecisionMaker) (← (@ decisionMaker) BuyRequest (GetObjectRec player) roadPosition qty))) (MainCommInterface.GameOver (Method ((MainCommInterface GameOver) self) (* sm: "12-JUL-83 22:09") (* Sent to Simulator) (← (@ simulator) GameOver) (MailOut self (LIST (QUOTE GameOver))) (←@ gameStarted NIL))) (MainCommInterface.GasFill (Method ((MainCommInterface GasFill) self prev new qty pr) (* sm: "10-JUL-83 18:44") (* Forwards to Simulator) (← (@ simulator) GasFill prev new qty pr) (MailOut self (LIST (QUOTE GasFill) prev new qty pr)))) (MainCommInterface.MaxMove (Method ((MainCommInterface MaxMove) self player maxMove) (* sm: "10-JUL-83 18:45") (* Forwards to Simulator) (← (@ simulator) MaxMove player maxMove) (MailOut self (LIST (QUOTE MaxMove) (GetObjectRec player) maxMove)))) (MainCommInterface.MoveMade (Method ((MainCommInterface MoveMade) self playerName fromStop toStop reason penaltyAmount missTurns) (* sm: "13-JUL-83 09:17") (* Forwards to Simulator) (← (@ simulator) MoveMade (GetObjectRec playerName) fromStop toStop reason penaltyAmount missTurns) (← (@ decisionMaker) MoveMade (GetObjectRec playerName) fromStop toStop reason penaltyAmount missTurns) (← (@ playerInterface) MoveMade (GetObjectRec playerName) fromStop toStop reason penaltyAmount missTurns) (MailOut self (LIST (QUOTE MoveMade) (GetObjectRec playerName) fromStop toStop reason penaltyAmount missTurns)) (← (@ decisionMaker) UpdateAlice (GetObjectRec playerName)))) (MainCommInterface.MoveRequest (Method ((MainCommInterface MoveRequest) self player from to reason) (* sm: " 5-JUL-83 17:21") (* Forwards to DecisionMaker) (← (@ decisionMaker) MoveRequest (GetObjectRec player) from to reason))) (MainCommInterface.NewGame (Method ((MainCommInterface NewGame) self seed boardType gameType) (* sm: "10-JUL-83 18:47") (* Forwards to Simulator) (← (@ simulator) NewGame seed boardType gameType) (← self CreatePlayerInterface gameType) (← (@ playerInterface) NewGame seed boardType gameType) (MailOut self (LIST (QUOTE NewGame) seed boardType gameType)))) (MainCommInterface.NewGameRequest (Method ((MainCommInterface NewGameRequest) self board) (* sm: "29-JUN-83 13:12") (* Forwards to DecisionMaker) (← (@ decisionMaker) NewGameRequest board))) (MainCommInterface.ParkedAtAlice (Method ((MainCommInterface ParkedAtAlice) self player time) (* sm: "10-JUL-83 18:48") (* Forwards to Simulator) (← (@ simulator) ParkedAtAlice player time) (MailOut self (LIST (QUOTE ParkedAtAlice) (GetObjectRec player) time)))) (MainCommInterface.ReUseGame (Method ((MainCommInterface ReUseGame) self seed) (* sm: "10-JUL-83 19:20") (* Forwards to Simulator and other recipients) (← (@ simulator) ReUseGame seed) (← (@ playerInterface) ReUseGame) (MailOut self (LIST (QUOTE ReUseGame) seed)))) (MainCommInterface.ReUseGameRequest (Method ((MainCommInterface ReUseGameRequest) self) (* sm: "29-JUN-83 14:21") (* Forwards to DecisionMaker for reusing existing game board) (← (@ decisionMaker) ReUseGameRequest))) (MainCommInterface.RemovePlayer (Method ((MainCommInterface RemovePlayer) self playerName reason) (* sm: "10-JUL-83 19:21") (* Forwards to Simulator) (← (@ simulator) RemovePlayer playerName reason) (← (@ playerInterface) RemovePlayer playerName reason) (MailOut self (LIST (QUOTE RemovePlayer) (GetObjectRec playerName) reason)))) (MainCommInterface.RemovePlayerRequest (Method ((MainCommInterface RemovePlayerRequest) self player reason) (* sm: "10-JUL-83 21:03") (* Request to remove player) (← (@ decisionMaker) RemovePlayerRequest player reason))) (MainCommInterface.SellMade (Method ((MainCommInterface SellMade) self playerName roadPosition reqQty qty cargoPos reason penaltyAmt) (* sm: "10-JUL-83 19:22") (* Forwards to Simulator, DecisionMaker, PlayerInterface) (← (@ simulator) SellMade (GetObjectRec playerName) roadPosition reqQty qty cargoPos reason penaltyAmt) (← (@ decisionMaker) SellMade (GetObjectRec playerName) roadPosition reqQty qty cargoPos reason penaltyAmt) (← (@ playerInterface) SellMade (GetObjectRec playerName) roadPosition reqQty qty cargoPos reason penaltyAmt) (MailOut self (LIST (QUOTE SellMade) (GetObjectRec playerName) roadPosition reqQty qty cargoPos reason penaltyAmt)))) (MainCommInterface.SellRequest (Method ((MainCommInterface SellRequest) self player roadPosition commodityIndex qty) (* sm: " 5-JUL-83 17:22") (* Forwards to DecisionMaker) (← (@ decisionMaker) SellRequest (GetObjectRec player) roadPosition commodityIndex qty))) (MainCommInterface.SetInitialParameters (Method ((MainCommInterface SetInitialParameters) self) (* sm: "10-JUL-83 20:16") (* Sets initial parameters) (←@(@ decisionMaker) startsAfter 0))) (MainCommInterface.SetUp (Method ((MainCommInterface SetUp) self game board display) (* sm: "10-JUL-83 19:37") (* Sets up the Standard configuration) (* ARGS: If NIL, then default. If T, then ask user, else use the passed arg) (← self CreateDecisionMaker game) (← self CreateSimulator display) (← self SetInitialParameters) (* sends a request to DecisionMaker to create a new game) (← (@ decisionMaker) NewGameRequest board))) (MainCommInterface.SpoilCargo (Method ((MainCommInterface SpoilCargo) self playerName cargoPos) (* sm: "10-JUL-83 19:22") (* Forwards to Simulator) (← (@ simulator) SpoilCargo playerName cargoPos) (MailOut self (LIST (QUOTE SpoilCargo) (GetObjectRec playerName) cargoPos)))) (MainCommInterface.StartGame (Method ((MainCommInterface StartGame) self begTime endTime) (* sm: "10-JUL-83 19:23") (* Forwards to simulator, PI, DM, and then starts WorldProcess) (← (@ simulator) StartGame begTime endTime) (← (@ playerInterface) StartGame begTime endTime) (← (@ decisionMaker) StartGame begTime endTime) (* start the WorldProcess) (← self StartWorldProcess) (MailOut self (LIST (QUOTE StartGame) begTime endTime)))) (MainCommInterface.WorldProcess [Method ((MainCommInterface WorldProcess) self) (* sm: "16-SEP-83 17:17") (* This is the World Process) (PROG ([endTime (SETUPTIMER.DATE (GDATE (IPLUS (@ Simulator endTime) 1] cTime pendReq) (* Wait till it is 2 secs before game) [BLOCK NIL (SETUPTIMER (IntervalToEvent (@ Simulator beginTime] (* ask PI to start User Processes) (* (← (@ playerInterface) StartPlayerProcesses)) (← (@ decisionMaker) RedoGameParameters) (← (@ simulator) RedoGameParameters) (* Start the loop for checking messages from PI) (PutValue (@ simulator) (QUOTE timeLeft) (IDIFFERENCE (@(@ simulator) endTime) (IDATE))) (←@(@ playerInterface) runningPlayer NIL) (← (@ playerInterface) CheckLocalPlayers) (until (TIMEREXPIRED? endTime (QUOTE SECONDS)) do (← (@ playerInterface) ScheduleNextPlayer) (BLOCK) (* this will enable the Scheduler to consider all players next time around. Needed only for Single Mc case) (for x in (@(@ playerInterface) suspendedPlayers) do (←@ x staySuspend NIL)) (← (@ decisionMaker) MonitorGame)) (* Game is over) (← (@ decisionMaker) MonitorGame T) (←@ gameStarted NIL) (← self CleanGameWorld) (RETURN (QUOTE Done]) (MoveTruckinDM.InitializeGameParameters [Method ((MoveTruckinDM InitializeGameParameters) self) (* sm: " 1-JUL-83 15:54") (* Initializes critical variables for new game to run) (←Super self InitializeGameParameters) [COND ((EQ (@ self numMovesRemaining SetByUser) T) (PutValue self (QUOTE numMovesRemaining) NIL (QUOTE SetByUser))) (T (←@ numMovesRemaining (GetInitialValue self (QUOTE numMovesRemaining] (WriteGameStatus (DATE) " New Simulation! " (CONCAT "Total Moves: " (@ numMovesRemaining]) (MoveTruckinDM.MoveBandits [Method ((MoveTruckinDM MoveBandits) self) (* sm: "27-JUN-83 10:55") (* randomly moves bandits around on the board before each turn) (COND ((ZEROP (IMOD (@ numMovesRemaining) (@ banditFreq))) (* Only move once in a while if you are a bandit) (←Super self MoveBandits]) (MoveTruckinPI.RunGame [Method ((MoveTruckinPI RunGame) self players) (* sm: "27-JUN-83 11:03") (* This is the main loop that runs the game) (while (GREATERP (@ numMovesRemaining) 0) bind playerRet do (PROGN (WaitIfControlKey "Beginning of Game Loop") (COND ((ZEROP (IMOD (@ numMovesRemaining) (@ replenishFreq))) (← self ReplenishQty))) [COND ((ZEROP (IMOD (@ numMovesRemaining) 10)) (WriteGameStatus NIL "Moves Remaining: " (@ numMovesRemaining] (← self CheckAlice) (← self MoveBandits) (←@ numMovesRemaining (SUB1 (@ numMovesRemaining))) (for x in (@ players) do (PROGN (SETQ currentPlayer (←@ currentPlayer x)) (←@ unchargedTime 0) (SETQ forcedStop NIL) (* update commodity status affected by moves) (for y in (@(@ x truck) cargo) do (DoFringeMethods y (QUOTE UpdateStatus))) (COND ((FMEMB x (@ loseTurn)) (WriteGameStatus (CONCAT (@ x driver) " lost his turn")) (←@ loseTurn (REMOVE x (@ loseTurn))) (←@ lastMoved NIL)) (T (SETQ maxMove (RAND 1 (@@(@ x truck) MaxDist))) (* (WriteGameStatus (@ x driver) " can MOVE max " maxMove)) [COND (debugMode (← x TakeTurn)) (T (SETQ playerRet (ERSETQ (← x TakeTurn))) (COND ((NULL playerRet) (← self RemovePlayer x "Player crashed on a Bug"] (←@ lastMoved NIL]) (NoDisplayTruckinS.AttachBoard (Method ((NoDisplayTruckinS AttachBoard) self gameBoard) (* dgb: "11-JUL-83 13:05") (* Attaches gameBoard to game) (←Super self AttachBoard gameBoard) (SETQ gameWindow NIL))) (NoDisplayTruckinS.DrivePlayer (Method ((NoDisplayTruckinS DrivePlayer) self curLoc finalLoc player) (* dgb: "11-JUL-83 12:40") (* Noop for NoDisplay case) self)) (NoDisplayTruckinS.UpdateRS (Method ((NoDisplayTruckinS UpdateRS) self roadStop) (* sm: "28-JUN-83 09:46") (* Sent when any RoadStop's data changes) (* Does not ask roadStop to display) roadStop)) (RemoteMasterComm.AddBandit (Method ((RemoteMasterComm AddBandit) self name) (* sm: " 7-JUL-83 13:22") (* Add bandit to game) (PROG (msg) (← (@ simulator) AddBandit name) (← (@ decisionMaker) AddBandit name) (SETQ msg (LIST (QUOTE AddBandit) name)) (SendOut self msg) (MailOut self msg)))) (RemoteMasterComm.AddPlayer (Method ((RemoteMasterComm AddPlayer) self reqID name type truck deniedFlg) (* sm: "10-JUL-83 11:20") (* Forwards to PI, Simulator, and DecisionMaker) (PROG (msg) (← (@ playerInterface) AddPlayer reqID name type truck deniedFlg) (← (@ simulator) AddPlayer reqID name type truck deniedFlg) (SETQ msg (LIST (QUOTE AddPlayer) reqID name type truck deniedFlg)) (SendOut self msg) (MailOut self msg) (← (@ decisionMaker) AddPlayer reqID name type truck deniedFlg)))) (RemoteMasterComm.AddPlayerRequest (Method ((RemoteMasterComm AddPlayerRequest) self reqID name type truck) (* sm: " 7-JUL-83 12:48") (* Forwards to DecisionMaker) (← (@ decisionMaker) AddPlayerRequest reqID name type truck))) (RemoteMasterComm.BeginGameRequest (Method ((RemoteMasterComm BeginGameRequest) self) (* sm: " 7-JUL-83 12:48") (* Request for starting game - forwarded to DecisionMaker) (← (@ decisionMaker) BeginGameRequest))) (RemoteMasterComm.BreakCargo [Method ((RemoteMasterComm BreakCargo) self playerName cargoPos) (* sm: " 7-JUL-83 13:38") (* Forwards to Simulator) (PROG (msg) (← (@ simulator) BreakCargo (GetObjectRec playerName) cargoPos) (SendOut self (LIST (QUOTE BreakCargo) (GetObjectName playerName) cargoPos)) (MailOut self (LIST (QUOTE BreakCargo) (GetObjectRec playerName) cargoPos]) (RemoteMasterComm.BuyMade (Method ((RemoteMasterComm BuyMade) self playerName roadPosition reqQty qty reason penaltyAmt fragility lifetime) (* sm: " 7-JUL-83 13:39") (* Forwards to Simulator) (← (@ simulator) BuyMade (GetObjectRec playerName) roadPosition reqQty qty reason penaltyAmt fragility lifetime) (← (@ decisionMaker) BuyMade (GetObjectRec playerName) roadPosition reqQty qty reason penaltyAmt fragility lifetime) (← (@ playerInterface) BuyMade (GetObjectRec playerName) roadPosition reqQty qty reason penaltyAmt fragility lifetime) (SendOut self (LIST (QUOTE BuyMade) (GetObjectName playerName) roadPosition reqQty qty reason penaltyAmt fragility lifetime)) (MailOut self (LIST (QUOTE BuyMade) (GetObjectRec playerName) roadPosition reqQty qty reason penaltyAmt fragility lifetime)))) (RemoteMasterComm.BuyRequest (Method ((RemoteMasterComm BuyRequest) self player roadPosition qty) (* sm: " 7-JUL-83 12:48") (* Forwards to DecisionMaker) (← (@ decisionMaker) BuyRequest (GetObjectRec player) roadPosition qty))) (RemoteMasterComm.GameOver (Method ((RemoteMasterComm GameOver) self) (* sm: "12-JUL-83 22:09") (* Sent to Simulator) (← (@ simulator) GameOver) (SendOut self (LIST (QUOTE GameOver))) (MailOut self (LIST (QUOTE GameOver))) (←@ gameStarted NIL))) (RemoteMasterComm.GasFill (Method ((RemoteMasterComm GasFill) self prev new qty pr) (* sm: " 7-JUL-83 13:41") (* Forwards to Simulator) (PROG (msg) (← (@ simulator) GasFill prev new qty pr) (SETQ msg (LIST (QUOTE GasFill) prev new qty pr)) (SendOut self msg) (MailOut self msg)))) (RemoteMasterComm.InterimWorldProcess (Method ((RemoteMasterComm InterimWorldProcess) self) (* sm: " 8-JUL-83 15:41") (* Interim world process) (until (@ gameStarted) do (COND ((← (@ postman) ReceiveP) (ReceiveIn self))) (BLOCK)) (DEL.PROCESS (THIS.PROCESS)))) (RemoteMasterComm.MaxMove (Method ((RemoteMasterComm MaxMove) self player maxMove) (* sm: "10-JUL-83 18:46") (* Forwards to Simulator) (← (@ simulator) MaxMove (GetObjectRec player) maxMove) (SendOut self (LIST (QUOTE MaxMove) (COND ((LITATOM player) player) (T (GetObjectName player))) maxMove)) (MailOut self (LIST (QUOTE MaxMove) (GetObjectRec player) maxMove)))) (RemoteMasterComm.MoveMade (Method ((RemoteMasterComm MoveMade) self playerName fromStop toStop reason penaltyAmount missTurns) (* sm: "13-JUL-83 09:17") (* Forwards to Simulator) (← (@ simulator) MoveMade (GetObjectRec playerName) fromStop toStop reason penaltyAmount missTurns) (← (@ decisionMaker) MoveMade (GetObjectRec playerName) fromStop toStop reason penaltyAmount missTurns) (← (@ playerInterface) MoveMade (GetObjectRec playerName) fromStop toStop reason penaltyAmount missTurns) (SendOut self (LIST (QUOTE MoveMade) (GetObjectName playerName) fromStop toStop reason penaltyAmount missTurns)) (MailOut self (LIST (QUOTE MoveMade) (GetObjectRec playerName) fromStop toStop reason penaltyAmount missTurns)) (← (@ decisionMaker) UpdateAlice (GetObjectRec playerName)))) (RemoteMasterComm.MoveRequest (Method ((RemoteMasterComm MoveRequest) self player from to reason) (* sm: " 7-JUL-83 12:49") (* Forwards to DecisionMaker) (← (@ decisionMaker) MoveRequest (GetObjectRec player) from to reason))) (RemoteMasterComm.NewGame (Method ((RemoteMasterComm NewGame) self seed boardType gameType) (* sm: " 7-JUL-83 13:49") (* Forwards to Simulator) (PROG (msg) (← (@ simulator) NewGame seed boardType gameType) (← self CreatePlayerInterface gameType) (← (@ playerInterface) NewGame seed boardType gameType) (SETQ msg (LIST (QUOTE NewGame) seed boardType gameType)) (SendOut self msg) (MailOut self msg)))) (RemoteMasterComm.NewGameRequest (Method ((RemoteMasterComm NewGameRequest) self board) (* sm: " 7-JUL-83 12:49") (* Forwards to DecisionMaker) (← (@ decisionMaker) NewGameRequest board))) (RemoteMasterComm.ParkedAtAlice (Method ((RemoteMasterComm ParkedAtAlice) self player time) (* sm: " 7-JUL-83 13:54") (* Forwards to Simulator) (← (@ simulator) ParkedAtAlice (GetObjectRec player) time) (SendOut self (LIST (QUOTE ParkedAtAlice) (GetObjectName player) time)) (MailOut self (LIST (QUOTE ParkedAtAlice) (GetObjectRec player) time)))) (RemoteMasterComm.ReUseGame (Method ((RemoteMasterComm ReUseGame) self seed) (* sm: " 7-JUL-83 13:55") (* Forwards to Simulator and other recipients) (← (@ simulator) ReUseGame seed) (← (@ playerInterface) ReUseGame) (SendOut self (LIST (QUOTE ReUseGame) seed)) (MailOut self (LIST (QUOTE ReUseGame) seed)))) (RemoteMasterComm.ReUseGameRequest (Method ((RemoteMasterComm ReUseGameRequest) self) (* sm: " 7-JUL-83 12:49") (* Forwards to DecisionMaker for reusing existing game board) (← (@ decisionMaker) ReUseGameRequest))) (RemoteMasterComm.RemovePlayer (Method ((RemoteMasterComm RemovePlayer) self playerName reason) (* sm: " 7-JUL-83 14:00") (* Forwards to Simulator) (← (@ simulator) RemovePlayer (GetObjectRec playerName) reason) (← (@ playerInterface) RemovePlayer (GetObjectRec playerName) reason) (SendOut self (LIST (QUOTE RemovePlayer) (GetObjectName playerName) reason)) (MailOut self (LIST (QUOTE RemovePlayer) (GetObjectRec playerName) reason)))) (RemoteMasterComm.RemovePlayerRequest (Method ((RemoteMasterComm RemovePlayerRequest) self player reason) (* sm: "10-JUL-83 21:10") (* Request to remove player) (← (@ decisionMaker) RemovePlayerRequest (GetObjectRec player) reason))) (RemoteMasterComm.SellMade (Method ((RemoteMasterComm SellMade) self playerName roadPosition reqQty qty cargoPos reason penaltyAmt) (* sm: " 7-JUL-83 14:09") (* Forwards to Simulator, DecisionMaker, PlayerInterface) (← (@ simulator) SellMade (GetObjectRec playerName) roadPosition reqQty qty cargoPos reason penaltyAmt) (← (@ decisionMaker) SellMade (GetObjectRec playerName) roadPosition reqQty qty cargoPos reason penaltyAmt) (← (@ playerInterface) SellMade (GetObjectRec playerName) roadPosition reqQty qty cargoPos reason penaltyAmt) (SendOut self (LIST (QUOTE SellMade) (GetObjectName playerName) roadPosition reqQty qty cargoPos reason penaltyAmt)) (MailOut self (LIST (QUOTE SellMade) (GetObjectRec playerName) roadPosition reqQty qty cargoPos reason penaltyAmt)))) (RemoteMasterComm.SellRequest (Method ((RemoteMasterComm SellRequest) self player roadPosition commodityIndex qty) (* sm: " 7-JUL-83 12:49") (* Forwards to DecisionMaker) (← (@ decisionMaker) SellRequest (GetObjectRec player) roadPosition commodityIndex qty))) (RemoteMasterComm.SetInitialParameters (Method ((RemoteMasterComm SetInitialParameters) self) (* sm: "10-JUL-83 20:19") (* Sets initial parameters) (←@(@ decisionMaker) startsAfter 10) (SETQ debugMode NIL))) (RemoteMasterComm.SetUp (Method ((RemoteMasterComm SetUp) self game board display) (* sm: "10-JUL-83 19:37") (* Sets up the Standard configuration) (* ARGS: If NIL, then default. If T, then ask user, else use the passed arg) (← self CreateDecisionMaker game) (← self CreateSimulator display) (← self CreateGateWay) (← self SetInitialParameters) (← self StartInterimWorldProcess) (* sends a request to DecisionMaker to create a new game) (← (@ decisionMaker) NewGameRequest board))) (RemoteMasterComm.SpoilCargo (Method ((RemoteMasterComm SpoilCargo) self playerName cargoPos) (* sm: "26-JUL-83 09:53") (* Forwards to Simulator) (← (@ simulator) SpoilCargo (GetObjectRec playerName) cargoPos) (* SpoilCargo is generated locally on each machine so should not be broadcast) (* (SendOut self (LIST (QUOTE SpoilCargo) (GetObjectName playerName) cargoPos))) (MailOut self (LIST (QUOTE SpoilCargo) (GetObjectRec playerName) cargoPos)))) (RemoteMasterComm.StartGame (Method ((RemoteMasterComm StartGame) self begTime endTime) (* sm: " 7-JUL-83 14:38") (* Forwards to simulator, PI, DM, and then starts WorldProcess) (← (@ simulator) StartGame begTime endTime) (* start the WorldProcess) (← self StartWorldProcess) (← (@ playerInterface) StartGame begTime endTime) (← (@ decisionMaker) StartGame begTime endTime) (SendOut self (LIST (QUOTE StartGame) begTime endTime)) (MailOut self (LIST (QUOTE StartGame) begTime endTime)))) (RemoteMasterComm.StartInterimWorldProcess (Method ((RemoteMasterComm StartInterimWorldProcess) self) (* sm: " 8-AUG-83 15:52") (* Starts Interim World Process) (DEL.PROCESS (QUOTE InterimWorldProc)) (←@ gameStarted NIL) (←@ interimWP (ADD.PROCESS (LIST (QUOTE ←) self (QUOTE InterimWorldProcess)) (QUOTE NAME) (QUOTE InterimWorldProc) (QUOTE RESTARTABLE) GameProcRestFlg)))) (RemoteMasterComm.WorldProcess [Method ((RemoteMasterComm WorldProcess) self) (* sm: "16-SEP-83 17:16") (* This is the World Process.) (PROG ([endTime (SETUPTIMER.DATE (GDATE (@ Simulator endTime] [begTime (SETUPTIMER (IntervalToEvent (@ Simulator beginTime] cTime pendReq) (* Wait till it is 5 secs before game) (until (TIMEREXPIRED? begTime (QUOTE MS)) do (COND ((← (@ postman) ReceiveP) (ReceiveIn self))) (BLOCK)) (* ask PI to start User Processes) (* (← (@ playerInterface) StartPlayerProcesses)) (← (@ decisionMaker) RedoGameParameters) (← (@ simulator) RedoGameParameters) (* Start the loop for checking messages from PI) (PutValue (@ simulator) (QUOTE timeLeft) (IDIFFERENCE (@(@ simulator) endTime) (IDATE))) (←@(@ playerInterface) runningPlayer NIL) (← (@ playerInterface) CheckLocalPlayers) (until (TIMEREXPIRED? endTime (QUOTE SECONDS)) do (← (@ playerInterface) ScheduleNextPlayer) (BLOCK) (← (@ decisionMaker) MonitorGame) (BLOCK) (COND ((← (@ postman) ReceiveP) (ReceiveIn self))) (BLOCK)) (* Game is over) (← (@ decisionMaker) MonitorGame T) (←@ gameStarted NIL) (← self CleanGameWorld) (RETURN (QUOTE Done]) (RemoteSlaveComm.AddBandit (Method ((RemoteSlaveComm AddBandit) self name) (* sm: " 7-JUL-83 13:22") (* Add bandit to game) (PROG (msg) (← (@ simulator) AddBandit name) (SETQ msg (LIST (QUOTE AddBandit) name)) (MailOut self msg)))) (RemoteSlaveComm.AddPlayer (Method ((RemoteSlaveComm AddPlayer) self reqID name type truck deniedFlg) (* sm: " 7-JUL-83 13:25") (* Forwards to PI, Simulator, and DecisionMaker) (PROG (msg) (← (@ playerInterface) AddPlayer reqID name type truck deniedFlg) (← (@ simulator) AddPlayer reqID name type truck deniedFlg) (SETQ msg (LIST (QUOTE AddPlayer) reqID name type truck deniedFlg)) (MailOut self msg)))) (RemoteSlaveComm.AddPlayerRequest (Method ((RemoteSlaveComm AddPlayerRequest) self reqID name type truck) (* sm: " 7-JUL-83 13:26") (* Forwards to DecisionMaker) (SendOut self (LIST (QUOTE AddPlayerRequest) reqID name type truck)))) (RemoteSlaveComm.BeginGameRequest (Method ((RemoteSlaveComm BeginGameRequest) self) (* mjs: " 2-AUG-83 11:29") (* Blocks it.) (printout TTY "You cannot start a game from the Slave Machine!!" T) (printout TTY "Wait till the Master Machine sends a StartGame to your machine" T))) (RemoteSlaveComm.BreakCargo [Method ((RemoteSlaveComm BreakCargo) self playerName cargoPos) (* sm: " 7-JUL-83 13:33") (* Forwards to Simulator) (PROG (msg) (← (@ simulator) BreakCargo (GetObjectRec playerName) cargoPos) (MailOut self (LIST (QUOTE BreakCargo) (GetObjectRec playerName) cargoPos]) (RemoteSlaveComm.BuyMade (Method ((RemoteSlaveComm BuyMade) self playerName roadPosition reqQty qty reason penaltyAmt fragility lifetime) (* sm: " 7-JUL-83 13:35") (* Forwards to Simulator) (← (@ simulator) BuyMade (GetObjectRec playerName) roadPosition reqQty qty reason penaltyAmt fragility lifetime) (← (@ playerInterface) BuyMade (GetObjectRec playerName) roadPosition reqQty qty reason penaltyAmt fragility lifetime) (MailOut self (LIST (QUOTE BuyMade) (GetObjectRec playerName) roadPosition reqQty qty reason penaltyAmt fragility lifetime)))) (RemoteSlaveComm.BuyRequest (Method ((RemoteSlaveComm BuyRequest) self player roadPosition qty) (* sm: "10-JUL-83 14:42") (* Forwards to DecisionMaker) (SendOut self (LIST (QUOTE BuyRequest) (COND ((LITATOM player) player) (T (GetObjectName player))) roadPosition qty)))) (RemoteSlaveComm.GameOver (Method ((RemoteSlaveComm GameOver) self) (* sm: "12-JUL-83 22:10") (* Sent to Simulator) (← (@ simulator) GameOver) (MailOut self (LIST (QUOTE GameOver))) (←@ gameStarted NIL))) (RemoteSlaveComm.GasFill (Method ((RemoteSlaveComm GasFill) self prev new qty pr) (* sm: " 7-JUL-83 13:41") (* Forwards to Simulator) (PROG (msg) (← (@ simulator) GasFill prev new qty pr) (SETQ msg (LIST (QUOTE GasFill) prev new qty pr)) (MailOut self msg)))) (RemoteSlaveComm.InterimWorldProcess (Method ((RemoteSlaveComm InterimWorldProcess) self) (* sm: " 8-JUL-83 15:41") (* Interim world process) (until (@ gameStarted) do (COND ((← (@ postman) ReceiveP) (ReceiveIn self))) (BLOCK)) (DEL.PROCESS (THIS.PROCESS)))) (RemoteSlaveComm.MaxMove (Method ((RemoteSlaveComm MaxMove) self player maxMove) (* sm: "10-JUL-83 18:45") (* Forwards to Simulator) (← (@ simulator) MaxMove (GetObjectRec player) maxMove) (MailOut self (LIST (QUOTE MaxMove) (COND ((LITATOM player) player) (T (GetObjectName player))) maxMove)))) (RemoteSlaveComm.MoveMade (Method ((RemoteSlaveComm MoveMade) self playerName fromStop toStop reason penaltyAmount missTurns) (* sm: " 7-JUL-83 13:45") (* Forwards to Simulator) (← (@ simulator) MoveMade (GetObjectRec playerName) fromStop toStop reason penaltyAmount missTurns) (← (@ playerInterface) MoveMade (GetObjectRec playerName) fromStop toStop reason penaltyAmount missTurns) (MailOut self (LIST (QUOTE MoveMade) (GetObjectRec playerName) fromStop toStop reason penaltyAmount missTurns)))) (RemoteSlaveComm.MoveRequest (Method ((RemoteSlaveComm MoveRequest) self player from to reason) (* sm: "10-JUL-83 14:43") (* Forwards to DecisionMaker) (SendOut self (LIST (QUOTE MoveRequest) (COND ((LITATOM player) player) (T (GetObjectName player))) from to reason)))) (RemoteSlaveComm.NewGame (Method ((RemoteSlaveComm NewGame) self seed boardType gameType) (* sm: "12-JUL-83 21:07") (* Forwards to Simulator) (← (@ simulator) NewGame seed boardType gameType) (← self CreatePlayerInterface gameType) (← (@ playerInterface) NewGame seed boardType gameType) (MailOut self (LIST (QUOTE NewGame) seed boardType gameType)))) (RemoteSlaveComm.NewGameRequest (Method ((RemoteSlaveComm NewGameRequest) self board) (* mjs: " 2-AUG-83 11:29") (* Blocks it) (printout TTY "Requests for new games can only be generated at the" " Master Machine" T))) (RemoteSlaveComm.ParkedAtAlice (Method ((RemoteSlaveComm ParkedAtAlice) self player time) (* sm: " 7-JUL-83 13:54") (* Forwards to Simulator) (← (@ simulator) ParkedAtAlice (GetObjectRec player) time) (MailOut self (LIST (QUOTE ParkedAtAlice) (GetObjectRec player) time)))) (RemoteSlaveComm.ReUseGame (Method ((RemoteSlaveComm ReUseGame) self seed) (* sm: " 7-JUL-83 13:55") (* Forwards to Simulator and other recipients) (← (@ simulator) ReUseGame seed) (← (@ playerInterface) ReUseGame) (MailOut self (LIST (QUOTE ReUseGame) seed)))) (RemoteSlaveComm.ReUseGameRequest (Method ((RemoteSlaveComm ReUseGameRequest) self) (* mjs: " 2-AUG-83 11:29") (* Blocks it) (printout TTY "Request to ReUse existing board can be given" T " ONLY at the Master Machine" T))) (RemoteSlaveComm.RemovePlayer (Method ((RemoteSlaveComm RemovePlayer) self playerName reason) (* sm: " 7-JUL-83 14:00") (* Forwards to Simulator) (← (@ simulator) RemovePlayer (GetObjectRec playerName) reason) (← (@ playerInterface) RemovePlayer (GetObjectRec playerName) reason) (MailOut self (LIST (QUOTE RemovePlayer) (GetObjectRec playerName) reason)))) (RemoteSlaveComm.RemovePlayerRequest (Method ((RemoteSlaveComm RemovePlayerRequest) self player reason) (* dgb: "15-JUL-83 00:31") (* Request to remove player) (SendOut self (LIST (QUOTE RemovePlayerRequest) (GetObjectName player) reason)))) (RemoteSlaveComm.SellMade (Method ((RemoteSlaveComm SellMade) self playerName roadPosition reqQty qty cargoPos reason penaltyAmt) (* sm: " 7-JUL-83 14:09") (* Forwards to Simulator, DecisionMaker, PlayerInterface) (← (@ simulator) SellMade (GetObjectRec playerName) roadPosition reqQty qty cargoPos reason penaltyAmt) (← (@ playerInterface) SellMade (GetObjectRec playerName) roadPosition reqQty qty cargoPos reason penaltyAmt) (MailOut self (LIST (QUOTE SellMade) (GetObjectRec playerName) roadPosition reqQty qty cargoPos reason penaltyAmt)))) (RemoteSlaveComm.SellRequest (Method ((RemoteSlaveComm SellRequest) self player roadPosition commodityIndex qty) (* sm: "10-JUL-83 14:43") (* Forwards to DecisionMaker) (SendOut self (LIST (QUOTE SellRequest) (COND ((LITATOM player) player) (T (GetObjectName player))) roadPosition commodityIndex qty)))) (RemoteSlaveComm.SetInitialParameters (Method ((RemoteSlaveComm SetInitialParameters) self) (* sm: "10-JUL-83 20:19") (* Sets initial parameters) (SETQ debugMode T) (SETQ timeTrace T))) (RemoteSlaveComm.SetUp (Method ((RemoteSlaveComm SetUp) self game board display) (* sm: "10-JUL-83 19:37") (* Sets up the Standard configuration) (* Ignores game and board ARGS) (← self CreateSimulator display) (← self CreateGateWay) (← self SetInitialParameters) (← self StartInterimWorldProcess))) (RemoteSlaveComm.SpoilCargo (Method ((RemoteSlaveComm SpoilCargo) self playerName cargoPos) (* sm: " 7-JUL-83 14:32") (* Forwards to Simulator) (← (@ simulator) SpoilCargo (GetObjectRec playerName) cargoPos) (MailOut self (LIST (QUOTE SpoilCargo) (GetObjectRec playerName) cargoPos)))) (RemoteSlaveComm.StartGame (Method ((RemoteSlaveComm StartGame) self begTime endTime) (* sm: "12-JUL-83 21:07") (* Forwards to simulator, PI, DM, and then starts WorldProcess) (← (@ simulator) StartGame begTime endTime) (* start the WorldProcess) (← self StartWorldProcess) (← (@ playerInterface) StartGame begTime endTime) (MailOut self (LIST (QUOTE StartGame) begTime endTime)) (← (@ playerInterface) SelectPlayers))) (RemoteSlaveComm.StartInterimWorldProcess (Method ((RemoteSlaveComm StartInterimWorldProcess) self) (* sm: " 8-AUG-83 15:52") (* Starts Interim World Process) (DEL.PROCESS (QUOTE InterimWorldProc)) (←@ gameStarted NIL) (←@ interimWP (ADD.PROCESS (LIST (QUOTE ←) self (QUOTE InterimWorldProcess)) (QUOTE NAME) (QUOTE InterimWorldProc) (QUOTE RESTARTABLE) GameProcRestFlg)))) (RemoteSlaveComm.WorldProcess [Method ((RemoteSlaveComm WorldProcess) self) (* sm: "16-SEP-83 17:17") (* This is the World Process) (PROG ([endTime (SETUPTIMER.DATE (GDATE (@ Simulator endTime] [begTime (SETUPTIMER (IntervalToEvent (@ Simulator beginTime] cTime pendReq) (* Wait till it is 5 secs before game) (until (TIMEREXPIRED? begTime (QUOTE MS)) do (COND ((← (@ postman) ReceiveP) (ReceiveIn self))) (BLOCK)) (* ask PI to start User Processes) (* (← (@ playerInterface) StartPlayerProcesses)) (← (@ simulator) RedoGameParameters) (* Start the loop for checking messages from PI) (PutValue (@ simulator) (QUOTE timeLeft) (IDIFFERENCE (@(@ simulator) endTime) (IDATE))) (←@(@ playerInterface) runningPlayer NIL) (← (@ playerInterface) CheckLocalPlayers) (until (TIMEREXPIRED? endTime (QUOTE SECONDS)) do (← (@ playerInterface) ScheduleNextPlayer) (BLOCK) (for x in (@(@ playerInterface) suspendedPlayers) when (SETQ pendReq (@ x pendingRequest)) do (←@ x pendingRequest NIL) (PutValue x (QUOTE pendingRequest) (IDATE) (QUOTE whenSent)) (PutValue x (QUOTE pendingRequest) pendReq (QUOTE inProcess)) (ApplyMethod self (CAR pendReq) (CDR pendReq))) (COND ((← (@ postman) ReceiveP) (ReceiveIn self))) (BLOCK)) (while (@ gameStarted) do (COND ((← (@ postman) ReceiveP) (ReceiveIn self))) (BLOCK)) (← self CleanGameWorld) (RETURN (QUOTE Done]) (TimeTruckinDM.ChargeTime (Method ((TimeTruckinDM ChargeTime) self player clockTime) (* sm: "28-JUN-83 10:06") (* Calculates the actual time to be charged to player) (* if clockTime is NIL, MinMoveTime is charged) (PROG (time charge) [COND ((NULL clockTime) (SETQ charge (@@ MinMoveTime))) (T [SETQ time (IDIFFERENCE clockTime (IPLUS (@ unchargedTime) (@@ player Handicap] [SETQ charge (SETQ time (FIX (QUOTIENT (PLUS 500 (TIMES time HandicapRatio)) 1000] (COND ((LESSP time (@@ MinMoveTime)) (SETQ charge (@@ MinMoveTime))) ((GREATERP time (@@ MaxMoveTime)) (* player exceeded limit. Yank from game) (← self RemovePlayer player (CONCAT "Too much time taken " charge)) (SETQ charge 0] (←@ player timeUsed (IPLUS charge (@ player timeUsed))) (←@ timeRemaining (IDIFFERENCE (@ timeRemaining) charge)) (AND debugTimeTrace (WriteGameStatus (CONCAT "Time Used: by " (@ player driver)) (CONCAT "Clock(ms) " clockTime) (CONCAT "Used(sec)" time))) (AND timeTrace (WriteGameStatus "Time Charged to: " (@ player driver) (CONCAT " " charge " sec"))) (RETURN charge)))) (TimeTruckinDM.CheckAlice [Method ((TimeTruckinDM CheckAlice) self player) (* sm: "13-JUL-83 09:44") (* check AlicesRestaurant's before each turn) (for x in (@ alices) bind parked do (for loc in (QUOTE (parkingPlace1 parkingPlace2)) do (PROG (time msg reason) (COND ((SETQ parked (GetValue x loc)) (COND ([OR (AND NIL (* This condition is blocked out) (GREATERP (GetValue x loc (QUOTE howLong)) 3) (SETQ msg "Stayed at Alices more than 3 turns") (SETQ reason (QUOTE AliceTurn))) (AND (GREATERP (GetValue x loc (QUOTE howLong)) 0) (GREATERP [SETQ time (IDIFFERENCE (IDATE) (GetValue x loc (QUOTE timeParked] (@ self aliceStay MaxTime)) (SETQ msg (CONCAT "Spent too much time at Alice: " time)) (SETQ reason (QUOTE AliceTime] (* stayed there too long) (COND ((← (@ unionHall) RoomToPark?) (BrokenRules parked msg NIL 1 "Forcibly moved to UnionHall") (← self MoveRequest parked (FindLocIndex x (@ roadStops)) (FindLocIndex (@ unionHall) (@ roadStops)) reason)) (T (* UnionHall is temporarily filled) (BrokenRules parked msg NIL 1 "Will be moved to UnionHall next turn"]) (TimeTruckinDM.InitializeGameParameters (Method ((TimeTruckinDM InitializeGameParameters) self) (* sm: " 8-JUL-83 11:06") (* Initializes critical variables for new game to run) (←Super self InitializeGameParameters) (PutValue self (QUOTE replenishFreq) (@ beginTime) (QUOTE LastTime)) (PutValue self (QUOTE banditFreq) (@ beginTime) (QUOTE LastTime)))) (TimeTruckinDM.MoveBandits [Method ((TimeTruckinDM MoveBandits) self) (* sm: " 5-JUL-83 12:05") (* randomly moves bandits around on the board before each turn) (PROG ((ctime (IDATE))) (COND ((IGREATERP (IDIFFERENCE ctime (@ self banditFreq LastTime)) (@ banditFreq)) (PutValue self (QUOTE banditFreq) ctime (QUOTE LastTime)) (* Only move once in a while if you are a bandit) (←Super self MoveBandits]) (TimeTruckinDM.RedoGameParameters (Method ((TimeTruckinDM RedoGameParameters) self) (* sm: " 4-AUG-83 13:16") (* Change game parameters based on players in the game) (PROG NIL (←Super self RedoGameParameters) [PutValue self (QUOTE banditFreq) (ITIMES (@@ MinMoveTime) (LENGTH (@ players)) (GetValue self (QUOTE banditFreq) (QUOTE BanditFactor] (* (PutValue self (QUOTE replenishFreq) (ITIMES (@@ MinMoveTime) (LENGTH (@ players)) (GetValue self (QUOTE replenishFreq) (QUOTE ReplenishFactor))))) (PutValue self (QUOTE replenishFreq) NotSetValue) (RETURN NIL)))) (TimeTruckinDM.ReplenishQty [Method ((TimeTruckinDM ReplenishQty) self) (* sm: " 5-JUL-83 12:06") (* Checks if time to replenish) (PROG ((ctime (IDATE))) (COND ((IGREATERP (IDIFFERENCE ctime (@ self replenishFreq LastTime)) (@ replenishFreq)) (PutValue self (QUOTE replenishFreq) ctime (QUOTE LastTime)) (←Super self ReplenishQty]) (TimeTruckinPI.RunGame (Method ((TimeTruckinPI RunGame) self players) (* sm: "27-JUN-83 11:02") (* This is the main loop that runs the game) (while (GREATERP (@ timeRemaining) 0) bind currPlayer begTime chargeTime playerRet do (WaitIfControlKey "Beginning of Game Loop") [COND ((ZEROP (IMOD (@ timeRemaining) 10)) (WriteGameStatus NIL "Time Remaining: " (@ timeRemaining] (← self ReplenishQty) (← self MoveBandits) [for p bind (minTimeSoFar ← 10000000) in (@ players) do (COND ((ILESSP (@ p timeUsed) minTimeSoFar) (SETQ currPlayer p) (SETQ minTimeSoFar (@ p timeUsed] (←@ currentPlayer (SETQ currentPlayer currPlayer)) (SETQ forcedStop NIL) (* update commodity status affected by moves) (for y in (@(@ currPlayer truck) cargo) do (DoFringeMethods y (QUOTE UpdateStatus))) (←@ unchargedTime 0) [COND ((FMEMB currPlayer (@ loseTurn)) (WriteGameStatus (CONCAT (@ currPlayer driver) " lost his turn")) (SETQ chargeTime (← self ChargeTime currPlayer)) (←@ loseTurn (REMOVE currPlayer (@ loseTurn))) (←@ lastMoved NIL)) (T (SETQ maxMove (RAND 1 (@@(@ currPlayer truck) MaxDist))) (* (WriteGameStatus (@ x driver) " can MOVE max " maxMove)) (SETQ begTime (CLOCK)) [COND (debugMode (← currPlayer TakeTurn)) (T (SETQ playerRet (ERSETQ (← currPlayer TakeTurn))) (COND ((NULL playerRet) (← self RemovePlayer currPlayer "Player crashed on a Bug"] (←@ lastMoved NIL) (SETQ chargeTime (← self ChargeTime currPlayer (IDIFFERENCE (CLOCK) begTime] (←@ currPlayer movesMade (ADD1 (@ currPlayer movesMade))) (← self UpdateAlice currPlayer chargeTime) (← self CheckAlice currPlayer)))) (TruckinBoard.AssignRoadStops [Method ((TruckinBoard AssignRoadStops) self) (* sm: "27-JUN-83 18:08") (* * Assign RoadStops to the current GameBoard) (PROG ((numStopsWanted (ITIMES (@@ numRows) (@@ numColumns))) numStopsKnown stops rs stillNeeded (availRS (APPEND (SetRoadStops))) count) (* generate dummy board) (for i from 1 to numStopsWanted do (SETQ stops (CONS NIL stops))) (* install BoardPattern) (SubstituteStop stops 1 (←New ($ UnionHall))) (for x in BoardPattern do (SubstituteStop stops (FindRandomNIL stops) (← ($ AlicesRestaurant) New))) (for x in MustStops do (SubstituteStop stops (FindRandomNIL stops) (← (GetObjectRec x) New))) (SETQ stillNeeded (for x in stops count (NULL x))) (SETQ availRS (FillerRoadStops (DefaultMustStops))) (SETQ numStopsKnown (FLENGTH availRS)) [for i from stillNeeded to 10 by -1 do [SETQ rs (CAR (NTH availRS (RAND 1 numStopsKnown] [COND ((ILEQ i numStopsKnown) (SETQ availRS (DREMOVE rs availRS)) (SETQ numStopsKnown (FLENGTH availRS] (SubstituteStop stops (FindRandomNIL stops) (←New (GetClassRec rs] [for i from 9 to 1 by -1 do [SETQ rs (CAR (NTH availRS (RAND 1 numStopsKnown] [COND ((ILEQ i numStopsKnown) (SETQ availRS (DREMOVE rs availRS)) (SETQ numStopsKnown (FLENGTH availRS] (SubstituteStop stops (FindFirstNIL stops) (←New (GetClassRec rs] (SETQ StopsNotUsed availRS) (RETURN (←@ roadStops stops]) (TruckinBoard.AttachToGame (Method ((TruckinBoard AttachToGame) self game) (* sm: "28-JUN-83 09:33") (* attaches self to game) (* returns previous game (if any) to which attached) (PROG (prevGame) (SETQ prevGame (@ simulator)) (COND ((GetObjectRec prevGame) (← prevGame UnattachBoard))) (PutValue self (QUOTE simulator) game) (RETURN prevGame)))) (TruckinBoard.CreateGameBoard (Method ((TruckinBoard CreateGameBoard) self region title) (* sm: " 5-JUL-83 18:38") (* * Creates a new Window for the gameBoard.) (PROG NIL (SETQ gameWindow (CREATEW region title)) (←@ gameWindow gameWindow) (← self InitializeGameWindow) (← self MakeDriveBitMaps) (RETURN gameWindow)))) (TruckinBoard.DisplayGameBoard (Method ((TruckinBoard DisplayGameBoard) self) (* sm: "29-JUN-83 15:51") (* * Displays the gameBoard. ReAllocates gameBoard window if needed.) (PROG (region (xMargin 2) (xExtra 10) (yExtra 20) width height (k 0) (date (DATE))) (* * Initialize and display the gameWindow if needed.) (SETQ gameWindow (@ gameWindow)) (COND [(NOT gameWindow) (* New window if needed.) [SETQ width (IPLUS xExtra (ITIMES (@@ numColumns) (@@($ RoadStop) Width] [SETQ height (IPLUS yExtra (ITIMES (@@ numRows) (IPLUS (@@($ RoadStop) Height) (@@($ Player) Height] (SETQ region (create REGION LEFT ← 10 BOTTOM ← 10 WIDTH ← width HEIGHT ← height)) (←@ windowRegion region) (SETQ gameWindow (← self CreateGameBoard region (CONCAT "TRUCKIN Knowledge System. Created by: DANIEL BOBROW, SANJAY MITTAL, and MARK STEFIK. Copyright (c) " (CONCAT "19" (SUBSTRING date 8 9)) " Xerox Corp" " " (DATE] (T (← self InitializeGameWindow))) (← self DrawRoadMarks) (for roadStop in (@ roadStops) do (← roadStop Display)) (RETURN self)))) (TruckinBoard.DrawRoadMarks (Method ((TruckinBoard DrawRoadMarks) self) (DrawRoadMarks self))) (TruckinBoard.InitializeRoadStops (Method ((TruckinBoard InitializeRoadStops) self seed) (* sm: "28-JUN-83 09:35") (* Initializes RoadStop qty and pr) (RANDSET seed) (for x in (@ roadStops) do (← x Initialize)))) (TruckinBoard.MakeDriveBitMaps (Method ((TruckinBoard MakeDriveBitMaps) self) (* sm: "27-JUN-83 18:09") (* Creates Bit maps for Trucks) (MakeDriveBitMaps 1))) (TruckinBoard.NewBoard (Method ((TruckinBoard NewBoard) self seed) (* sm: " 5-JUL-83 18:40") (* Creates and displays a new game board) (RANDSET seed) (* Display the board) (SETQ gameWindow NIL) (← self Initialize) (← self AssignRoadStops) (* Pick Road Stops) (* (← self DisplayGameBoard)) (* Place RoadStops on the board) (← self PlaceRoadStops) (* Generate initial qty and pr for applicable roadStops) (← self InitializeRoadStops (RANDSET)) self)) (TruckinBoard.PlaceRoadStops [Method ((TruckinBoard PlaceRoadStops) self) (* sm: "27-JUN-83 18:09") (* * Place the RoadStops onto the GameBoard.) (PROG ((numRows (@@ numRows)) (numColumns (@@ numColumns)) (roadStops (@ roadStops)) (milePost 0) roadStop x y xIncr yIncr prev) (* * Compute the x and y initial values and increments.) (SETQ yIncr (IPLUS (@@($ RoadStop) Height) (@@($ Player) Height))) (SETQ xIncr (@@($ RoadStop) Width)) (SETQ y (ITIMES numRows yIncr)) (* * Place the RoadStops on the board.) (for row from numRows to 1 by -2 do (SETQ x 0) (SETQ y (IDIFFERENCE y yIncr)) (for col from 1 to numColumns do (SETQ roadStop (pop roadStops)) (COND (prev (←@ prev next roadStop))) (←@ roadStop prev prev) (SETQ prev roadStop) (SETQ milePost (ADD1 milePost)) (← roadStop Place x y milePost (QUOTE Right)) (SETQ x (IPLUS x xIncr))) (SETQ x (IDIFFERENCE x xIncr)) (SETQ y (IDIFFERENCE y yIncr)) (for col from numColumns to 1 by -1 do (SETQ roadStop (pop roadStops)) (←@ prev next roadStop) (←@ roadStop prev prev) (SETQ prev roadStop) (SETQ milePost (ADD1 milePost)) (← roadStop Place x y milePost (QUOTE Left)) (SETQ x (IDIFFERENCE x xIncr]) (TruckinBoard.ReInitializeRoadStops (Method ((TruckinBoard ReInitializeRoadStops) self seed) (* sm: "29-JUN-83 14:34") (* Reinitializes roadstops) (RANDSET seed) (for x in (@ roadStops) do (← x ReInitialize)))) (TruckinBoard.ReUseBoard (Method ((TruckinBoard ReUseBoard) self seed) (* sm: " 5-JUL-83 18:40") (* Reuses game board: displaying afresh) (← self Initialize) (← self ReInitializeRoadStops (RANDSET)) self)) (TruckinBoard.RemovePlayer (Method ((TruckinBoard RemovePlayer) self player) (* sm: "27-JUN-83 18:09") (* Sent to game board so it can remove player from board) (PROG ((truck (@ player truck)) loc) (SETQ loc (@ truck location)) (COND (loc (← loc Unpark player))) (RETURN player)))) (TruckinCommInterface.CleanGameWorld (Method ((TruckinCommInterface CleanGameWorld) self) (* sm: "16-SEP-83 17:17") (* Cleans up the game world after game over) (← (@ playerInterface) DeletePlayerProcesses) (AND GameControlWindow (CLOSEW GameControlWindow)))) (TruckinCommInterface.CreateDecisionMaker (Method ((TruckinCommInterface CreateDecisionMaker) self game) (* sm: " 5-JUL-83 18:41") (* Creates a new DecisionMaker) (* ARGS: If NIL, then default. If T, then ask user, else use the passed arg) (PROG (dm gameClass) [COND [(AND (SETQ gameClass (GetClassRec game)) (← gameClass Subclass (QUOTE TruckinDecisionMaker] [(NULL game) (SETQ gameClass (GetClassRec (GetValue self (QUOTE decisionMaker) (QUOTE DefaultClass] (T (SETQ gameClass (GetClassRec (INMENU "Select the game" (← ($ TruckinDecisionMaker) List (QUOTE Subs] (SETQ dm (← gameClass New)) (SETQ DecisionMaker dm) (←@ decisionMaker dm) (RETURN dm)))) (TruckinCommInterface.CreateGateWay (Method ((TruckinCommInterface CreateGateWay) self machineName postalAddress) (* sm: "12-JUL-83 18:51") (* creates a gateway and links it) (PROG (gclass newP machineID) (OR machineName (SETQ machineName (INTTY "Give me a name for your machine: " NIL "An atom which identifies your machine" T))) (OR postalAddress (SETQ postalAddress (INTTY "What is the address of the postMaster machine? " NIL "An integer which is the PupAddress of the machine" T))) [SETQ gclass (GetClassRec (GetValue self (QUOTE postman) (QUOTE DefaultClass] (SETQ newP (← gclass New)) (SETQ Postman newP) (←@ postman newP) (* Link to PostMaster) (SETQ machineID (← Postman GetPostalBox machineName postalAddress)) (←@ machineID machineID) (RETURN Postman)))) (TruckinCommInterface.CreatePlayerInterface (Method ((TruckinCommInterface CreatePlayerInterface) self gameType) (* sm: "10-JUL-83 20:22") (* Create a PlayerInterface (if needed) matching gameType) (PROG (currentPI cpiClass piClass newPI) (* currently not checking for any prior PI. My do so later if needed) [SETQ piClass (GetClassRec (GetClassValue (GetObjectRec gameType) (QUOTE PlayerInterface] [COND ((NULL piClass) (* no matching PlayerInterface class found. ask user) (SETQ piClass (GetClassRec (INMENU (CONCAT "Select PlayerInterface for game type: " gameType) (← ($ TruckinPlayerInterface) List!(QUOTE Subs] (SETQ newPI (← piClass New)) (←@ playerInterface newPI) (SETQ PI (SETQ PlayerInterface newPI)) (RETURN PlayerInterface)))) (TruckinCommInterface.CreateSimulator [Method ((TruckinCommInterface CreateSimulator) self display) (* sm: " 9-SEP-83 15:02") (* Creates a new simulator) (PROG (sim gameClass) [COND [(AND (SETQ gameClass (GetClassRec display)) (← gameClass Subclass (QUOTE TruckinSimulator] [(NULL display) (SETQ gameClass (GetClassRec (GetValue self (QUOTE simulator) (QUOTE DefaultClass] (T (SETQ gameClass (GetClassRec (INMENU "Select the game" (← ($ TruckinSimulator) List (QUOTE Subs] (SETQ sim (← gameClass New)) (SETQ Simulator sim) (RETURN (←@ simulator sim]) (TruckinCommInterface.SetInitialParameters (Method ((TruckinCommInterface SetInitialParameters) self) (* sm: "10-JUL-83 19:36") (* Sets initial parameters) self)) (TruckinCommInterface.StartWorldProcess (Method ((TruckinCommInterface StartWorldProcess) self) (* sm: " 8-AUG-83 15:50") (* Starts world process) (PROG (hand) (DEL.PROCESS (FIND.PROCESS (QUOTE WorldProcess))) (SETQ hand (ADD.PROCESS (LIST (QUOTE ←) self (QUOTE WorldProcess)) (QUOTE NAME) (QUOTE WorldProcess) (QUOTE RESTARTABLE) GameProcRestFlg)) (←@ worldProcess hand) (←@ gameStarted T) (GameControlMenu) (RETURN hand)))) (TruckinCommInterface.TellMe [Method ((TruckinCommInterface TellMe) self obj) (* mjs: " 2-AUG-83 11:30") (* Adds obj to broadcastList) (COND ([AND (GetObjectRec obj) (NOT (FMEMB (GetObjectRec obj) (@ broadcastList] (←@ broadcastList (CONS (GetObjectRec obj) (@ broadcastList))) (printout TTY obj " is now on the broadcast list. Welcome to the game!!" T]) (TruckinDecisionMaker.AddBandit [Method ((TruckinDecisionMaker AddBandit) self name) (* sm: "30-JUN-83 19:30") (* Add bandit to list) (←@ bandits (CONS (GetObjectRec name) (@ bandits]) (TruckinDecisionMaker.AddPlayer (Method ((TruckinDecisionMaker AddPlayer) self reqID name type truck deniedFlg) (* mjs: " 2-AUG-83 11:30") (* If player added, do initial placing for him) (PROG (player locs nextLoc) (* Check if request denied) (COND (deniedFlg (RETURN NIL))) (SETQ player (GetObjectRec name)) (COND ((FMEMB player (@ players)) (printout TTY "Shouldnt happen!! Attempt to add player" "already in game (in Decision Maker) " name T) (HELPCHECK "Adding player already in game!") (RETURN NIL))) (←@ players (CONS player (@ players))) (* position the player on the board) (SETQ locs (@ roadStops)) (SETQ nextLoc (CAR locs)) (SETQ locs (CDR locs)) LOOP(COND ((← nextLoc RoomToPark?) (← Communicator MoveMade player 0 (@ nextLoc milePost) (QUOTE InitialPlacing))) (T (SETQ nextLoc (CAR locs)) (SETQ locs (CDR locs)) (GO LOOP))) (RETURN player)))) (TruckinDecisionMaker.AddPlayerRequest [Method ((TruckinDecisionMaker AddPlayerRequest) self reqID name type truck) (* sm: "10-JUL-83 20:48") (* Decides if a new player can be added or not) (PROG (player locs nextLoc) (* Check if another object of name) (SETQ player (GetObjectRec name)) (RETURN (COND ([OR [AND player (NOT (← player InstOf!(QUOTE Player] (AND player (FMEMB name (@ playerNames] (* conflict in player request) (← Communicator AddPlayer reqID name type truck (QUOTE NameConflict))) (T (←@ playerNames (CONS player (@ playerNames))) (← Communicator AddPlayer reqID name type truck NIL]) (TruckinDecisionMaker.AttachSimulator (Method ((TruckinDecisionMaker AttachSimulator) self sim) (* sm: "28-JUN-83 11:45") (* Attaches local simulator by copying relevant info) (←@ simulator sim) (←@ roadStops (@(@ simulator) roadStops)))) (TruckinDecisionMaker.BeginGameRequest (Method ((TruckinDecisionMaker BeginGameRequest) self) (* sm: " 5-JUL-83 18:56") (* Starts the game) (PROG (move nextLoc locs) (← self ChangeGameParameters) (←@ alices (for x in (@ roadStops) when (← x InstOf!(QUOTE AlicesRestaurant)) collect x)) (←@ unionHall (CAR (@ roadStops))) [COND ((AND banditCount (GREATERP banditCount 0)) (for banditIndex from 1 to (IMIN banditCount (FLENGTH banditNames)) do (← Communicator AddBandit (CAR (NTH banditNames banditIndex] (←@ beginTime (IPLUS (IDATE) (ITIMES (@ startsAfter) 60))) (←@ endTime (IPLUS (@ beginTime) (ITIMES (@ gameDuration) 60))) (← self InitializeGameParameters) (← Communicator StartGame (@ beginTime) (@ endTime)) (RETURN T)))) (TruckinDecisionMaker.BuyMade (Method ((TruckinDecisionMaker BuyMade) self player roadPosition reqQty qty reason penaltyAmt fragility lifetime) (* sm: " 1-JUL-83 09:37") (* Dummy for now) self)) (TruckinDecisionMaker.BuyRequest [Method ((TruckinDecisionMaker BuyRequest) self player roadPosition qty) (* sm: " 6-JUL-83 13:42") (* message sent to DecisionMaker to BUY qty at roadPosition) (PROG (truck loc commodity intendedLoc (ctime (IDATE))) (* check if truck at a producer roadstop) (SETQ truck (@ player truck)) (SETQ loc (@ truck location)) (SETQ intendedLoc (CAR (NTH (@ roadStops) roadPosition))) [COND ((GREATERP ctime (@ Simulator endTime)) (RETURN (← Communicator BuyMade player roadPosition qty 0 (QUOTE GameOver] [COND ((NOT (EQ loc intendedLoc)) (* player not where he thought he was) (RETURN (← Communicator BuyMade player roadPosition qty 0 (QUOTE IncorrectLoc] [COND ([NOT (AND (GetObjectRec loc) (← loc InstOf!(QUOTE Producer] (RETURN (← Communicator BuyMade player roadPosition qty 0 (QUOTE NotProducer] (* Update game status window.) (* (WriteGameStatus (@ currentPlayer driver) " Buys " (CONCAT qty " " (GetObjectName (@@ loc Commodity)) " units"))) (* check if qty is available at RoadStop) [COND ((ZEROP qty) (RETURN (← Communicator BuyMade player roadPosition qty 0 (QUOTE Zero] [COND ((AND qty (GREATERP qty (@ loc qty))) (RETURN (← Communicator BuyMade player roadPosition qty 0 (QUOTE MoreThanAvailable) .01] (* transfer ownership) (SETQ commodity (← (@@ loc Commodity) New (@ loc pr) (COND (qty qty) (T (@ loc qty))) loc)) (RETURN (COND [(← commodity CanTransfer player NIL qty) (← Communicator BuyMade player roadPosition qty (@ commodity qty) NIL NIL (COND ((← commodity InstOf!(QUOTE FragileCommodity)) (@ commodity fragility)) (T NIL)) (COND ((← commodity InstOf!(QUOTE PerishableCommodity)) (@ commodity lifetime)) (T NIL] (T (* there was some error during transaction) (← Communicator BuyMade player roadPosition qty 0 FCTReason FCTPenalty]) (TruckinDecisionMaker.ChangeGameParameters (Method ((TruckinDecisionMaker ChangeGameParameters) self) (* sm: " 5-JUL-83 17:33") (* Changes gameParameters via inspector) (PROG (gp) (SETQ gp (GetItHere self (QUOTE gameParameters))) (COND ((EQ gp NotSetValue) (SETQ gp (← (GetObjectRec (@ gameParameters)) New)) (←@ gameParameters gp))) (PROMPT "Change Game Parameters by using the displayed Inspector." "When done, click DONE") (← gp SetUp) (while (NOT GameParaSet) do (TOTOPW GameParamW) (TOTOPW GameCommandW) (DISMISS 500)) (← gp StorePara) (RETURN T)))) (TruckinDecisionMaker.CheckAlice [Method ((TruckinDecisionMaker CheckAlice) self) (* sm: "27-JUN-83 10:56") (* check AlicesRestaurant's before each turn) (for x in (@ alices) do (for loc in (QUOTE (parkingPlace1 parkingPlace2)) do (PROGN (COND ((GetValue x loc) (PutValue x loc (ADD1 (GetValue x loc (QUOTE howLong))) (QUOTE howLong)) (COND ((GREATERP (GetValue x loc (QUOTE howLong)) 3) (* stayed there too long) (SETQ currentPlayer (GetValue x loc)) (COND ((← (@ unionHall) RoomToPark?) (BrokenRules currentPlayer "Stayed at Alices more than 3 turns" NIL 1 "Forcibly moved to UnionHall") (← self MoveRequest currentPlayer (FindLocIndex x (@ roadStops)) (FindLocIndex (@ unionHall) (@ roadStops)) (QUOTE AliceTurn))) (T (* UnionHall is temporarily filled) (BrokenRules currentPlayer "Stayed at Alices more than 3 turns" NIL 1 "Will be moved to UnionHall next turn"]) (TruckinDecisionMaker.ForcedMove [Method ((TruckinDecisionMaker ForcedMove) self player curLoc maxMilePost reason) (* sm: "28-JUN-83 09:57") (* determines the loc to move currentPlayer as a forced move close to maxMilePost) (PROG ((cmile (@ curLoc milePost)) newLoc) [SETQ newLoc (COND ((GREATERP cmile maxMilePost) (for i from maxMilePost to cmile thereis (← (CAR (NTH (@ roadStops) i)) RoomToPark?))) (T (for i from maxMilePost to cmile by -1 thereis (← (CAR (NTH (@ roadStops) i)) RoomToPark?] [COND ((NULL newLoc) (* no room to park anywhere) (RETURN (← Communicator MoveMade player cmile cmile (QUOTE NoRoom] (SETQ newLoc (CAR (NTH (@ roadStops) newLoc))) (RETURN (← self MoveTruck player curLoc newLoc reason]) (TruckinDecisionMaker.GameOver (Method ((TruckinDecisionMaker GameOver) self) (* sm: " 6-JUL-83 13:13") (* Sent when game is over) (← Communicator GameOver))) (TruckinDecisionMaker.GiveAliceBonus (Method ((TruckinDecisionMaker GiveAliceBonus) self atAlice) (* sm: "27-JUN-83 10:56") (* Dummy method) self)) (TruckinDecisionMaker.InitializeGameParameters (Method ((TruckinDecisionMaker InitializeGameParameters) self) (* sm: " 8-JUL-83 11:07") (* Initializes critical variables for new game to run) (AND gameStatusWindow (CLEARW gameStatusWindow)) (COND (truckinLogHandle (CLOSEF? truckinLogHandle))) (COND [truckinLogFlg (SETQ truckinLogHandle (OPENFILE truckinLogFile (QUOTE OUTPUT] (T (SETQ truckinLogHandle NIL))) (←@ lastMoved NIL) (←@ loseTurn NIL))) (TruckinDecisionMaker.MonitorGame [Method ((TruckinDecisionMaker MonitorGame) self gameOverFlg) (* dgb: "15-JUL-83 00:16") (* Monitors the game to move bandits, replenish qty, check alice, and signal game end.) (PROG ((ctime (IDATE))) (COND (gameOverFlg (← self GameOver)) ((IGREATERP ctime (@ Simulator endTime))) (T (← self MoveBandits) (← self ReplenishQty) (← self CheckAlice]) (TruckinDecisionMaker.MonitorProcess [Method ((TruckinDecisionMaker MonitorProcess) self) (* sm: " 5-JUL-83 15:00") (* Monitors the game to move bandits, replenish qty, check alice, and signal game end) (PROG (begTime endTime cTime) (SETQ endTime (SETUPTIMER (@ Simulator endTime) NIL NIL (QUOTE SECONDS))) [BLOCK NIL (SETUPTIMER (IntervalToEvent (@ Simulator beginTime] (until (TIMEREXPIRED? endTime (QUOTE SECONDS)) do (← self MoveBandits) (← self ReplenishQty) (← self CheckAlice) (BLOCK)) (← self GameOver) (RETURN (QUOTE GameOver]) (TruckinDecisionMaker.MoveBandits (Method ((TruckinDecisionMaker MoveBandits) self) (* mjs: " 4-AUG-83 10:27") (* randomly moves bandits around on the board before each turn) (PROG ((maxLoc (FLENGTH (@ roadStops))) loc curLoc banditLoc direction truck cmile dmile) (WriteGameStatus NIL "Watch out!! The Bandits are Moving") [for x in (@ bandits) do (PROGN (SETQ truck (@ x truck)) (SETQ direction (@ x direction)) (SETQ curLoc (@ truck location)) [SETQ banditLoc (COND ((NULL (GetObjectRec curLoc)) (RAND 1 maxLoc)) (T (@ curLoc milePost] [COND ((AND (EQ direction (QUOTE F)) (GREATERP (IPLUS banditLoc banditMoveRange) maxLoc)) (←@ x direction (QUOTE B))) ((AND (EQ direction (QUOTE B)) (LESSP (IDIFFERENCE banditLoc banditMoveRange) 1)) (←@ x direction (QUOTE F] [SETQ loc (CAR (NTH (@ roadStops) (COND [(RandomRoomAvailable [COND ((EQ direction (QUOTE F)) banditLoc) (T (IMAX 1 (IDIFFERENCE banditLoc banditMoveRange] (COND ((EQ direction (QUOTE B)) banditLoc) (T (IMIN maxLoc (IPLUS banditLoc banditMoveRange] (T (RandomRoomAvailable 1 maxLoc] [SETQ cmile (COND ((NULL curLoc) 0) (T (FindLocIndex curLoc (@ roadStops] (SETQ dmile (FindLocIndex loc (@ roadStops))) (WriteGameStatus (@ x driver) " Moves to " (@@ loc RoadSign)) (← Communicator MoveMade x cmile dmile (QUOTE BanditMove] (RETURN T)))) (TruckinDecisionMaker.MoveCheckingHazards [Method ((TruckinDecisionMaker MoveCheckingHazards) self player curLoc newLoc reason) (* sm: "28-JUN-83 09:59") (* moves truck checking for hazards along the way. Called by GameMaster.MoveTruck) (PROG (cmile (dmile (@ newLoc milePost)) whoStopped rs forcedIndex dist fuelNeeded (truck (@ player truck))) [COND ((NOT (EQ curLoc (@ truck location))) (INTTYL "Bug in MoveCheckingHazards" NIL "Type return to continue.") (SETQ curLoc (@ truck location] (SETQ cmile (@ curLoc milePost)) (SETQ dist (IDIFFERENCE (IMAX cmile dmile) (IMIN cmile dmile))) (* check for WeighStations and Bandits) [SETQ forcedIndex (for i from cmile to dmile by (COND ((GREATERP cmile dmile) -1) (T 1)) when (AND (NOT (EQUAL i cmile)) (NOT (EQUAL i dmile))) eachtime (SETQ rs (CAR (NTH (@ gameMaster roadStops) i))) thereis (SETQ whoStopped (← rs GoingPast player dist] (COND (forcedIndex (SETQ newLoc (CAR (NTH (@ roadStops) forcedIndex))) (SETQ dmile forcedIndex))) (RETURN (← Communicator MoveMade player cmile dmile (OR whoStopped reason]) (TruckinDecisionMaker.MoveMade [Method ((TruckinDecisionMaker MoveMade) self player fromStop toStop reason penaltyAmount missTurns) (* sm: "26-JUL-83 09:45") (* Generates new MaxMove for player and checks for Alice overstay) (* update commodity status affected by moves) (COND ((← player InstOf!(QUOTE Player)) (* if not bandit or gasman) (* (for y in (@ (@ player truck) cargo) do (DoFringeMethods y (QUOTE UpdateStatus)))) (COND ((EQ reason (QUOTE GameOver))) (T (← Communicator MaxMove player (RAND 1 (@@(@ player truck) MaxDist]) (TruckinDecisionMaker.MoveRequest [Method ((TruckinDecisionMaker MoveRequest) self player from to reason) (* sm: " 6-SEP-83 14:52") (* sent to DecisionMaker for deciding if move can be made) (* reason, if given is used for system generated requests and is not charged as a move to player) (PROG ((truck (@ player truck)) curLoc moves (cli from) (nli to) (gb GameBoard) maxLoc (maxMove (@ player maxMove)) (newLoc to) fromLoc (ctime (IDATE))) (SETQ maxLoc (ITIMES (@@ gb numRows) (@@ gb numColumns))) (SETQ curLoc (@ truck location)) (SETQ fromLoc (CAR (NTH (@ roadStops) from))) [COND ((GREATERP ctime (@ Simulator endTime)) (RETURN (← Communicator MoveMade player from from (QUOTE GameOver] [COND ((NOT (EQ curLoc fromLoc)) (* player not where he thought he was) (RETURN (← Communicator MoveMade player from from (QUOTE IncorrectLoc] (* (COND ((AND (NOT reason) (EQ player (@ lastMoved))) (RETURN (← Communicator MoveMade player cli cli (QUOTE ConsecutiveMove))))) (COND ((NOT reason) (* set last moved only when no System Reason) (←@ lastMoved player)))) [COND [(NUMBERP to) (COND [(LESSP nli 1) (RETURN (← Communicator MoveMade player cli cli (QUOTE OffBoardBeg] [(GREATERP nli maxLoc) (RETURN (← Communicator MoveMade player cli cli (QUOTE OffBoardEnd] (T (SETQ newLoc (CAR (NTH (@ roadStops) nli] [(FMEMB to (@ roadStops)) (SETQ nli (FindLocIndex to (@ roadStops] (T (BrokenRules player (CONCAT "Illegal location: " to)) (RETURN (← Communicator MoveMade player cli cli (QUOTE IllegalLoc] (* if asked to go to UnionHall dont check any more) [COND ((← newLoc InstOf!(QUOTE UnionHall)) (RETURN (← self MoveTruck player curLoc newLoc reason] [COND ((OR (GREATERP nli (PLUS cli maxMove)) (LESSP nli (DIFFERENCE cli maxMove))) (RETURN (← Communicator MoveMade player cli cli (QUOTE MoreThanAllowed) NIL 1] (* check if want to move to curLoc) [COND ((EQ newLoc curLoc) (* no moves are made) (RETURN (← Communicator MoveMade player cli cli (QUOTE AlreadyThere] (RETURN (← self MoveTruck player curLoc newLoc reason]) (TruckinDecisionMaker.MoveTruck [Method ((TruckinDecisionMaker MoveTruck) self player curLoc newLoc reason) (* sm: "28-JUN-83 10:01") (* actually moves the currentPlayer's truck) (* reason - if NIL then move asked by user. else is the reason for the move, where the actual loc will be different from the original request) (PROG (dist cmile dmile (truck (@ player truck)) fuelNeeded actMile forcedMP) (* check if want to go to UnionHall) (SETQ cmile (@ curLoc milePost)) (SETQ dmile (@ newLoc milePost)) [COND ((← newLoc InstOf!(QUOTE UnionHall)) (COND ((← newLoc RoomToPark?) (RETURN (← Communicator MoveMade player cmile dmile reason))) (T (RETURN (← Communicator MoveMade player cmile cmile (OR reason (QUOTE NoRoomStayPut] (* check if truck has fuel) (SETQ dist (IDIFFERENCE (IMAX cmile dmile) (IMIN cmile dmile))) (SETQ fuelNeeded (TIMES dist (@@ truck Gpm))) (COND ((GREATERP fuelNeeded (@ truck fuel)) [SETQ actMile (FIX (FQUOTIENT (@ truck fuel) (@@ truck Gpm] [COND ((ZEROP actMile) (* has no fuel - move to UnionHall) (RETURN (← self MoveTruck player curLoc (@ unionHall) (QUOTE NoFuel] [SETQ forcedMP (COND ((GREATERP dmile cmile) (PLUS cmile actMile)) (T (DIFFERENCE cmile actMile] (← self ForcedMove player curLoc forcedMP (QUOTE LowFuel)) (RETURN NIL))) (* enough fuel for the move) (* check if room at intended location) (COND ((← newLoc RoomToPark?)) (T (← self ForcedMove player curLoc dmile (QUOTE NoRoom)) (RETURN NIL))) (RETURN (← self MoveCheckingHazards player curLoc newLoc reason]) (TruckinDecisionMaker.NewGameRequest (Method ((TruckinDecisionMaker NewGameRequest) self board) (* sm: " 5-JUL-83 18:42") (* Generates seed for a new game) (* board - type of gameBoard needed (BW, Color etc)) (PROG (gbClass seed) [COND [(AND (SETQ gbClass (GetClassRec board)) (← gbClass Subclass (QUOTE TruckinBoard] [(NULL board) (SETQ gbClass (GetClassRec (QUOTE BWTruckin] (T (SETQ gbClass (GetClassRec (INMENU "Select type of Game Board" (← ($ TruckinBoard) List (QUOTE Subs] (← Communicator NewGame (SETQ seed (RANDSET T)) (GetObjectName gbClass) (GetObjectName (Class self))) (← self AttachSimulator (@ Communicator simulator)) (* initialize IVs which change game to game) (← self Initialize) (←@ gameSeed seed) (RETURN seed)))) (TruckinDecisionMaker.ReUseGameRequest (Method ((TruckinDecisionMaker ReUseGameRequest) self) (* sm: " 5-JUL-83 13:57") (* Generates a new seed for reusing existing game) (PROG (seed) (←@ gameSeed (SETQ seed (RANDSET T))) (← self Initialize) (← Communicator ReUseGame seed) (RETURN seed)))) (TruckinDecisionMaker.RedoGameParameters (Method ((TruckinDecisionMaker RedoGameParameters) self) (* sm: " 8-JUL-83 14:34") (* Dummy. Needed if some game parameters need to be changed after the players are known) self)) (TruckinDecisionMaker.RemovePlayer (Method ((TruckinDecisionMaker RemovePlayer) self player reason) (* sm: "10-JUL-83 21:20") (* removes player from game) (PROG NIL (* (WriteGameStatus (@ player driver) " Committed serious violation: " reason) (COND ((EQ (QUOTE YES) (EVAL.IN.TTY.PROCESS (INTTY (CONCAT "Should I remove " (@ player driver) " from game?") (QUOTE (YES NO)) "Y to remove. N to let stay in game") T))))) (←@ players (REMOVE player (@ players))) (←@ playerNames (REMOVE (@ player driver) (@ playerNames))) (← Communicator RemovePlayer player reason) (RETURN player)))) (TruckinDecisionMaker.RemovePlayerRequest (Method ((TruckinDecisionMaker RemovePlayerRequest) self player reason) (* sm: "10-JUL-83 21:15") (* Request to remove player) (← self RemovePlayer player reason))) (TruckinDecisionMaker.ReplenishQty (Method ((TruckinDecisionMaker ReplenishQty) self) (* sm: "28-JUN-83 10:03") (* replenish GasStations qty) (PROG (gasMan gasStations (prevStop 0) nextStop unionHall (roadStops (@ roadStops))) (SETQ gasStations (for gasStation in roadStops when (AND (← gasStation InstOf!($ GasStation)) (← gasStation RoomToPark?) (ZEROP (@ gasStation qty))) collect gasStation)) (COND (gasStations (for x in gasStations do (← Communicator GasFill prevStop (SETQ nextStop (FindLocIndex x roadStops)) (GetInitialValue x (QUOTE qty)) (TIMES 2 (@ x pr))) (SETQ prevStop nextStop)) (← Communicator GasFill prevStop 0))) (RETURN gasStations)))) (TruckinDecisionMaker.SellMade (Method ((TruckinDecisionMaker SellMade) self player roadPosition reqQty qty cargoPos reason penaltyAmt) (* sm: " 1-JUL-83 09:38") (* Dummy for now) self)) (TruckinDecisionMaker.SellRequest [Method ((TruckinDecisionMaker SellRequest) self player roadPosition commodityIndex qty) (* sm: " 6-SEP-83 14:42") (* message sent to DecisionMaker to sell qty of commodity at the player's roadPosition.) (* commodityIndex - index into cargo of player) (PROG (truck loc commodity intendedLoc commodities (ctime (IDATE))) (* check if truck at a Consumer RoadStop) (SETQ truck (@ player truck)) (SETQ loc (@ truck location)) (SETQ intendedLoc (CAR (NTH (@ roadStops) roadPosition))) [COND ((GREATERP ctime (@ Simulator endTime)) (RETURN (← Communicator SellMade player roadPosition qty 0 commodityIndex (QUOTE GameOver] [COND ((NOT (EQ loc intendedLoc)) (* player is not where he thought he was) (RETURN (← Communicator SellMade player roadPosition qty 0 commodityIndex (QUOTE IncorrectLoc] [COND ([NOT (AND (GetObjectRec loc) (← loc InstOf!(QUOTE Consumer] (RETURN (← Communicator SellMade player roadPosition qty 0 commodityIndex (QUOTE NotConsumer] (* check if trying to sell 0) (* check if commodityIndex is class or actual commodity index) [COND [(NUMBERP commodityIndex) (COND [(ZEROP commodityIndex) (RETURN (← Communicator SellMade player roadPosition qty 0 commodityIndex (QUOTE IncorrectRequest] [(GREATERP commodityIndex (FLENGTH (@ truck cargo))) (RETURN (← Communicator SellMade player roadPosition qty 0 commodityIndex (QUOTE NotOwned] (T (SETQ commodity (CAR (NTH (@ truck cargo) commodityIndex] (T (RETURN (← Communicator SellMade player roadPosition qty 0 commodityIndex (QUOTE IncorrectCommodity] (* (WriteGameStatus (@ currentPlayer driver) " Sells " (CONCAT qty " " (ClassName commodity) " units."))) (* check if truck has qty) [COND ((NULL qty) (SETQ qty (@ commodity qty] [COND ((ZEROP qty) (RETURN (← Communicator SellMade player roadPosition qty 0 commodityIndex (QUOTE CannotSellZero] [COND ((GREATERP qty (@ commodity qty)) (RETURN (← Communicator SellMade player roadPosition qty 0 commodityIndex (QUOTE MoreThanOwned) .1] (* transfer ownership) (RETURN (COND ((← commodity CanTransfer loc (@ loc pr) qty) (← Communicator SellMade player roadPosition qty qty commodityIndex)) (T (* there was some error during transaction) (← Communicator SellMade player roadPosition qty 0 commodityIndex FCTReason FCTPenalty]) (TruckinDecisionMaker.StartGame (Method ((TruckinDecisionMaker StartGame) self) (* sm: " 8-JUL-83 14:30") (* Starts game) (* (← self StartMonitorProcess) (← self RedoGameParameters)) T)) (TruckinDecisionMaker.StartMonitorProcess (Method ((TruckinDecisionMaker StartMonitorProcess) self) (* sm: " 1-JUL-83 14:47") (* Start the monitor process) (ADD.PROCESS (LIST (QUOTE ←) self (QUOTE MonitorProcess)) (QUOTE GameMonitor)))) (TruckinDecisionMaker.UpdateAlice [Method ((TruckinDecisionMaker UpdateAlice) self player) (* sm: "13-JUL-83 09:35") (* Decides when parked at Alice) (for x in (@ alices) do (for loc in (QUOTE (parkingPlace1 parkingPlace2)) do (COND ((EQ player (GetValue x loc)) [COND ((ZEROP (GetValue x loc (QUOTE howLong))) (← Communicator ParkedAtAlice player (GetValue x loc (QUOTE timeParked] (PutValue x loc (ADD1 (GetValue x loc (QUOTE howLong))) (QUOTE howLong]) (TruckinPlayerInterface.AddPlayer (Method ((TruckinPlayerInterface AddPlayer) self reqID name type truck deniedFlg) (* sm: "16-SEP-83 16:41") (* New player being added to game) (PROG (plClass player) (SETQ player (GetObjectRec name)) (COND (deniedFlg [COND ((EQUAL reqID (@ Communicator machineID)) (* local request was denied. Destroy previously created object) (WriteGameStatus "Request to create player " name (CONCAT " denied: " deniedFlg " Create another player")) (AND player (← player Destroy] (RETURN NIL))) (* check if this was a requested local player) (COND ([AND (EQUAL reqID (@ Communicator machineID)) (NOT (FMEMB player (@ localPlayers] (←@ localPlayers (CONS player (@ localPlayers))) (* Create a process for player if local player) (← (@ player truck) Initialize) (← player Initialize) (← self CreatePlayerProcess player T) [COND ((@ Simulator gameRunningFlg) (AND (@ playerMenuWindow) (CLOSEW (@ playerMenuWindow))) (←@ playerMenuWindow (PlayerInterruptMenu (for x in (@ localPlayers) collect (@ x driver)) (@ self playerMenuWindow position] (pushnew ExistingPlayers player)) (T (* Not local so create a RemotePlayer) (SETQ plClass ($ RemotePlayer)) (SETQ player (← plClass New name truck type)) (* Initialize player and truck) (← player Initialize) (← (@ player truck) Initialize))) (←@ player remoteMachine reqID) (* (←@ players (CONS player (@ players)))) (RETURN player)))) (TruckinPlayerInterface.AddPlayerRequest (Method ((TruckinPlayerInterface AddPlayerRequest) self playerName playerType truckType) (* sm: "10-JUL-83 20:28") (* A request to create a new Player) (* If playerName is an instance of Player, then used with other two args extracted from it) (PROG (plClass player) [COND [(SETQ player (GetObjectRec playerName)) (COND [(NOT (FMEMB player (@ Simulator players] (T (WriteGameStatus "Cannot use " playerName " as player - another object by that name exists!") (RETURN NIL] (T (* get needed info from user) (SETQ player (CreateNewPlayer playerName playerType truckType] [SETQ truckType (GetObjectName (Class (@ player truck] (SETQ playerType (GetObjectName (Class player))) (SETQ playerName (@ player driver)) (← Communicator AddPlayerRequest (@ Communicator machineID) playerName playerType truckType)))) (TruckinPlayerInterface.BeginGame (Method ((TruckinPlayerInterface BeginGame) self players moves) (* sm: " 1-JUL-83 17:11") (* * Starts a new game. Players is either the number of players or a list of Player objects. If players is NIL, but the gameMaster has previous players, it uses those.) (PROG (board) (SETQ board GameBoard) (SetMachineDepPara) (← board MakeDriveBitMaps) (COND ((OR (@ Simulator players) (@ Simulator bandits)) (* if this board has been used before, ask for a new game on it) (← Communicator ReUseGameRequest))) (* Ask user to select players) (← self SelectPlayers players) (← Communicator BeginGameRequest) (RETURN T)))) (TruckinPlayerInterface.Buy [Method ((TruckinPlayerInterface Buy) self player qty) (* sm: "10-JUL-83 18:35") (* message sent by currentPlayer to BUY qty at its current location) (PROG (truck loc cmile) [COND ((NUMBERP qty) (SETQ qty (FIX qty] (SETQ truck (@ player truck)) (SETQ loc (@ truck location)) (SETQ cmile (FindLocIndex loc (@ roadStops))) (* Update game status window.) (WriteGameStatus (@ player driver) " Wants to Buy " (CONCAT qty " " (GetObjectName (@@ loc Commodity)) " units")) (←@ player pendingRequest (LIST (QUOTE BuyRequest) player cmile qty)) (RETURN (← self SuspendPlayer player T]) (TruckinPlayerInterface.BuyMade [Method ((TruckinPlayerInterface BuyMade) self player roadPosition reqQty qty reason penaltyAmt fragility lifetime) (* sm: " 6-JUL-83 11:14") (* check if for local player) (COND ((FMEMB player (@ localPlayers)) (* set the reason when awakened) (← self PlayerRequestComplete player reason]) (TruckinPlayerInterface.ChargeTime (Method ((TruckinPlayerInterface ChargeTime) self player clockTime) (* sm: " 6-JUL-83 13:09") (* Calculates the actual time to be charged to player) (* if clockTime is NIL, MinMoveTime is charged) (PROG (time charge used) (SETQ used (IDIFFERENCE clockTime (@ player startedAt))) [SETQ time (IDIFFERENCE used (IPLUS (@ player unchargedTime) (@@ player Handicap] (* (SETQ charge (SETQ time (FIX (ITIMES time HandicapRatio))))) (SETQ charge time) [COND ((LESSP time (@@ MinMoveTime)) (SETQ charge (@@ MinMoveTime))) ((GREATERP time (@@ MaxMoveTime)) (* player exceeded limit. Yank from game) (* currently not yanked) (* (← self RemovePlayer player (CONCAT "Too much time taken " charge))) ] (←@ player timeUsed (IPLUS charge (@ player timeUsed))) (AND debugTimeTrace (WriteGameStatus (CONCAT "Time Used: by " (@ player driver)) (CONCAT "Elapsed(sec)" used))) (AND timeTrace (WriteGameStatus "Time Charged to: " (@ player driver) (CONCAT " " charge " sec"))) (RETURN charge)))) (TruckinPlayerInterface.CheckLocalPlayers [Method ((TruckinPlayerInterface CheckLocalPlayers) self) (* sm: "16-SEP-83 17:09") (* Checks to make sure that all local players have processes) (* Should be needed only in abnormal situations, e.g., machine crashes or manual deletion of a player's process) (for x in (@ localPlayers) do (COND ((PROCESSP (@ x processHandle))) (T (* process has disappeared. recreate) (printout TTY "SysWarning: process for " (@ x driver) " has disappeared. Recreating the process." T) (← self CreatePlayerProcess x]) (TruckinPlayerInterface.ContinueGame (Method ((TruckinPlayerInterface ContinueGame) self noRedrawFlg) (* sm: "27-JUN-83 11:01") (* to resume a game in the middle.) (PROG ((board (@ gameBoard))) [COND ((NULL noRedrawFlg) (* redisplays the game board) (CLEARW (@ board gameWindow)) (← board DisplayGameBoard) (* (← board PlaceRoadStops)) (for rs in (@ board roadStops) do (←@ rs parkingPlace1 NIL) (←@ rs parkingPlace2 NIL)) (for p in (@ players) do (SETQ currentPlayer p) (← (@(@ p truck) location) Park)) (for b in (@ bandits) do (SETQ currentPlayer b) (← (@(@ b truck) location) Park] (* resume game) (← self RunGame) (← self WhoWon) (WriteGameStatus NIL "Simulation Complete! " (DATE)) (AND truckinLogHandle (CLOSEF? truckinLogHandle)) (SETQ truckinLogHandle NIL) (RETURN "Simulation Complete!")))) (TruckinPlayerInterface.CreatePlayerProcess (Method ((TruckinPlayerInterface CreatePlayerProcess) self player staySuspendFlg) (* sm: "16-SEP-83 17:07") (* Creates a process for player and suspends the process) (* marks player to stay suspended if staySuspendFlg is non-NIL) (PROG (hand) (DEL.PROCESS (FIND.PROCESS (@ player driver))) (SETQ hand (ADD.PROCESS (LIST (QUOTE ←) player (QUOTE StartGame)) (QUOTE NAME) (@ player driver) (QUOTE RESTARTABLE) PlayerProcRestFlg)) (←@ player processHandle hand) [COND ((FMEMB player (@ suspendedPlayers))) (T (←@ suspendedPlayers (CONS player (@ suspendedPlayers] (COND (staySuspendFlg (←@ player staySuspend staySuspendFlg))) (SUSPEND.PROCESS hand)))) (TruckinPlayerInterface.DeletePlayerProcesses [Method ((TruckinPlayerInterface DeletePlayerProcesses) self) (* sm: "12-JUL-83 16:33") (* Deletes players processes after the game) (for x in (@ localPlayers) do (DEL.PROCESS (@ x processHandle))) (AND (@ playerMenuWindow) (CLOSEW (@ playerMenuWindow]) (TruckinPlayerInterface.Move [Method ((TruckinPlayerInterface Move) self player newLoc) (* dgb: "15-JUL-83 00:25") (* sent by to move to newLoc) (PROG ((truck (@ player truck)) curLoc cli nli maxLoc (gb GameBoard)) (SETQ maxLoc (ITIMES (@@ gb numRows) (@@ gb numColumns))) (SETQ curLoc (@ truck location)) [SETQ cli (COND ((NULL curLoc) 0) (T (FindLocIndex curLoc (@ roadStops] [COND ((NUMBERP newLoc) (SETQ nli (PLUS cli newLoc))) [(FMEMB newLoc (@ roadStops)) (SETQ nli (FindLocIndex newLoc (@ roadStops] (T (BrokenRules player (CONCAT "Illegal location: " newLoc] (WriteGameStatus (@ player driver) (CONCAT " Wants to Move " (IDIFFERENCE nli cli)) (CONCAT " (max " (@ player maxMove) ")")) (COND ((AND (GREATERP nli 0) (LEQ nli maxLoc)) (SETQ newLoc (CAR (NTH (@ roadStops) nli))) (WriteGameStatus " To: " (@@ newLoc RoadSign) NIL T)) (T (WriteGameStatus NIL NIL NIL T))) (←@ player pendingRequest (LIST (QUOTE MoveRequest) player cli nli)) (RETURN (← self SuspendPlayer player T]) (TruckinPlayerInterface.MoveMade [Method ((TruckinPlayerInterface MoveMade) self player fromStop toStop reason penaltyAmount missTurns) (* sm: " 6-JUL-83 11:15") (* check if for local player) (COND ((FMEMB player (@ localPlayers)) (* ask to be resumed) (← self PlayerRequestComplete player reason]) (TruckinPlayerInterface.NewGame (Method ((TruckinPlayerInterface NewGame) self seed boardType gameType) (* sm: " 5-JUL-83 13:33") (* Adds roadStops locally) (←@ roadStops (@ Simulator roadStops)) (← self Initialize))) (TruckinPlayerInterface.NewGameRequest (Method ((TruckinPlayerInterface NewGameRequest) self board) (* sm: "29-JUN-83 13:14") (* Request for creating a new game of existing type) (* board - type of GameBoard desired) (← Communicator NewGameRequest board))) (TruckinPlayerInterface.PlayerRequestComplete [Method ((TruckinPlayerInterface PlayerRequestComplete) self player reason) (* sm: "10-JUL-83 11:28") (* if player passed as arg, set wakeReason) (COND (player (←@ player wakeReason reason) (←@ player staySuspend NIL]) (TruckinPlayerInterface.ReUseGame (Method ((TruckinPlayerInterface ReUseGame) self) (* sm: " 5-JUL-83 13:34") (* Received when the current board is used for a new game) (← self Initialize))) (TruckinPlayerInterface.RemovePlayer [Method ((TruckinPlayerInterface RemovePlayer) self player reason) (* sm: "10-JUL-83 21:18") (* New method template) (COND ((FMEMB player (@ localPlayers)) (DREMOVE player (@ localPlayers)) (DREMOVE player (@ suspendedPlayers)) (AND (@ player processHandle) (DEL.PROCESS (@ player processHandle]) (TruckinPlayerInterface.RemovePlayerRequest (Method ((TruckinPlayerInterface RemovePlayerRequest) self player reason) (* mjs: " 2-AUG-83 11:33") (* Request to remove player) (PROG NIL (SETQ player (GetObjectRec player)) (COND ([OR (NOT player) (NOT (← player InstOf!(QUOTE Player] (printout TTY "Are you kidding! " player " is NOT a player" T) (RETURN NIL))) (COND ((NOT (FMEMB player (@ localPlayers))) (printout TTY "Cannot remove non-local player" T) (RETURN NIL))) (← Communicator RemovePlayerRequest player (OR reason (QUOTE LocalRequest))) (RETURN player)))) (TruckinPlayerInterface.RunNextPlayer [Method ((TruckinPlayerInterface RunNextPlayer) self) (* sm: " 6-JUL-83 11:16") (* Decides who to run next -) (* This is one of the few methods which need to be changed to get different strategies for scheduling players) (PROG NIL (AND (@ Simulator gameRunningFlg) (COND ((FMEMB player (@ suspendedPlayers)) (DREMOVE player (@ suspendedPlayers)) (WAKE.PROCESS (@ player processHandle) (NOT reason]) (TruckinPlayerInterface.ScheduleNextPlayer [Method ((TruckinPlayerInterface ScheduleNextPlayer) self) (* sm: "16-SEP-83 17:02") (* Decides who to run next -) (PROG (currPlayer pendReq waitTime) (COND [(@ localPlayers) (COND ((EQUAL (FLENGTH (@ localPlayers)) (FLENGTH (@ suspendedPlayers))) (* all suspended. Pick one) [for p bind (minTimeSoFar ← 10000000) in (@ suspendedPlayers) do (COND ((ILESSP (@ p timeUsed) minTimeSoFar) (SETQ currPlayer p) (SETQ minTimeSoFar (@ p timeUsed] [COND (currPlayer (←@ suspendedPlayers (REMOVE currPlayer (@ suspendedPlayers))) (←@ runningPlayer currPlayer) [COND ((SETQ pendReq (@ currPlayer pendingRequest)) (←@ currPlayer pendingRequest NIL) (PutValue currPlayer (QUOTE pendingRequest) pendReq (QUOTE inProcess)) (PutValue currPlayer (QUOTE pendingRequest) (IDATE) (QUOTE whenSent)) (ApplyMethod Communicator (CAR pendReq) (CDR pendReq] (←@ unchargedTime 0) (←@ currPlayer schCount (ADD1 (@ currPlayer schCount))) (COND [(@ currPlayer staySuspend) (COND ((IGREATERP (SETQ waitTime (IDIFFERENCE (IDATE) (@ currPlayer pendingRequest whenSent))) 60) (printout TTY "SysWarning: over " waitTime " secs have elapsed since request sent by " (@ currPlayer driver) T] (T (← self WakePlayer currPlayer] (RETURN currPlayer)) (T (* one player already running) (COND ((@ runningPlayer) [COND [(@(@ runningPlayer) staySuspend) (COND ((IGREATERP (SETQ waitTime (IDIFFERENCE (IDATE) (@(@ runningPlayer) pendingRequest whenSent)) ) 60) (printout TTY "SysWarning: over " waitTime " secs have elapsed since request sent by " (@(@ runningPlayer) driver) T] (T (← self WakePlayer (@ runningPlayer] (RETURN (@ runningPlayer))) (T (printout TTY "Shouldnt Happen!! Scheduled player is NOT known" T) (HELPCHECK "What happened to scheduled player?") (← self CheckLocalPlayers) (RETURN NIL] (T (RETURN NIL]) (TruckinPlayerInterface.SelectPlayers (Method ((TruckinPlayerInterface SelectPlayers) self players) (* mjs: " 2-AUG-83 11:35") (* Asks user to select players) (PROG NIL (←@ localPlayers NIL) (COND ((AND (EQ players T) ExistingPlayers) (* ask existing players to be added to game) (SETQ players ExistingPlayers))) (COND ((OR (NUMBERP players) (NULL players)) (SETQ players (CreatePlayers ExistingPlayers))) ((ATOM players) (printout TTY "Illegal arg" -3 players T) (RETURN NIL))) (for x in (INTERSECTION players players) do (← self AddPlayerRequest x)) (RETURN players)))) (TruckinPlayerInterface.Sell [Method ((TruckinPlayerInterface Sell) self player commodity qty) (* sm: " 6-SEP-83 14:28") (* message sent by currentPlayer to sell qty of commodity at the player's current location.) (* commodity is either an instance of commodity or a class of commodity. In the latter case, the game master will try to find the proper instance if any from the cargo of the truck) (PROG (truck loc commodityIndex commodityClass commodities cmile) [COND ((NUMBERP qty) (SETQ qty (FIX qty] (SETQ truck (@ player truck)) (SETQ loc (@ truck location)) (SETQ cmile (FindLocIndex loc (@ roadStops))) (* check if commodity is class or actual commodity instance) (COND [(AND (GetObjectRec commodity) (← (GetObjectRec commodity) InstOf!(QUOTE Commodity))) (SETQ commodityIndex (FindLocIndex (GetObjectRec commodity) (@ truck cargo] [(AND (GetClassRec commodity) (← (GetClassRec commodity) Subclass (QUOTE Commodity))) (* get commodity instance from cargo) (SETQ commodities (for x in (@ truck cargo) when (← x InstOf! commodity) collect x)) (COND ((NULL commodities) (WriteGameStatus (@ player driver) " does not own " commodity) (SETQ commodity NIL) (SETQ commodityIndex 0)) [(NULL qty) (* no qty specified. pick any from cargo) (SETQ commodity (CAR commodities)) (SETQ commodityIndex (FindLocIndex commodity (@ truck cargo] (T (* get the instance with at least specified qty) [SETQ commodity (for x in commodities thereis (NOT (LESSP qty (@ x qty] [COND ((NULL commodity) (* no instance with qty - pick any) (SETQ commodity (CAR commodities] (SETQ commodityIndex (FindLocIndex commodity (@ truck cargo] (T (WriteGameStatus (@ player driver) " selling incorrect commodity: " commodity) (SETQ commodity NIL) (SETQ commodityIndex 0))) (* Update Status Window.) [COND ((AND (GetObjectRec commodity) (← (GetObjectRec commodity) InstOf!(QUOTE Commodity))) (WriteGameStatus (@ player driver) " Wants to sell " (CONCAT qty " " (ClassName commodity) " units."] (←@ player pendingRequest (LIST (QUOTE SellRequest) player cmile commodityIndex qty)) (RETURN (← self SuspendPlayer player T]) (TruckinPlayerInterface.SellMade [Method ((TruckinPlayerInterface SellMade) self player roadPosition reqQty qty cargoPos reason penaltyAmt) (* sm: " 6-JUL-83 11:15") (* check if for local player) (COND ((FMEMB player (@ localPlayers)) (* ask to be resumed) (← self PlayerRequestComplete player reason]) (TruckinPlayerInterface.StartGame (Method ((TruckinPlayerInterface StartGame) self begTime endTime) (* mjs: " 2-AUG-83 11:38") (* Starts the game at begTime) (* Put in code to : wait till begTime; spawn processes for each player;) (PROG ((currTime (IDATE))) (←@ beginTime begTime) (←@ endTime endTime) (WriteGameStatus "The following players are already in the game") (WriteGameStatus "" (for x in (@ Simulator players) collect (@ x driver))) (printout TTY "If you want to add any more players, do:" T .FONT BOLDFONT "(← PlayerInterface AddPlayerRequest)" .FONT DEFAULTFONT T) [COND ((@ localPlayers) (←@ playerMenuWindow (PlayerInterruptMenu (for x in (@ localPlayers) collect (@ x driver)) (@ self playerMenuWindow position] (* (COND ((EQ (QUOTE YES) (EVAL.IN.TTY.PROCESS (QUOTE (INTTY "Do you want to add any more players? " (QUOTE (YES NO)))) T)) (SETQ players (EVAL.IN.TTY.PROCESS (QUOTE (CreatePlayers NIL)) T)) (for x in (INTERSECTION players players) when (NOT (FMEMB x (@ localPlayers))) do (← self AddPlayerRequest x))))) (RETURN T)))) (TruckinPlayerInterface.StartPlayerProcesses (Method ((TruckinPlayerInterface StartPlayerProcesses) self) (* sm: " 8-JUL-83 13:53") (* starts players in separate processes) (PROG (hand) (←@ suspendedPlayers NIL) (for x in (@ localPlayers) when (NOT (FMEMB x (@ suspendedPlayers))) do (← self CreatePlayerProcess x)) (RETURN T)))) (TruckinPlayerInterface.SuspendPlayer [Method ((TruckinPlayerInterface SuspendPlayer) self player staySuspend) (* sm: " 8-AUG-83 20:45") (* Suspends player after a Buy/Move/Sell request) (PROG NIL (← self ChargeTime player (IDATE)) [COND ((FMEMB player (@ suspendedPlayers)) (printout TTY (@ player driver) " " "Was already suspended!" T)) (T (←@ suspendedPlayers (CONS player (@ suspendedPlayers] (COND (staySuspend (←@ player staySuspend staySuspend))) [COND ((@ runningPlayer) (COND ((EQ player (@ runningPlayer)) (←@ runningPlayer NIL)) (T (printout TTY "Shouldnt Happen!! Player just suspended: " (@ player driver) T "Wasn't even scheduled" T) (HELPCHECK "Unscheduled player suspended!"] (COND ((NOT (EQ (THIS.PROCESS) (@ player processHandle))) (HELPCHECK "Player being suspended from a different process"))) (SUSPEND.PROCESS (@ player processHandle)) (until (AND (EQ player (@ runningPlayer)) (NOT (@ player staySuspend))) do (SUSPEND.PROCESS (@ player processHandle]) (TruckinPlayerInterface.WakePlayer [Method ((TruckinPlayerInterface WakePlayer) self player) (* sm: "16-SEP-83 16:55") (* Wakes player so it can be run at next BLOCK) (PROG ((hand (@ player processHandle))) [COND ((PROCESSP hand)) (T (* player process has disappeared) (printout TTY "SysWarning: process for " (@ player driver) " has disappeared. Recreating the process." T) (← self CreatePlayerProcess player) (←@ suspendedPlayers (REMOVE player (@ suspendedPlayers] (←@ player unchargedTime 0) (←@ player startedAt (IDATE)) (WAKE.PROCESS (@ player processHandle) (@ player wakeReason]) (TruckinSimulator.AddBandit [Method ((TruckinSimulator AddBandit) self name) (* sm: " 1-JUL-83 17:45") (* Add bandit to game) (←@ bandits (CONS (← ($ Bandit) New name) (@ bandits]) (TruckinSimulator.AddPlayer (Method ((TruckinSimulator AddPlayer) self reqID name type truck deniedFlg) (* dgb: "11-JUL-83 14:01") (* Adds player to its list - assumes player created by PlayerInterface) (PROG (player) (COND (deniedFlg (RETURN NIL))) (SETQ player (GetObjectRec name)) (COND ((FMEMB player (@ players)) (RETURN NIL))) (←@ players (CONS player (@ players))) [COND ((AND (@ gameRunningFlg) (@ barChart)) (← (@ barChart) Attach (@ player truck) (QUOTE cashBox) NIL (@ player driver] (RETURN player)))) (TruckinSimulator.AttachBoard (Method ((TruckinSimulator AttachBoard) self gameBoard) (* sm: "28-JUN-83 09:31") (* Attaches gameBoard to game) (PutValue self (QUOTE gameBoard) gameBoard) (←@ roadStops (@ gameBoard roadStops)) (← gameBoard AttachToGame self))) (TruckinSimulator.BreakCargo (Method ((TruckinSimulator BreakCargo) self player commodIndex) (* sm: "27-JUN-83 10:59") (* Sent by a commodity when it breaks) (PROG ((truck (@ player truck)) commod) (SETQ commod (CAR (NTH (@ truck cargo) commodIndex))) (←@ commod status NIL) (WriteGameStatus (CONCAT (@ player driver) "'s Cargo of:") (CONCAT (@ commod qty) " " (ClassName commod) " units") " destroyed by RoughRoad")))) (TruckinSimulator.BuyMade [Method ((TruckinSimulator BuyMade) self player roadPosition reqQty qty reason penalty fragility lifetime) (* sm: " 1-JUL-83 16:51") (* Indicates a definite BUY to be made, or reasons for not carrying out a BuyRequest) (PROG ((truck (@ player truck)) (loc (CAR (NTH (@ roadStops) roadPosition))) commodity) (* (AuxBuyMade player roadPosition reqQty qty reason penalty fragility lifetime)) (COND ((ZEROP qty) (* no buy made) (BrokenRules player (CONCAT "Buy not made: " reason) penalty) (RETURN NIL))) (SETQ commodity (← (GetObjectRec (@@ loc Commodity)) New (@ loc pr) qty loc)) (COND ((← commodity InstOf!(QUOTE FragileCommodity)) (←@ commodity fragility fragility))) (COND ((← commodity InstOf!(QUOTE PerishableCommodity)) (←@ commodity lifetime lifetime))) (RETURN (← commodity TransferOwner truck NIL qty]) (TruckinSimulator.ClockProcess [Method ((TruckinSimulator ClockProcess) self) (* sm: "12-JUL-83 21:09") (* Monitors game clock) (PROG ([endTime (SETUPTIMER.DATE (GDATE (@ Simulator endTime] (blockTime (SETUPTIMER 800 NIL NIL (QUOTE MS))) cTime countDown) (* Wait till it is game time) [SETQ countDown (SETUPTIMER (IntervalToEvent (@ Simulator beginTime] (until (TIMEREXPIRED? countDown) do (printout PROMPTWINDOW T T (CHARACTER 7) "Game starting soon!" T) (←@ timeLeft (IDIFFERENCE (@ beginTime) (IDATE))) (BLOCK 4000)) (←@ timeLeft (IDIFFERENCE (@ Simulator endTime) (IDATE))) (until (TIMEREXPIRED? endTime (QUOTE SECONDS)) do (←@ timeLeft (IDIFFERENCE (@ Simulator endTime) (IDATE))) (SETQ blockTime (SETUPTIMER 800 blockTime NIL (QUOTE MS))) (BLOCK NIL blockTime)) (←@ timeLeft 0) (RETURN (QUOTE Done]) (TruckinSimulator.DrivePlayer (Method ((TruckinSimulator DrivePlayer) self curLoc finalLoc player) (* dgb: "11-JUL-83 12:40") (* Drives player from curLoc to finalLoc) (Drive curLoc finalLoc player))) (TruckinSimulator.GameOver (Method ((TruckinSimulator GameOver) self) (* dgb: "11-JUL-83 13:56") (* Game Over) (← self WhoWon) (←@ gameRunningFlg NIL))) (TruckinSimulator.GasFill (Method ((TruckinSimulator GasFill) self prevStop gsStop qty pr) (* sm: " 6-JUL-83 18:33") (* Instructions for moving a gas truck and filling GasStation) (* Fills gas station at gsStop) (* Spl cases: If prevStop =0 then start at UnionHall. If gsStop=0 then end at UnionHall) (PROG (gasMan prevRS newRS (unionHall (@ unionHall)) (roadStops (@ roadStops))) (SETQ gasMan (OR (GetObjectRec (QUOTE Gas)) (← ($ GasPlayer) New))) [COND ((ZEROP prevStop) (WriteGameStatus NIL "Here comes the GasMan!") (COND ((← unionHall RoomToPark?) (← unionHall Crash gasMan) (DISMISS 1500))) (SETQ prevRS unionHall)) (T (SETQ prevRS (CAR (NTH roadStops prevStop] [COND ((ZEROP gsStop) (SETQ newRS unionHall)) (T (SETQ newRS (CAR (NTH roadStops gsStop] (COND ((← prevRS Parked? gasMan) (← prevRS Unpark gasMan))) (Drive prevRS newRS gasMan) (COND [(EQ newRS unionHall) (COND ((← newRS RoomToPark?) (← newRS Crash gasMan) (DISMISS 1500) (← newRS Unpark gasMan] (T (← newRS Park gasMan) (DISMISS 200) (←@ newRS qty qty) (←@ newRS pr pr) (DISMISS 300))) (RETURN newRS)))) (TruckinSimulator.GiveAliceBonus [Method ((TruckinSimulator GiveAliceBonus) self atAlice) (* sm: " 6-JUL-83 13:21") (* Give bonus for reaching Alices) (WriteGameStatus "Their cashbox multiplied by " (@@ AliceBonus)) (for p in atAlice do (←@(@ p truck) cashBox (FIX (TIMES (@(@ p truck) cashBox) (@@ AliceBonus]) (TruckinSimulator.Initialize (Method ((TruckinSimulator Initialize) self) (* edited: "12-JUL-83 12:09") (* Initializes) (AND (@ barChart) (← (@ barChart) Close)) (for x in (@ players) when (← x InstOf!(QUOTE RemotePlayer)) DO (← x Destroy)) (←Super self Initialize))) (TruckinSimulator.MaxMove (Method ((TruckinSimulator MaxMove) self player maxMove) (* sm: " 1-JUL-83 11:51") (* Puts maxMove in player) (←@ player maxMove maxMove))) (TruckinSimulator.MoveMade (Method ((TruckinSimulator MoveMade) self player from to reason penaltyAmt missTurn) (* sm: " 6-SEP-83 15:02") (* Actually makes the move after all checks are done) (* player - player being moved from, to - indices of from and to locs reason - reason for move penaltyAmt - if any associated with move missTurn - any missed turn associated with move) (* Current set of reasons: Bandit, WeighStation, NoFuel, UnionHall, OffBoardBeg, OffBoardEnd, ConsecMoves, IllegalLoc, MoreThanAllowed, AlreadyThere, NoRoom, LowFuel) (PROG (curLoc finalLoc dist (truck (@ player truck))) (←@ player movesMade (ADD1 (@ player movesMade))) [COND ((← player InstOf!(QUOTE Player)) (* if not bandit or gasman) (for y in (@(@ player truck) cargo) do (DoFringeMethods y (QUOTE UpdateStatus] (COND ((AND (EQUAL from to) (← player InstOf!(QUOTE Player))) (* no physical move. print message) (BrokenRules player (CONCAT "Move not made: " reason) penaltyAmt missTurn) [COND ((EQ reason (QUOTE IncorrectLoc)) (WriteGameStatus (@ player driver) (CONCAT " located at: " (@(@ player truck) location)) (CONCAT " thinks he is at stop# " from] (RETURN NIL))) (SETQ curLoc (COND ((GREATERP from 0) (CAR (NTH (@ roadStops) from))) (T NIL))) (SETQ finalLoc (CAR (NTH (@ roadStops) to))) (SETQ dist (IABS (IDIFFERENCE from to))) [←@ truck fuel (IMAX 0 (IDIFFERENCE (@ truck fuel) (ITIMES dist (@@ truck Gpm] (COND (curLoc (← curLoc Unpark player) (← self DrivePlayer curLoc finalLoc player))) (← finalLoc Visit player reason (IDATE)) (* more code here for UnionHall, Bandit & WS cash lost, etc) (RETURN finalLoc)))) (TruckinSimulator.NewGame (Method ((TruckinSimulator NewGame) self seed board) (* sm: "26-JUL-83 11:20") (* Generates a new game based on seed and board specified by DecisionMaster) (PROG (gb) (SETQ gb (← (GetClassRec board) New self)) (SETQ GameBoard gb) (SETQ gameWindow NIL) (SetMachineDepPara) (← gb NewBoard seed) (← self AttachBoard gb) (← self Initialize) (← self SetUpGauges) (←@ alices (for x in (@ roadStops) when (← x InstOf!(QUOTE AlicesRestaurant)) collect x)) (←@ unionHall (CAR (@ roadStops))) (RETURN self)))) (TruckinSimulator.ParkedAtAlice [Method ((TruckinSimulator ParkedAtAlice) self player time) (* sm: " 1-JUL-83 11:44") (* Marks when player parked at alice) (for loc in (QUOTE (parkingPlace1 parkingPlace2)) bind (x ←(@(@ player truck) location)) do (COND ((EQ player (GetValue x loc)) (PutValue x loc time (QUOTE timeParked]) (TruckinSimulator.ReUseGame (Method ((TruckinSimulator ReUseGame) self seed) (* sm: "30-JUN-83 19:36") (* Sends message to GameBoard to reuse) (← (@ gameBoard) ReUseBoard seed) (← self Initialize))) (TruckinSimulator.RedoGameParameters [Method ((TruckinSimulator RedoGameParameters) self) (* sm: " 8-AUG-83 15:29") (* Change anything after all game info is known - prior to game start) (COND ((@ barChart)) (T (←@ barChart (←New ($ SSBarChart) SetUp (@ players) (QUOTE cashBox) "CashBox of Players" 20000 (QUOTE (truck)) NIL (QUOTE (430 . 630]) (TruckinSimulator.RemovePlayer (Method ((TruckinSimulator RemovePlayer) self player reason) (* sm: "10-JUL-83 21:18") (* Sent to game board so it can remove player from board) (PROG ((pobj player)) (DREMOVE pobj (@ players)) (← (@ gameBoard) RemovePlayer pobj) (WriteGameStatus (@ player driver) "Removed from game: " reason) (RETURN player)))) (TruckinSimulator.SellMade [Method ((TruckinSimulator SellMade) self player roadPosition reqQty qty cargoPosition reason penalty) (* sm: " 1-JUL-83 16:52") (* Performs an actual Sell, once all checking is done) (PROG [(truck (@ player truck)) commodity (loc (CAR (NTH (@ roadStops) roadPosition] (* (AuxSellMade player roadPosition reqQty qty cargoPosition reason penalty)) (COND ((ZEROP qty) (* no sell made) (BrokenRules player (CONCAT "Unable to sell: " reason) penalty) (RETURN NIL))) (SETQ commodity (CAR (NTH (@ truck cargo) cargoPosition))) (RETURN (← commodity TransferOwner loc (@ loc pr) qty]) (TruckinSimulator.SetUpGauges (Method ((TruckinSimulator SetUpGauges) self) (* sm: " 1-JUL-83 14:55") (* Sets up gauges) (← self AddGauges (QUOTE timeLeft) T "Time Remaining (sec)"))) (TruckinSimulator.SpoilCargo (Method ((TruckinSimulator SpoilCargo) self player commodIndex) (* sm: "27-JUN-83 11:00") (* Sent by commodity when it spoils) (PROG ((truck (@ player truck)) commod) (SETQ commod (CAR (NTH (@ truck cargo) commodIndex))) (←@ commod status NIL) (WriteGameStatus (CONCAT (@ player driver) "'s cargo of: ") (CONCAT (@ commod qty) " " (ClassName commod) " units") " just perished. Tch! Tch!") (RETURN NIL)))) (TruckinSimulator.StartClockProcess (Method ((TruckinSimulator StartClockProcess) self) (* sm: " 8-AUG-83 15:53") (* Starts the clock process) (DEL.PROCESS (FIND.PROCESS (QUOTE GameClock))) (ADD.PROCESS (LIST (QUOTE ←) self (QUOTE ClockProcess)) (QUOTE NAME) (QUOTE GameClock) (QUOTE RESTARTABLE) GameProcRestFlg))) (TruckinSimulator.StartGame (Method ((TruckinSimulator StartGame) self begTime endTime) (* sm: " 5-JUL-83 16:13") (* SetsUp IVs for time left etc and starts game clock process) (←@ beginTime begTime) (←@ endTime endTime) (←@ timeLeft (IDIFFERENCE endTime begTime)) (* Start the clock process here) (← self StartClockProcess) (WriteGameStatus (DATE) " New Simulation!") [WriteGameStatus (CONCAT "Game Begins at: " (GDATE (@ beginTime))) (CONCAT "Game will end at: " (GDATE (@ endTime] (←@ gameRunningFlg T))) (TruckinSimulator.UnattachBoard (Method ((TruckinSimulator UnattachBoard) self) (* sm: "28-JUN-83 09:31") (* Removes game board) (PutValue self (QUOTE gameBoard) NotSetValue) (←@ roadStops NIL))) (TruckinSimulator.UpdateRS (Method ((TruckinSimulator UpdateRS) self roadStop) (* sm: "28-JUN-83 09:45") (* Sent when any RoadStop's data changes) (← roadStop DisplayData))) (TruckinSimulator.WhoWon (Method ((TruckinSimulator WhoWon) self) (* mjs: " 2-AUG-83 11:49") (* summarizes the game results) (PROG (atAlice winner) (printout TTY 5 .FONT BOLDFONT "Summary of Game" .FONT DEFAULTFONT T) (WriteGameStatus NIL "Summary of Game") [SETQ atAlice (for x in (@ alices) join (for y in (QUOTE (parkingPlace1 parkingPlace2) ) when (GetValue x y) collect (GetValue x y] (printout TTY "Following players made it to Alices" T T) (WriteGameStatus "Following players made it to Alices") (← self GiveAliceBonus atAlice) [for x in atAlice do (printout TTY .FONT BOLDFONT (@ x driver) -5 "$" (@(@ x truck) cashBox) T) (WriteGameStatus (@ x driver) (CONCAT " $" (@(@ x truck) cashBox] (printout PPDefault T .FONT DEFAULTFONT "Summary of all player's status" T) (for x in (@ players) do (← x Summarize) (AND truckinLogFlg truckinLogHandle (← x Summarize truckinLogHandle))) (printout PPDefault T) (SETQ atAlice (@ players)) (SETQ winner (CAR atAlice)) [for x in (CDR atAlice) do (COND ((GREATERP (@(@ x truck) cashBox) (@(@ winner truck) cashBox)) (SETQ winner x] (printout TTY .FONT BOLDFONT "Winner is :" (@ winner driver) (CONCAT " Cash: $" (@(@ winner truck) cashBox)) .FONT DEFAULTFONT T) (WriteGameStatus "Winner is: " (@ winner driver) (CONCAT " Cash: $" (@(@ winner truck) cashBox))) (RETURN winner)))) ) (PUTPROPS TRUCKINM COPYRIGHT ("Xerox Corporation" 1985)) (DECLARE: DONTCOPY (FILEMAP (NIL (23120 26273 (MoveTruckinPI.BeginGame 23130 . 23663) (RemoteMasterComm.StartWorldProcess 23665 . 24260) (RemoteSlaveComm.StartWorldProcess 24262 . 24856) (SlaveTruckin 24858 . 25252) ( TimeTruckinPI.BeginGame 25254 . 25849) (TruckinCommInterface.NewInstance 25851 . 26271)) (49391 210058 (BWTruckin.InitializeGameWindow 49401 . 49832) (ColorTruckin.CreateGameBoard 49834 . 50574) ( ColorTruckin.InitializeGameWindow 50576 . 51713) (ColorTruckin.MakeDriveBitMaps 51715 . 52003) ( DisplayTruckinS.NewGame 52005 . 52404) (DisplayTruckinS.ReUseGame 52406 . 52751) ( GameCommInterface.NewInstance 52753 . 53740) (GameDecisionMaker.NewInstance 53742 . 54152) ( GamePlayerInterface.ChangeGameParameters 54154 . 54994) (GamePlayerInterface.NewInstance 54996 . 55541 ) (GameSimulator.NewInstance 55543 . 55945) (MainCommInterface.AddBandit 55947 . 56359) ( MainCommInterface.AddPlayer 56361 . 56959) (MainCommInterface.AddPlayerRequest 56961 . 57303) ( MainCommInterface.BeginGameRequest 57305 . 57670) (MainCommInterface.BreakCargo 57672 . 58099) ( MainCommInterface.BuyMade 58101 . 59034) (MainCommInterface.BuyRequest 59036 . 59393) ( MainCommInterface.GameOver 59395 . 59762) (MainCommInterface.GasFill 59764 . 60143) ( MainCommInterface.MaxMove 60145 . 60550) (MainCommInterface.MoveMade 60552 . 61504) ( MainCommInterface.MoveRequest 61506 . 61864) (MainCommInterface.NewGame 61866 . 62377) ( MainCommInterface.NewGameRequest 62379 . 62699) (MainCommInterface.ParkedAtAlice 62701 . 63124) ( MainCommInterface.ReUseGame 63126 . 63559) (MainCommInterface.ReUseGameRequest 63561 . 63930) ( MainCommInterface.RemovePlayer 63932 . 64431) (MainCommInterface.RemovePlayerRequest 64433 . 64775) ( MainCommInterface.SellMade 64777 . 65715) (MainCommInterface.SellRequest 65717 . 66092) ( MainCommInterface.SetInitialParameters 66094 . 66412) (MainCommInterface.SetUp 66414 . 67101) ( MainCommInterface.SpoilCargo 67103 . 67530) (MainCommInterface.StartGame 67532 . 68184) ( MainCommInterface.WorldProcess 68186 . 70079) (MoveTruckinDM.InitializeGameParameters 70081 . 70799) ( MoveTruckinDM.MoveBandits 70801 . 71292) (MoveTruckinPI.RunGame 71294 . 73210) ( NoDisplayTruckinS.AttachBoard 73212 . 73545) (NoDisplayTruckinS.DrivePlayer 73547 . 73812) ( NoDisplayTruckinS.UpdateRS 73814 . 74192) (RemoteMasterComm.AddBandit 74194 . 74695) ( RemoteMasterComm.AddPlayer 74697 . 75389) (RemoteMasterComm.AddPlayerRequest 75391 . 75731) ( RemoteMasterComm.BeginGameRequest 75733 . 76096) (RemoteMasterComm.BreakCargo 76098 . 76696) ( RemoteMasterComm.BuyMade 76698 . 77792) (RemoteMasterComm.BuyRequest 77794 . 78149) ( RemoteMasterComm.GameOver 78151 . 78570) (RemoteMasterComm.GasFill 78572 . 79035) ( RemoteMasterComm.InterimWorldProcess 79037 . 79484) (RemoteMasterComm.MaxMove 79486 . 80085) ( RemoteMasterComm.MoveMade 80087 . 81187) (RemoteMasterComm.MoveRequest 81189 . 81545) ( RemoteMasterComm.NewGame 81547 . 82153) (RemoteMasterComm.NewGameRequest 82155 . 82473) ( RemoteMasterComm.ParkedAtAlice 82475 . 83036) (RemoteMasterComm.ReUseGame 83038 . 83538) ( RemoteMasterComm.ReUseGameRequest 83540 . 83907) (RemoteMasterComm.RemovePlayer 83909 . 84582) ( RemoteMasterComm.RemovePlayerRequest 84584 . 84955) (RemoteMasterComm.SellMade 84957 . 86047) ( RemoteMasterComm.SellRequest 86049 . 86422) (RemoteMasterComm.SetInitialParameters 86424 . 86769) ( RemoteMasterComm.SetUp 86771 . 87523) (RemoteMasterComm.SpoilCargo 87525 . 88282) ( RemoteMasterComm.StartGame 88284 . 89014) (RemoteMasterComm.StartInterimWorldProcess 89016 . 89610) ( RemoteMasterComm.WorldProcess 89612 . 91454) (RemoteSlaveComm.AddBandit 91456 . 91868) ( RemoteSlaveComm.AddPlayer 91870 . 92446) (RemoteSlaveComm.AddPlayerRequest 92448 . 92805) ( RemoteSlaveComm.BeginGameRequest 92807 . 93221) (RemoteSlaveComm.BreakCargo 93223 . 93701) ( RemoteSlaveComm.BuyMade 93703 . 94486) (RemoteSlaveComm.BuyRequest 94488 . 94917) ( RemoteSlaveComm.GameOver 94919 . 95282) (RemoteSlaveComm.GasFill 95284 . 95713) ( RemoteSlaveComm.InterimWorldProcess 95715 . 96160) (RemoteSlaveComm.MaxMove 96162 . 96654) ( RemoteSlaveComm.MoveMade 96656 . 97388) (RemoteSlaveComm.MoveRequest 97390 . 97820) ( RemoteSlaveComm.NewGame 97822 . 98329) (RemoteSlaveComm.NewGameRequest 98331 . 98672) ( RemoteSlaveComm.ParkedAtAlice 98674 . 99124) (RemoteSlaveComm.ReUseGame 99126 . 99555) ( RemoteSlaveComm.ReUseGameRequest 99557 . 99922) (RemoteSlaveComm.RemovePlayer 99924 . 100481) ( RemoteSlaveComm.RemovePlayerRequest 100483 . 100870) (RemoteSlaveComm.SellMade 100872 . 101669) ( RemoteSlaveComm.SellRequest 101671 . 102118) (RemoteSlaveComm.SetInitialParameters 102120 . 102442) ( RemoteSlaveComm.SetUp 102444 . 102940) (RemoteSlaveComm.SpoilCargo 102942 . 103396) ( RemoteSlaveComm.StartGame 103398 . 104036) (RemoteSlaveComm.StartInterimWorldProcess 104038 . 104630) (RemoteSlaveComm.WorldProcess 104632 . 106799) (TimeTruckinDM.ChargeTime 106801 . 108350) ( TimeTruckinDM.CheckAlice 108352 . 110082) (TimeTruckinDM.InitializeGameParameters 110084 . 110621) ( TimeTruckinDM.MoveBandits 110623 . 111276) (TimeTruckinDM.RedoGameParameters 111278 . 112104) ( TimeTruckinDM.ReplenishQty 112106 . 112655) (TimeTruckinPI.RunGame 112657 . 114872) ( TruckinBoard.AssignRoadStops 114874 . 116969) (TruckinBoard.AttachToGame 116971 . 117586) ( TruckinBoard.CreateGameBoard 117588 . 118043) (TruckinBoard.DisplayGameBoard 118045 . 119550) ( TruckinBoard.DrawRoadMarks 119552 . 119663) (TruckinBoard.InitializeRoadStops 119665 . 120021) ( TruckinBoard.MakeDriveBitMaps 120023 . 120311) (TruckinBoard.NewBoard 120313 . 121176) ( TruckinBoard.PlaceRoadStops 121178 . 122894) (TruckinBoard.ReInitializeRoadStops 122896 . 123250) ( TruckinBoard.ReUseBoard 123252 . 123596) (TruckinBoard.RemovePlayer 123598 . 124069) ( TruckinCommInterface.CleanGameWorld 124071 . 124477) (TruckinCommInterface.CreateDecisionMaker 124479 . 125552) (TruckinCommInterface.CreateGateWay 125554 . 126683) ( TruckinCommInterface.CreatePlayerInterface 126685 . 127837) (TruckinCommInterface.CreateSimulator 127839 . 128703) (TruckinCommInterface.SetInitialParameters 128705 . 128993) ( TruckinCommInterface.StartWorldProcess 128995 . 129706) (TruckinCommInterface.TellMe 129708 . 130264) (TruckinDecisionMaker.AddBandit 130266 . 130593) (TruckinDecisionMaker.AddPlayer 130595 . 131861) ( TruckinDecisionMaker.AddPlayerRequest 131863 . 132797) (TruckinDecisionMaker.AttachSimulator 132799 . 133184) (TruckinDecisionMaker.BeginGameRequest 133186 . 134309) (TruckinDecisionMaker.BuyMade 134311 . 134648) (TruckinDecisionMaker.BuyRequest 134650 . 137437) ( TruckinDecisionMaker.ChangeGameParameters 137439 . 138311) (TruckinDecisionMaker.CheckAlice 138313 . 139837) (TruckinDecisionMaker.ForcedMove 139839 . 140941) (TruckinDecisionMaker.GameOver 140943 . 141231) (TruckinDecisionMaker.GiveAliceBonus 141233 . 141498) ( TruckinDecisionMaker.InitializeGameParameters 141500 . 142147) (TruckinDecisionMaker.MonitorGame 142149 . 142728) (TruckinDecisionMaker.MonitorProcess 142730 . 143562) ( TruckinDecisionMaker.MoveBandits 143564 . 145596) (TruckinDecisionMaker.MoveCheckingHazards 145598 . 147180) (TruckinDecisionMaker.MoveMade 147182 . 148098) (TruckinDecisionMaker.MoveRequest 148100 . 151000) (TruckinDecisionMaker.MoveTruck 151002 . 153247) (TruckinDecisionMaker.NewGameRequest 153249 . 154466) (TruckinDecisionMaker.ReUseGameRequest 154468 . 154952) ( TruckinDecisionMaker.RedoGameParameters 154954 . 155316) (TruckinDecisionMaker.RemovePlayer 155318 . 156120) (TruckinDecisionMaker.RemovePlayerRequest 156122 . 156444) (TruckinDecisionMaker.ReplenishQty 156446 . 157444) (TruckinDecisionMaker.SellMade 157446 . 157775) (TruckinDecisionMaker.SellRequest 157777 . 161162) (TruckinDecisionMaker.StartGame 161164 . 161558) ( TruckinDecisionMaker.StartMonitorProcess 161560 . 161967) (TruckinDecisionMaker.UpdateAlice 161969 . 162703) (TruckinPlayerInterface.AddPlayer 162705 . 164838) (TruckinPlayerInterface.AddPlayerRequest 164840 . 166071) (TruckinPlayerInterface.BeginGame 166073 . 166954) (TruckinPlayerInterface.Buy 166956 . 167925) (TruckinPlayerInterface.BuyMade 167927 . 168435) (TruckinPlayerInterface.ChargeTime 168437 . 170064) (TruckinPlayerInterface.CheckLocalPlayers 170066 . 170959) ( TruckinPlayerInterface.ContinueGame 170961 . 172243) (TruckinPlayerInterface.CreatePlayerProcess 172245 . 173338) (TruckinPlayerInterface.DeletePlayerProcesses 173340 . 173800) ( TruckinPlayerInterface.Move 173802 . 175233) (TruckinPlayerInterface.MoveMade 175235 . 175720) ( TruckinPlayerInterface.NewGame 175722 . 176058) (TruckinPlayerInterface.NewGameRequest 176060 . 176521 ) (TruckinPlayerInterface.PlayerRequestComplete 176523 . 176930) (TruckinPlayerInterface.ReUseGame 176932 . 177269) (TruckinPlayerInterface.RemovePlayer 177271 . 177771) ( TruckinPlayerInterface.RemovePlayerRequest 177773 . 178615) (TruckinPlayerInterface.RunNextPlayer 178617 . 179350) (TruckinPlayerInterface.ScheduleNextPlayer 179352 . 182186) ( TruckinPlayerInterface.SelectPlayers 182188 . 183078) (TruckinPlayerInterface.Sell 183080 . 186131) ( TruckinPlayerInterface.SellMade 186133 . 186622) (TruckinPlayerInterface.StartGame 186624 . 188065) ( TruckinPlayerInterface.StartPlayerProcesses 188067 . 188594) (TruckinPlayerInterface.SuspendPlayer 188596 . 189966) (TruckinPlayerInterface.WakePlayer 189968 . 190860) (TruckinSimulator.AddBandit 190862 . 191196) (TruckinSimulator.AddPlayer 191198 . 192011) (TruckinSimulator.AttachBoard 192013 . 192422) (TruckinSimulator.BreakCargo 192424 . 193061) (TruckinSimulator.BuyMade 193063 . 194356) ( TruckinSimulator.ClockProcess 194358 . 195598) (TruckinSimulator.DrivePlayer 195600 . 195907) ( TruckinSimulator.GameOver 195909 . 196199) (TruckinSimulator.GasFill 196201 . 197915) ( TruckinSimulator.GiveAliceBonus 197917 . 198405) (TruckinSimulator.Initialize 198407 . 198859) ( TruckinSimulator.MaxMove 198861 . 199142) (TruckinSimulator.MoveMade 199144 . 201444) ( TruckinSimulator.NewGame 201446 . 202301) (TruckinSimulator.ParkedAtAlice 202303 . 202811) ( TruckinSimulator.ReUseGame 202813 . 203149) (TruckinSimulator.RedoGameParameters 203151 . 203709) ( TruckinSimulator.RemovePlayer 203711 . 204250) (TruckinSimulator.SellMade 204252 . 205191) ( TruckinSimulator.SetUpGauges 205193 . 205516) (TruckinSimulator.SpoilCargo 205518 . 206182) ( TruckinSimulator.StartClockProcess 206184 . 206720) (TruckinSimulator.StartGame 206722 . 207470) ( TruckinSimulator.UnattachBoard 207472 . 207815) (TruckinSimulator.UpdateRS 207817 . 208111) ( TruckinSimulator.WhoWon 208113 . 210056))))) STOP