home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Clean 1.2.4 / IO Examples / Scrabble / types.dcl < prev    next >
Encoding:
Modula Definition  |  1997-05-14  |  2.7 KB  |  81 lines  |  [TEXT/3PRM]

  1. definition module types
  2.  
  3.  
  4. import    StdString, StdClass, StdFile
  5.  
  6.  
  7. /***************************************************************************************************************
  8.     Basic type definitions.
  9. ****************************************************************************************************************/
  10. ::    Playmode            =    EndPlayer1 | EndPlayer2 | Playing
  11. ::    Playerkind            =    Computer | Person
  12. ::    Player                =    Player1 | Player2
  13. ::    Strength            =    Maximum | First | Strength Real
  14. ::    Direction            =    Hor | Ver 
  15. ::    Word                :==    String
  16. ::    Position            :==    (!Int,!Int)
  17.  
  18. MediumStrength            :==    Strength 0.5
  19. EasyStrength            :==    Strength 0.25
  20. VeryEasyStrength        :==    Strength 0.125
  21.  
  22. instance == Playmode
  23. instance == Playerkind
  24. instance == Player
  25. instance == Strength
  26. instance == Direction
  27. instance == Placing
  28.  
  29. otherplayer :: !Player -> Player
  30.  
  31.  
  32. /***************************************************************************************************************
  33.     The type Progress is by the computer player function when determining a move. The computer player checks in 
  34.     alfabetic order all words starting with a particular letter.
  35.     
  36.     Words starting with a particular letter are handled quickly when the starting letter does not occur on the 
  37.     letter bar. In that case the positions on the board are checked if they are valid as a starting position for 
  38.     the word (horizontal and vertical are handled separately).
  39.     
  40.     For words starting with a particular letter on the letter bar more board positions need to be examined.
  41. ****************************************************************************************************************/
  42. ::    Progress
  43.     =    Letter Char Placing
  44.     |    Finish Placing
  45. ::    Placing
  46.     =    {    word    :: Word
  47.         ,    pos        :: Position
  48.         ,    dir        :: Direction
  49.         ,    score    :: Int
  50.         }
  51. initplacing            :: Placing
  52. getplacing            :: !Progress -> Placing
  53. getletter            :: !Progress -> Char
  54. notyetready            :: !Progress -> Bool
  55.  
  56.  
  57. /***************************************************************************************************************
  58.     The Tree type stores the lexicon. 
  59. ****************************************************************************************************************/
  60.  
  61. ::    Tree
  62.     =    Leaf !String
  63.     |    Node Tree !String Tree
  64.  
  65. readtree            :: !Files            -> (!Tree,!Files)
  66. writetree            :: !Tree !Files        -> Files
  67. wordsstartingwith    :: !Char !Tree        -> [Word]
  68. seek                :: !Tree !String    -> Bool
  69. sizetree            :: !Tree            -> Int
  70. depthtree            :: !Tree            -> Int
  71. addwordstotree        :: !Tree ![Word]    -> Tree
  72.  
  73.  
  74. /***************************************************************************************************************
  75.     Global Ids.
  76. ****************************************************************************************************************/
  77.  
  78. scrabbleId        :==    1
  79. toevoegId        :==    2
  80. computerId        :== 1
  81.