home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / club100 / pg / pggame / nim.100 < prev    next >
Text File  |  2006-10-19  |  3KB  |  84 lines

  1.      NIM.BA  by Paul Globman
  2.        Copyright (c) 1991
  3.      -----------------------
  4.  
  5. In the game of nim, two players take turns removing stones from several
  6. piles of stones. At each turn, a player may remove as many stones as he or she
  7. likes, but all from the same pile. The player to remove the last stone wins.
  8.  
  9. In NIM.BA, the piles of stones are represented by numbers, and the Model
  10. 100/200 is your opponent.  When you run NIM.BA, you begin at LEVEL 5 (5 piles
  11. of stones).  The number of stones in each pile is randomly selected, between
  12. 1 and 7 stones per pile.
  13.  
  14. Use the left/right ARROW KEY to select a pile, then press a number (1-7) to
  15. indicate how many stones to remove from the selected pile.  You will always
  16. have the first move, and the play will alternate between you and the computer.
  17. The program will ignore any attempt to remove more stones than the selected
  18. pile contains.
  19.  
  20. When all stones are removed, the program will beep and indicate who won.  The
  21. following keys (commands) are available at any time during the game...
  22.  
  23. ESC - press ESC to abort the game and return to the Menu.
  24.  
  25. NEW - press "N" to abort the game and play a new game.
  26.  
  27. REPEAT - press "R" to abort the game and restart with the same piles of stones.
  28.  
  29. SKILL - press "S" to abort the game and start a new game at the next highest
  30. skill level.  Increasing the skill level just increases the number of piles of
  31. stones.  Ten (10 piles) is the highest skill level and the most difficult
  32. level to beat the computer.
  33.  
  34. NOTE: These commands respond to uppercase characters only, so press the
  35. CAPS LOCK key.
  36.  
  37. Have fun.... Paul Globman [72227,1661]
  38. -----------------------------------------------------------------------------
  39. 0 REM NIM.BA (c) 1991 by Paul Globman
  40. 1 DEFINTA-Z:P$="   "+CHR$(152)+"   ":FORI=27TO29:B$=B$+CHR$(I):NEXT:L=5
  41. 2 B$=B$+"NRS":X=VAL(RIGHT$(TIME$,2)):X=RND(-VAL(MID$(TIME$,4,2))*60+X)
  42. 3 TT=0:FORI=1TOL:R(I)=INT(RND(1)*7)+1:TT=TT+R(I):B(I)=R(I):NEXT:P=1
  43. 4 X$="NIM.BA (c) 1991 by Paul Globman":CLS:T=TT:FORI=0TO4STEP2
  44. 5 LINE(0+I,0+I)-(239-I,63-I),1,B:NEXT:PRINT@45,X$
  45. 6 GOSUB22
  46. 7 X$=INKEY$:IFX$=""THEN7
  47. 8 X=INSTR(1,B$,X$):IFX=0THEN14
  48. 9 ONXGOTO18,11,12,3,13,10
  49. 10 L=L+1:L=L+(L>10):GOTO3
  50. 11 P=P+1:P=P+(P>L):GOSUB23:GOTO7
  51. 12 P=P-1:P=P-(P=0):GOSUB23:GOTO7
  52. 13 FORI=1TOL:R(I)=B(I):NEXT:GOTO4
  53. 14 X=VAL(X$):IFX<1ORX>R(P)THEN6
  54. 15 R(P)=R(P)-X:T=T-X:IFT<>0THEN19
  55. 16 BEEP:BEEP:PRINT@248,"You ";
  56. 17 PRINT"win... Please try again":GOTO7
  57. 18 MENU
  58. 19 GOSUB22:GOSUB24:Y=S(J):P=I:PRINT@208,"I'll take"Y"from pile"I
  59. 20 R(I)=R(I)-Y:T=T-Y:FORI=1TO1500:NEXT:PRINT@205,SPACE$(30):IFT<>0THEN6
  60. 21 BEEP:BEEP:PRINT@248,"I ";:GOTO17
  61. 22 FORI=1TOL:PRINT@162+I*3,R(I):NEXT
  62. 23 PRINT@203+(P-1)*3,P$:RETURN
  63. 24 B4=0:B2=0:B1=0:FORI=1TOL:R=R(I):B1=B1+RMOD2:B2=B2-(R=2ORR=3ORR>5)
  64. 25 B4=B4-(R>3):NEXT:F=4*(B4MOD2)+2*(B2MOD2)+B1MOD2:IFF>0THEN28
  65. 26 I=RND(1)*(L+1):IFR(I)=0THEN26
  66. 27 S(J)=RND(1)*R(I)+1:RETURN
  67. 28 ONFGOTO29,30,31,32,33,34,35
  68. 29 RESTORE38:GOTO36
  69. 30 RESTORE39:GOTO36
  70. 31 RESTORE40:GOTO36
  71. 32 RESTORE41:GOTO36
  72. 33 RESTORE42:GOTO36
  73. 34 RESTORE43:GOTO36
  74. 35 RESTORE44
  75. 36 FORI=1TO4:READQ(I),S(I):NEXT:FORI=1TOL:FORJ=1TO4:IFR(I)=Q(J)THENRETURN
  76. 37 NEXTJ:NEXTI
  77. 38 DATA 7,1,5,1,3,1,1,1
  78. 39 DATA 7,2,6,2,3,2,2,2
  79. 40 DATA 7,3,6,1,3,3,2,1
  80. 41 DATA 7,4,6,4,5,4,4,4
  81. 42 DATA 7,5,6,3,5,5,4,3
  82. 43 DATA 7,6,6,6,5,2,4,2
  83. 44 DATA 7,7,6,5,5,3,4,1
  84.