ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

157 lines
3.8 KiB

  1. 100 PRINT TAB(33);"NIM"
  2. 110 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
  3. 120 PRINT:PRINT:PRINT
  4. 210 DIM A(100),B(100,10),D(2)
  5. 220 PRINT "THIS IS THE GAME OF NIM."
  6. 230 PRINT "DO YOU WANT INSTRUCTIONS";
  7. 240 INPUT Z$
  8. 250 IF Z$="NO" THEN 440
  9. 260 IF Z$="no" THEN 440
  10. 270 IF Z$="YES" THEN 310
  11. 280 IF Z$="yes" THEN 310
  12. 290 PRINT "PLEASE ANSWER YES OR NO"
  13. 300 GOTO 240
  14. 310 PRINT "THE GAME IS PLAYED WITH A NUMBER OF PILES OF OBJECTS."
  15. 320 PRINT "ANY NUMBER OF OBJECTS ARE REMOVED FROM ONE PILE BY YOU AND"
  16. 330 PRINT "THE MACHINE ALTERNATELY. ON YOUR TURN, YOU MAY TAKE"
  17. 340 PRINT "ALL THE OBJECTS THAT REMAIN IN ANY PILE, BUT YOU MUST"
  18. 350 PRINT "TAKE AT LEAST ONE OBJECT, AND YOU MAY TAKE OBJECTS FROM"
  19. 360 PRINT "ONLY ONE PILE ON A SINGLE TURN. YOU MUST SPECIFY WHETHER"
  20. 370 PRINT "WINNING IS DEFINED AS TAKING OR NOT TAKING THE LAST OBJECT,"
  21. 380 PRINT "THE NUMBER OF PILES IN THE GAME, AND HOW MANY OBJECTS ARE"
  22. 390 PRINT "ORIGINALLY IN EACH PILE. EACH PILE MAY CONTAIN A"
  23. 400 PRINT "DIFFERENT NUMBER OF OBJECTS."
  24. 410 PRINT "THE MACHINE WILL SHOW ITS MOVE BY LISTING EACH PILE AND THE"
  25. 420 PRINT "NUMBER OF OBJECTS REMAINING IN THE PILES AFTER EACH OF ITS"
  26. 430 PRINT "MOVES."
  27. 440 PRINT
  28. 450 PRINT "ENTER WIN OPTION - 1 TO TAKE LAST, 2 TO AVOID LAST";
  29. 460 INPUT W
  30. 470 IF W=1 THEN 490
  31. 480 IF W<>2 THEN 450
  32. 490 PRINT "ENTER NUMBER OF PILES";
  33. 500 INPUT N
  34. 510 IF N>100 THEN 490
  35. 520 IF N<1 THEN 490
  36. 530 IF N<>INT(N) THEN 490
  37. 540 PRINT "ENTER PILE SIZES"
  38. 550 FOR I=1 TO N
  39. 560 PRINT I;
  40. 570 INPUT A(I)
  41. 580 IF A(I)>2000 THEN 560
  42. 590 IF A(I)<1 THEN 560
  43. 600 IF A(I)<>INT(A(I)) THEN 560
  44. 610 NEXT I
  45. 620 PRINT "DO YOU WANT TO MOVE FIRST";
  46. 630 INPUT Q9$
  47. 640 IF Q9$="YES" THEN 1450
  48. 650 IF Q9$="yes" THEN 1450
  49. 660 IF Q9$="NO" THEN 700
  50. 670 IF Q9$="no" THEN 700
  51. 680 PRINT "PLEASE ANSWER YES OR NO."
  52. 690 GOTO 630
  53. 700 IF W=1 THEN 940
  54. 710 LET C=0
  55. 720 FOR I=1 TO N
  56. 730 IF A(I)=0 THEN 770
  57. 740 LET C=C+1
  58. 750 IF C=3 THEN 840
  59. 760 LET D(C)=I
  60. 770 NEXT I
  61. 780 IF C=2 THEN 920
  62. 790 IF A(D(1))>1 THEN 820
  63. 800 PRINT "MACHINE LOSES"
  64. 810 GOTO 1640
  65. 820 PRINT "MACHINE WINS"
  66. 830 GOTO 1640
  67. 840 LET C=0
  68. 850 FOR I=1 TO N
  69. 860 IF A(I)>1 THEN 940
  70. 870 IF A(I)=0 THEN 890
  71. 880 LET C=C+1
  72. 890 NEXT I
  73. 900 IF C/2<>INT(C/2) THEN 800
  74. 910 GOTO 940
  75. 920 IF A(D(1))=1 THEN 820
  76. 930 IF A(D(2))=1 THEN 820
  77. 940 FOR I=1 TO N
  78. 950 LET E=A(I)
  79. 960 FOR J=0 TO 10
  80. 970 LET F=E/2
  81. 980 LET B(I,J)=2*(F-INT(F))
  82. 990 LET E=INT(F)
  83. 1000 NEXT J
  84. 1010 NEXT I
  85. 1020 FOR J=10 TO 0 STEP -1
  86. 1030 LET C=0
  87. 1040 LET H=0
  88. 1050 FOR I=1 TO N
  89. 1060 IF B(I,J)=0 THEN 1110
  90. 1070 LET C=C+1
  91. 1080 IF A(I)<=H THEN 1110
  92. 1090 LET H=A(I)
  93. 1100 LET G=I
  94. 1110 NEXT I
  95. 1120 IF C/2<>INT(C/2) THEN 1190
  96. 1130 NEXT J
  97. 1140 LET E=INT(N*RND(1)+1)
  98. 1150 IF A(E)=0 THEN 1140
  99. 1160 LET F=INT(A(E)*RND(1)+1)
  100. 1170 LET A(E)=A(E)-F
  101. 1180 GOTO 1380
  102. 1190 LET A(G)=0
  103. 1200 FOR J=0 TO 10
  104. 1210 LET B(G,J)=0
  105. 1220 LET C=0
  106. 1230 FOR I=1 TO N
  107. 1240 IF B(I,J)=0 THEN 1260
  108. 1250 LET C=C+1
  109. 1260 NEXT I
  110. 1270 LET A(G)=A(G)+2*(C/2-INT(C/2))*2^J
  111. 1280 NEXT J
  112. 1290 IF W=1 THEN 1380
  113. 1300 LET C=0
  114. 1310 FOR I=1 TO N
  115. 1320 IF A(I)>1 THEN 1380
  116. 1330 IF A(I)=0 THEN 1350
  117. 1340 LET C=C+1
  118. 1350 NEXT I
  119. 1360 IF C/2<>INT(C/2) THEN 1380
  120. 1370 LET A(G)=1-A(G)
  121. 1380 PRINT "PILE SIZE"
  122. 1390 FOR I=1 TO N
  123. 1400 PRINT I;A(I)
  124. 1410 NEXT I
  125. 1420 IF W=2 THEN 1450
  126. 1430 GOSUB 1570
  127. 1440 IF Z=1 THEN 820
  128. 1450 PRINT "YOUR MOVE - PILE, NUMBER TO BE REMOVED";
  129. 1460 INPUT X,Y
  130. 1470 IF X>N THEN 1450
  131. 1480 IF X<1 THEN 1450
  132. 1490 IF X<>INT(X) THEN 1450
  133. 1500 IF Y>A(X) THEN 1450
  134. 1510 IF Y<1 THEN 1450
  135. 1520 IF Y<>INT(Y) THEN 1450
  136. 1530 LET A(X)=A(X)-Y
  137. 1540 GOSUB 1570
  138. 1550 IF Z=1 THEN 800
  139. 1560 GOTO 700
  140. 1570 LET Z=0
  141. 1580 FOR I=1 TO N
  142. 1590 IF A(I)=0 THEN 1610
  143. 1600 RETURN
  144. 1610 NEXT I
  145. 1620 LET Z=1
  146. 1630 RETURN
  147. 1640 PRINT "do you want to play another game";
  148. 1650 INPUT Q9$
  149. 1660 IF Q9$="YES" GOTO 1720
  150. 1670 IF Q9$="yes" GOTO 1720
  151. 1680 IF Q9$="NO" GOTO 1730
  152. 1690 IF Q9$="no" GOTO 1730
  153. 1700 PRINT "PLEASE. YES OR NO."
  154. 1710 GOTO 1650
  155. 1720 GOTO 440
  156. 1730 END