home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / vmsnet.sources.games / hi-q / part01 next >
Internet Message Format  |  1992-08-03  |  10KB

  1. Path: uunet!stanford.edu!rutgers!ub!acsu.buffalo.edu!ubvmsb.cc.buffalo.edu!masmummy
  2. From: masmummy@ubvmsb.cc.buffalo.edu (William Brennessel)
  3. Newsgroups: vmsnet.sources.games
  4. Subject: Re: Request for DCL games or programs.
  5. Message-ID: <BpBA8x.7BJ@acsu.buffalo.edu>
  6. Date: 4 Jun 92 09:00:00 GMT
  7. References: <1992Jun3.143623.1@bbs.mdcbbs.com>
  8. Sender: nntp@acsu.buffalo.edu
  9. Organization: University at Buffalo
  10. Lines: 303
  11. News-Software: VAX/VMS VNEWS 1.41
  12. Nntp-Posting-Host: ubvmsb.cc.buffalo.edu
  13.  
  14. Here's a fun DCL challenge... HI-Q.
  15.  
  16. - Bill
  17.  
  18. -----------------------------------------------------------------------------
  19.  
  20. $ Facility_Name=    "HI-Q"
  21. $ Facility_Version=    "V-1.00 18-Mar-1988"
  22. $ Verify=F$Verify(F$TRNLNM("COMMAND_DEBUG"))
  23. $ On Control_Y then goto Exit
  24. $ Set Symbol/Scope=NoGlobal
  25. $!
  26. $! Copyright ) (c) 1988, by Michael Bednarek
  27. $! The distribution of this file is unrestricted as long as this notice
  28. $! remains intact.
  29. $!
  30. $! Michael Bednarek, Institute of Applied Economic and Social Research (IAESR)
  31. $!    //  Melbourne University,Parkville 3052, AUSTRALIA, Phone:+61 3 344 5744
  32. $!  \X/   Domain:u3369429@{murdu.oz.au | ucsvc.dn.mu.oz.au} | mb@munnari.oz.au
  33. $!        "bang":...UUNET!munnari!murdu!u3369429     PSI%23343000301::U3369429
  34. $!
  35. $ Say="Write SYS$Output"
  36. $ Ask="Inquire/NoPunctuation"
  37. $!
  38. $ Gosub Intro
  39. $ Say "Initializing ..."
  40. $ On Control_Y then goto EndGame
  41. $ Gosub Init
  42. $NewGame: Gosub InitTable
  43. $ Gosub DrawBoard
  44. $!
  45. $GetInput:
  46. $ Say CSI,"1;1H"    ! set the cursor always at the top to prevent scrolling
  47. $ Ask Command ""
  48. $ Cmd=Command-"J"
  49. $ Jump=Cmd.nes.Command
  50. $ If F$Locate(".''Cmd'.",Commands).ne.lCommands then gosub 'Cmd
  51. $ Goto GetInput
  52. $EndGame: Set Key/State=DEFAULT/NoLog
  53. $ Delete/Key/NoLog/All/State=(Curious,Curiouser)
  54. $ Set Terminal/NoApplication_Keypad/Line_Editing/Echo
  55. $ Say A,CSI,"23;1H",CSI,"?25h"    ! exit on last line, cursor on
  56. $Exit:
  57. $ Exit 0*F$Verify(Verify)+1
  58. $!----------------------------------------------------------------------------
  59. $Intro:
  60. $ Say Facility_Name," ",Facility_Version
  61. $ Type SYS$Input
  62.  
  63. A well known one-player game, once implemented by Bill Conley for MS-DOS,
  64. here presented by Michael Bednarek, entirely in Vax/VMS DCL.
  65.  
  66. A version in AmigaBasic is also available.
  67.  
  68.    //
  69.  \X/   u3369429@{murdu.oz.au | ucsvc.dn.mu.oz.au} | mb@munnari.oz.au
  70. $ Ask Yes "Do you want help? "
  71. $ If .not.Yes then Return
  72. $ShowHelp: Type SYS$Input
  73.  
  74. The game is played on a board with 33 holes arranged in a cross pattern
  75. and begins with all except the center hole being filled with a peg.
  76.  
  77. The object of the game is to remove as many pegs as possible by jumping pegs
  78. either horizontally or vertically and removing pegs that are jumped over.
  79. No diagonal moves or moves without jumping are allowed.
  80.  
  81. You move around the board using the numeric keypad keys:
  82.  
  83.      8 = Up
  84.  4 Left         6 = Right
  85.      2 = Down
  86.  
  87. You jump by pressing PF1 plus a keypad key, e.g. to jump upwards press PF1 KP8.
  88. Press PF1 twice to exit the game (or F10 on a VT200).
  89. Note: pressing CTRL/Z will not end the game!
  90. PF2 will produce this page again, and PF4 will reset the board.
  91.  
  92. Good luck.
  93. $ Read/End_of_File=Exit/Error=Return/Prompt="Hit RETURN to continue"-
  94.     /Time_Out=30 SYS$Command Yes
  95. $Return: Return
  96. $!----------------------------------------------------------------------------
  97. $UP:
  98. $ y=CurY-1
  99. $ x=CurX
  100. $ Goto Play
  101. $RIGHT:
  102. $ y=CurY
  103. $ x=CurX+1
  104. $ Goto Play
  105. $LEFT:
  106. $ y=CurY
  107. $ x=CurX-1
  108. $ Goto Play
  109. $DOWN:
  110. $ y=CurY+1
  111. $ x=CurX
  112. $Play:
  113. $ If F$Type(Table'y''x).nes."" then goto Play1
  114. $Error:
  115. $ Say BEL
  116. $ Return
  117. $Play1:
  118. $ If Jump then goto Jump
  119. $ Call DrawOne 'F$Integer(CurY*3-2) 'F$Integer(CurX*5+19) 0 &Table'CurY''CurX
  120. $ CurY=y
  121. $ CurX=x
  122. $ Call DrawOne 'F$Integer(CurY*3-2) 'F$Integer(CurX*5+19) 7 &Table'CurY''CurX
  123. $ Return
  124. $Jump:
  125. $ If Table'CurY''CurX'.ne."1" then goto Error    ! Currently on a peg?
  126. $ If Table'y''x'.ne."1" then goto Error        ! Jumping over a peg?
  127. $ jy=CurY+(y-CurY)*2
  128. $ jx=CurX+(x-CurX)*2
  129. $ If F$Type(Table'y''x).eqs."" then goto Error    ! Out of bounds?
  130. $ If Table'jy''jx'.ne."0" then goto Error    ! Target empty?
  131. $ Table'CurY''CurX'="0"    ! The current position becomes empty & un-highlighted
  132. $ Call DrawOne 'F$Integer(CurY*3-2) 'F$Integer(CurX*5+19) 0 0
  133. $ Table'y''x'="0"    ! The skipped position becomes empty, too.
  134. $ Call DrawOne 'F$Integer(y*3-2) 'F$Integer(x*5+19) 0 0
  135. $ Table'jy''jx'="1"    ! The target position becomes filled & highlighted
  136. $ Call DrawOne 'F$Integer(jy*3-2) 'F$Integer(jx*5+19) 7 1
  137. $ CurY=jy
  138. $ CurX=jx
  139. $ nPegs=nPegs-1
  140. $ Gosub DrawScore
  141. $Return
  142. $!----------------------------------------------------------------------------
  143. $Help:
  144. $ Say A,CLS
  145. $ Gosub ShowHelp
  146. $ Gosub DrawBoard
  147. $ Return
  148. $!----------------------------------------------------------------------------
  149. $Init:
  150. $ If F$GetDVI("TT","TT_DECCRT") then goto Start0
  151. $ Say "Sorry, HI-Q needs a DEC CRT terminal."
  152. $ Goto Exit
  153. $Start0:If F$Mode().nes."BATCH" then goto Init0
  154. $ Say "You can't play HI-Q in batch."
  155. $ Goto Exit
  156. $!
  157. $Init0:
  158. $ BEL[0,8]=7
  159. $ ESC[0,8]=27
  160. $ CSI=ESC+"["
  161. $ CLS=CSI+"2J"+CSI+"1;1H"    ! Clear Screen & Home
  162. $ G=ESC+"(0"            ! DEC Special Graphics character set
  163. $ A=ESC+"(B"            ! ASCII character set
  164. $!
  165. $ Set Terminal/Application_Keypad/NoLine_Editing/NoEcho
  166. $ Define/Key/NoLog PF1 ""/Set_State=Curiouser/If_State=Curious
  167. $ Define/Key/NoLog PF2 HELP/Terminate/NoEcho/If_State=Curious
  168. $ Define/Key/NoLog HELP HELP/Terminate/NoEcho/If_State=Curious
  169. $ Define/Key/NoLog PF4 NEWGAME/Terminate/NoEcho/If_State=Curious
  170. $ Define/Key/NoLog KP8 UP/Terminate/NoEcho/If_State=Curious
  171. $ Define/Key/NoLog KP6 RIGHT/Terminate/NoEcho/If_State=Curious
  172. $ Define/Key/NoLog KP4 LEFT/Terminate/NoEcho/If_State=Curious
  173. $ Define/Key/NoLog KP2 DOWN/Terminate/NoEcho/If_State=Curious
  174. $ Define/Key/NoLog F10 EndGame/Terminate/NoEcho/If_State=Curious
  175. $ Set Key/State=Curious/NoLog
  176. $ Define/Key/NoLog KP8 JUP/Terminate/NoEcho/If_State=Curiouser
  177. $ Define/Key/NoLog KP6 JRIGHT/Terminate/NoEcho/If_State=Curiouser
  178. $ Define/Key/NoLog KP4 JLEFT/Terminate/NoEcho/If_State=Curiouser
  179. $ Define/Key/NoLog KP2 JDOWN/Terminate/NoEcho/If_State=Curiouser
  180. $ Define/Key/NoLog PF1 EndGame/Terminate/NoEcho/If_State=Curiouser
  181. $!
  182. $ Commands=".UP.RIGHT.LEFT.DOWN.ENDGAME.HELP.NEWGAME.CHEAT."
  183. $ lCommands=F$Length(Commands)
  184. $ Cmd=""
  185. $ nGames=-1
  186. $ nPegs=32
  187. $ BestResult=32
  188. $ Say CSI,"?25l"    ! Cursor Off
  189. $Return
  190. $!----------------------------------------------------------------------------
  191. $Cheat:
  192. $InitTable:
  193. $ CurY=0
  194. $iNextRow: CurX=0
  195. $ CurY=CurY+1
  196. $ If CurY.le.7 then goto iNextCol
  197. $ Table44="0"
  198. $ CurY=6
  199. $ CurX=4
  200. $ If nPegs.lt.BestResult then BestResult=nPegs
  201. $ nGames=nGames+1
  202. $ nPegs=32
  203. $ If Cmd.nes."CHEAT" then Return
  204. $ Table52="1"
  205. $ Table53="1"
  206. $ Table64="1"
  207. $ CurY=5
  208. $ CurX=2
  209. $ nPegs=3
  210. $ Return
  211. $iNextCol: CurX=CurX+1
  212. $ If CurX.gt.7 then goto iNextRow
  213. $ If (CurY.lt.3 .or. CurY.gt.5).and.(CurX.lt.3 .or. CurX.gt.5) -
  214.     .or. CurY.eq.4 .and. CurX.eq.4 then goto iNextCol
  215. $ Table'CurY''CurX="1"
  216. $ If Cmd.nes."CHEAT" then goto iNextCol
  217. $ Table'CurY''CurX="0"
  218. $ Goto iNextCol
  219. $!----------------------------------------------------------------------------
  220. $DrawBoard:
  221. $Say CLS
  222. $ y=0
  223. $NextRow: x=0
  224. $ y=y+1
  225. $ If y.le.7 then goto NextCol
  226. $!
  227. $ Say A,CSI,"3;54H",F$FAO("!SL game!%S played",nGames),CSI,"K"
  228. $ Say   CSI,"4;54HBest result was ",BestResult
  229. $ Say   CSI,"17;2HKP8 = Up     Precede",CSI,"17;54H6 or more left .. nice try"
  230. $ Say   CSI,"18;2HKP6 = Right  with",    CSI,"18;54H5 left .............. good"
  231. $ Say   CSI,"19;2HKP4 = Left   PF1",    CSI,"19;54H4 left ............ better"
  232. $ Say   CSI,"20;2HKP2 = Down   to jump",CSI,"20;54H3 left ..... really clever"
  233. $ Say                    CSI,"21;54H2 left ........ a sharpie!"
  234. $ Say   CSI,"22;2HPF2 = Help",        CSI,"22;54H1 left ... take a deep bow"
  235. $ Say   CSI,"23;2HPF4 = Reset",        CSI,"23;54H1 left in center...perfect"
  236. $ Say   CSI,"23;15HPress PF1 twice to exit"
  237. $ Gosub DrawScore
  238. $Return
  239. $NextCol: x=x+1
  240. $ If x.gt.7 then goto NextRow
  241. $ If F$Type(Table'y''x).eqs."" then goto NextCol
  242. $ Attr=(y.eq.CurY .and. x.eq.CurX)*7
  243. $ Call DrawOne 'F$Integer(y*3-2) 'F$Integer(x*5+19) 'Attr &Table'y''x
  244. $ Goto NextCol
  245. $!----------------------------------------------------------------------------
  246. $DrawOne: Subroutine
  247. $! Draws a box, either filled or empty, highlighted or plain.
  248. $! P1 = Row number        P2 = Column number
  249. $! P3 = Attributes for SGR    P4 = Empty (0) /filled (1)
  250. $ P1=F$Integer(P1)    ! Necessary because of "P1+1" below
  251. $! The next line not only works if P4="0"|"1", but also if P4="TABLE44" and
  252. $! TABLE44="0"|"1".
  253. $ P4=F$Element(F$Integer('P4),",","Hx  x,Hxaax")
  254. $ Say G,CSI,P3,"m",-
  255.       CSI,P1,";",P2,"Hlqqk",CSI,P1+1,";",P2,P4,CSI,P1+2,";",P2,"Hmqqj",-
  256.       CSI,"0m",A
  257. $EndSubroutine
  258. $!----------------------------------------------------------------------------
  259. $DrawScore:
  260. $ Say A,CSI,"11;63H",F$FAO("!2SL peg!%S remaining",nPegs),CSI,"K"
  261. $ If nPegs.eq.1 then goto Finish
  262. $! Check whether the player is stuck
  263. $ y=0
  264. $cNextRow: x=0
  265. $ y=y+1
  266. $ If y.le.7 then goto cNextCol
  267. $Finish: Say CSI,"23;2H",CSI,"5;7mPF4 = Reset"
  268. $ Say CSI,"23;15HPress PF1 twice to exit",CSI,"0m",BEL
  269. $ Goto Illuminate
  270. $cNextCol: x=x+1
  271. $ If x.gt.7 then goto cNextRow
  272. $ If F$Type(Table'y''x).eqs."" then goto cNextCol
  273. $! Look at 3 boxes horizontally and vertically at once
  274. $ If F$Type(Table'y''F$Integer(x+2)).eqs."" then goto cCol
  275. $ Check=Table'y''x+Table'y''F$Integer(x+1)+Table'y''F$Integer(x+2)
  276. $ If Check.eqs."110" .or. Check.eqs."011" then goto Illuminate
  277. $cCol:
  278. $ If F$Type(Table'F$Integer(y+2)''x).eqs."" then goto cNextCol
  279. $ Check=Table'y''x+Table'F$Integer(y+1)''x+Table'F$Integer(y+2)''x
  280. $ If Check.nes."110" .and. Check.nes."011" then goto cNextCol
  281. $Illuminate:
  282. $ If nPegs.gt.6 then Return
  283. $ Goto Illuminate'nPegs
  284. $Illuminate6:
  285. $ Say A,CSI,"17;54H",CSI,"7m6 or more left .. nice try",CSI,"0m"
  286. $ Return
  287. $Illuminate5:
  288. $ Say A,CSI,"17;54H6 or more left .. nice try"
  289. $ Say A,CSI,"18;54H",CSI,"7m5 left .............. good",CSI,"0m"
  290. $ Return
  291. $Illuminate4:
  292. $ Say A,CSI,"18;54H5 left .............. good"
  293. $ Say A,CSI,"19;54H",CSI,"7m4 left ............ better",CSI,"0m"
  294. $ Return
  295. $Illuminate3:
  296. $ Say A,CSI,"19;54H4 left ............ better"
  297. $ Say A,CSI,"20;54H",CSI,"7m3 left ..... really clever",CSI,"0m"
  298. $ Return
  299. $Illuminate2:
  300. $ Say A,CSI,"20;54H3 left ..... really clever"
  301. $ Say A,CSI,"21;54H",CSI,"7m2 left ........ a sharpie!",CSI,"0m"
  302. $ Return
  303. $Illuminate1:
  304. $ Say A,CSI,"21;54H2 left ........ a sharpie!"
  305. $ If Table44.eqs."1" then goto Illuminate0
  306. $ Say A,CSI,"22;54H",CSI,"7m1 left ... take a deep bow",CSI,"0m"
  307. $ Return
  308. $Illuminate0:
  309. $ Say A,CSI,"23;54H",CSI,"7m1 left in center...perfect",CSI,"0m"
  310. $ Return
  311.