mentor/derived/MinimaxIE.m3


 Copyright (C) 1995, Digital Equipment Corporation.       
 All rights reserved.                                     
 See the file COPYRIGHT for a full description.           
                                                          
 Last modified on Thu Feb  9 08:50:48 PST 1995 by kalsow  
      modified on Sun Jun  5 21:59:57 PDT 1994 by mhb     
      modified on Wed Feb 17 16:46:47 PST 1993 by johnh   

********************************************************************

      *  NOTE: This file is generated automatically from the event
      *        definition file Minimax.evt.
      ********************************************************************


<* PRAGMA LL *>

MODULE MinimaxIE;

<*NOWARN*> IMPORT ZeusClass, Zeus, TypeFmt, Minimax;
<*NOWARN*> IMPORT MinimaxAlgClass, MinimaxViewClass, Algorithm;
<*NOWARN*> IMPORT GameBoard, View, Thread, AlgorithmClass;

<* FATAL Zeus.Error, Zeus.Locked *>
If you get either of these errors, contact a Zeus implementor.

TYPE
  SetupArgs = BRANDED REF RECORD
  END;

  PlayerMoveArgs = BRANDED REF RECORD
    player: INTEGER;
    fromx: INTEGER;
    fromy: INTEGER;
    tox: INTEGER;
    toy: INTEGER;
  END;

  FinishedArgs = BRANDED REF RECORD
    winner: INTEGER;
  END;

  EvaluateNodeArgs = BRANDED REF RECORD
    board: GameBoard.T;
  END;

  PlayerThinkingArgs = BRANDED REF RECORD
    player: INTEGER;
    board: GameBoard.T;
  END;

  FinishedEvalNodeArgs = BRANDED REF RECORD
    board: GameBoard.T;
  END;

  BoardValueUpdatedArgs = BRANDED REF RECORD
    board: GameBoard.T;
    newValue: Minimax.BoardValue;
  END;

  HumanSelectionArgs = BRANDED REF RECORD
    xCoord: INTEGER;
    yCoord: INTEGER;
  END;

  HumanCellSelectedArgs = BRANDED REF RECORD
    xCoord: INTEGER;
    yCoord: INTEGER;
  END;

  HumanIllegalMoveArgs = BRANDED REF RECORD
  END;
Zeus calls the following to invoke vbt v's event handler:

<*NOWARN*> PROCEDURE OEDispatcher(v: ZeusClass.T; evt: REFANY) RAISES {Thread.Alerted} =
  <* LL <= VBT.mu *>
  (* LL = {} if event style is output, LL = VBT.mu if event style is update. *)
  BEGIN
    TYPECASE v OF
    | MinimaxViewClass.T (view) => <*NOWARN*>
      TYPECASE evt OF
      | SetupArgs(varSetupArgs) => <*NOWARN*>
          view.oeSetup (
              )
      | PlayerMoveArgs(varPlayerMoveArgs) => <*NOWARN*>
          view.oePlayerMove (
              varPlayerMoveArgs.player
                ,
              varPlayerMoveArgs.fromx
                ,
              varPlayerMoveArgs.fromy
                ,
              varPlayerMoveArgs.tox
                ,
              varPlayerMoveArgs.toy
              )
      | FinishedArgs(varFinishedArgs) => <*NOWARN*>
          view.oeFinished (
              varFinishedArgs.winner
              )
      | EvaluateNodeArgs(varEvaluateNodeArgs) => <*NOWARN*>
          view.oeEvaluateNode (
              varEvaluateNodeArgs.board
              )
      | PlayerThinkingArgs(varPlayerThinkingArgs) => <*NOWARN*>
          view.oePlayerThinking (
              varPlayerThinkingArgs.player
                ,
              varPlayerThinkingArgs.board
              )
      | FinishedEvalNodeArgs(varFinishedEvalNodeArgs) => <*NOWARN*>
          view.oeFinishedEvalNode (
              varFinishedEvalNodeArgs.board
              )
      | BoardValueUpdatedArgs(varBoardValueUpdatedArgs) => <*NOWARN*>
          view.oeBoardValueUpdated (
              varBoardValueUpdatedArgs.board
                ,
              varBoardValueUpdatedArgs.newValue
              )
      | HumanCellSelectedArgs(varHumanCellSelectedArgs) => <*NOWARN*>
          view.oeHumanCellSelected (
              varHumanCellSelectedArgs.xCoord
                ,
              varHumanCellSelectedArgs.yCoord
              )
      | HumanIllegalMoveArgs(varHumanIllegalMoveArgs) => <*NOWARN*>
          view.oeHumanIllegalMove (
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this view isn't a MinimaxViewClass, so just ignore *)
    END
  END OEDispatcher;

<*NOWARN*> PROCEDURE FEDispatcher(v: ZeusClass.T; evt: REFANY) =
  <* LL = VBT.mu *>
  BEGIN
    TYPECASE v OF
    | MinimaxAlgClass.T (alg) => <*NOWARN*>
      TYPECASE evt OF
      | HumanSelectionArgs(varHumanSelectionArgs) => <*NOWARN*>
          alg.feHumanSelection (
              varHumanSelectionArgs.xCoord
                ,
              varHumanSelectionArgs.yCoord
              )
      ELSE <* ASSERT FALSE *>
      END;
    ELSE (* this alg isn't a MinimaxAlgClass, so just ignore *)
    END
  END FEDispatcher;

PROCEDURE Setup (
      initiator: Algorithm.T;

    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(SetupArgs
      );
      alg := NARROW(initiator, MinimaxAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfSetup);
      alg.stopAtEvent := alg.eventDataRec.stopAtSetup;
      alg.waitAtEvent := alg.eventDataRec.waitAtSetup;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Setup", OEDispatcher, zumeArgRec);
    END;
  END Setup;

PROCEDURE PlayerMove (
      initiator: Algorithm.T;
       player: INTEGER; fromx, fromy, tox, toy: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(PlayerMoveArgs
               , player := player
               , fromx := fromx
               , fromy := fromy
               , tox := tox
               , toy := toy
      );
      alg := NARROW(initiator, MinimaxAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfPlayerMove);
      alg.stopAtEvent := alg.eventDataRec.stopAtPlayerMove;
      alg.waitAtEvent := alg.eventDataRec.waitAtPlayerMove;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "PlayerMove", OEDispatcher, zumeArgRec);
    END;
  END PlayerMove;

PROCEDURE Finished (
      initiator: Algorithm.T;
       winner: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(FinishedArgs
               , winner := winner
      );
      alg := NARROW(initiator, MinimaxAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfFinished);
      alg.stopAtEvent := alg.eventDataRec.stopAtFinished;
      alg.waitAtEvent := alg.eventDataRec.waitAtFinished;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "Finished", OEDispatcher, zumeArgRec);
    END;
  END Finished;

PROCEDURE EvaluateNode (
      initiator: Algorithm.T;
       board: GameBoard.T
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(EvaluateNodeArgs
               , board := board
      );
      alg := NARROW(initiator, MinimaxAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfEvaluateNode);
      alg.stopAtEvent := alg.eventDataRec.stopAtEvaluateNode;
      alg.waitAtEvent := alg.eventDataRec.waitAtEvaluateNode;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "EvaluateNode", OEDispatcher, zumeArgRec);
    END;
  END EvaluateNode;

PROCEDURE PlayerThinking (
      initiator: Algorithm.T;
       player: INTEGER; board: GameBoard.T
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(PlayerThinkingArgs
               , player := player
               , board := board
      );
      alg := NARROW(initiator, MinimaxAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfPlayerThinking);
      alg.stopAtEvent := alg.eventDataRec.stopAtPlayerThinking;
      alg.waitAtEvent := alg.eventDataRec.waitAtPlayerThinking;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "PlayerThinking", OEDispatcher, zumeArgRec);
    END;
  END PlayerThinking;

PROCEDURE FinishedEvalNode (
      initiator: Algorithm.T;
       board: GameBoard.T
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(FinishedEvalNodeArgs
               , board := board
      );
      alg := NARROW(initiator, MinimaxAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfFinishedEvalNode);
      alg.stopAtEvent := alg.eventDataRec.stopAtFinishedEvalNode;
      alg.waitAtEvent := alg.eventDataRec.waitAtFinishedEvalNode;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "FinishedEvalNode", OEDispatcher, zumeArgRec);
    END;
  END FinishedEvalNode;

PROCEDURE BoardValueUpdated (
      initiator: Algorithm.T;
       board: GameBoard.T; newValue: Minimax.BoardValue
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(BoardValueUpdatedArgs
               , board := board
               , newValue := newValue
      );
      alg := NARROW(initiator, MinimaxAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfBoardValueUpdated);
      alg.stopAtEvent := alg.eventDataRec.stopAtBoardValueUpdated;
      alg.waitAtEvent := alg.eventDataRec.waitAtBoardValueUpdated;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "BoardValueUpdated", OEDispatcher, zumeArgRec);
    END;
  END BoardValueUpdated;

PROCEDURE HumanCellSelected (
      initiator: Algorithm.T;
       xCoord, yCoord: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(HumanCellSelectedArgs
               , xCoord := xCoord
               , yCoord := yCoord
      );
      alg := NARROW(initiator, MinimaxAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfHumanCellSelected);
      alg.stopAtEvent := alg.eventDataRec.stopAtHumanCellSelected;
      alg.waitAtEvent := alg.eventDataRec.waitAtHumanCellSelected;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "HumanCellSelected", OEDispatcher, zumeArgRec);
    END;
  END HumanCellSelected;

PROCEDURE HumanIllegalMove (
      initiator: Algorithm.T;

    ) RAISES {Thread.Alerted} =
  <* LL = {} *>
  VAR zumeArgRec := NEW(HumanIllegalMoveArgs
      );
      alg := NARROW(initiator, MinimaxAlgClass.T);
  BEGIN
    LOCK alg.evtMu DO
      INC(alg.eventDataRec.ctOfHumanIllegalMove);
      alg.stopAtEvent := alg.eventDataRec.stopAtHumanIllegalMove;
      alg.waitAtEvent := alg.eventDataRec.waitAtHumanIllegalMove;
      Zeus.Dispatch(initiator, Zeus.EventStyle.Output, 1,
                    "HumanIllegalMove", OEDispatcher, zumeArgRec);
    END;
  END HumanIllegalMove;

PROCEDURE HumanSelection (
      initiator: View.T;
       xCoord, yCoord: INTEGER
    ) RAISES {Thread.Alerted} =
  <* LL = VBT.mu *>
  VAR zumeArgRec := NEW(HumanSelectionArgs
               , xCoord := xCoord
               , yCoord := yCoord
      );
  BEGIN
    Zeus.Dispatch(initiator, Zeus.EventStyle.Notify, 1,
                  "HumanSelection", FEDispatcher, zumeArgRec);
  END HumanSelection;

BEGIN
END MinimaxIE.

interface View is in: