mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-13 21:46:58 -08:00
Removed spaces from top-level directory names.
Spaces tend to cause annoyances in a Unix-style shell environment. This change fixes that.
This commit is contained in:
7
16_Bug/README.md
Normal file
7
16_Bug/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
### Bug
|
||||
|
||||
As published in Basic Computer Games (1978)
|
||||
https://www.atariarchives.org/basicgames/showpage.php?page=30
|
||||
|
||||
Downloaded from Vintage Basic at
|
||||
http://www.vintage-basic.net/games.html
|
||||
256
16_Bug/bug.bas
Normal file
256
16_Bug/bug.bas
Normal file
@@ -0,0 +1,256 @@
|
||||
10 PRINT TAB(34);"BUG"
|
||||
20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||
30 PRINT:PRINT:PRINT
|
||||
40 REM
|
||||
50 A=0: B=0: H=0: L=0: N=0: P=0: Q=0: R=0: S=0: T=0: U=0: V=0: Y=0
|
||||
60 PRINT "THE GAME BUG"
|
||||
70 PRINT "I HOPE YOU ENJOY THIS GAME."
|
||||
80 PRINT
|
||||
90 PRINT "DO YOU WANT INSTRUCTIONS";
|
||||
100 INPUT Z$
|
||||
110 IF Z$="NO" THEN 300
|
||||
120 PRINT "THE OBJECT OF BUG IS TO FINISH YOUR BUG BEFORE I FINISH"
|
||||
130 PRINT "MINE. EACH NUMBER STANDS FOR A PART OF THE BUG BODY."
|
||||
140 PRINT "I WILL ROLL THE DIE FOR YOU, TELL YOU WHAT I ROLLED FOR YOU"
|
||||
150 PRINT "WHAT THE NUMBER STANDS FOR, AND IF YOU CAN GET THE PART."
|
||||
160 PRINT "IF YOU CAN GET THE PART I WILL GIVE IT TO YOU."
|
||||
170 PRINT "THE SAME WILL HAPPEN ON MY TURN."
|
||||
180 PRINT "IF THERE IS A CHANGE IN EITHER BUG I WILL GIVE YOU THE"
|
||||
190 PRINT "OPTION OF SEEING THE PICTURES OF THE BUGS."
|
||||
200 PRINT "THE NUMBERS STAND FOR PARTS AS FOLLOWS:"
|
||||
210 PRINT "NUMBER","PART","NUMBER OF PART NEEDED"
|
||||
220 PRINT "1","BODY","1"
|
||||
230 PRINT "2","NECK","1"
|
||||
240 PRINT "3","HEAD","1"
|
||||
250 PRINT "4","FEELERS","2"
|
||||
260 PRINT "5","TAIL","1"
|
||||
270 PRINT "6","LEGS","6"
|
||||
280 PRINT
|
||||
290 PRINT
|
||||
300 IF Y>0 THEN 2480
|
||||
310 Z=INT(6*RND(1)+1)
|
||||
320 C=1
|
||||
330 PRINT "YOU ROLLED A";Z
|
||||
340 ON Z GOTO 350,430,540,650,760,870
|
||||
350 PRINT "1=BODY"
|
||||
360 IF B=1 THEN 410
|
||||
370 PRINT "YOU NOW HAVE A BODY."
|
||||
380 B=1
|
||||
390 C=0
|
||||
400 GOTO 970
|
||||
410 PRINT "YOU DO NOT NEED A BODY."
|
||||
420 GOTO 970
|
||||
430 PRINT "2=NECK"
|
||||
440 IF N=1 THEN 500
|
||||
450 IF B=0 THEN 520
|
||||
460 PRINT "YOU NOW HAVE A NECK."
|
||||
470 N=1
|
||||
480 C=0
|
||||
490 GOTO 970
|
||||
500 PRINT "YOU DO NOT NEED A NECK."
|
||||
510 GOTO 970
|
||||
520 PRINT "YOU DO NOT HAVE A BODY."
|
||||
530 GOTO 970
|
||||
540 PRINT "3=HEAD"
|
||||
550 IF N=0 THEN 610
|
||||
560 IF H=1 THEN 630
|
||||
570 PRINT "YOU NEEDED A HEAD."
|
||||
580 H=1
|
||||
590 C=0
|
||||
600 GOTO 970
|
||||
610 PRINT "YOU DO NOT HAVE A NECK."
|
||||
620 GOTO 970
|
||||
630 PRINT "YOU HAVE A HEAD."
|
||||
640 GOTO 970
|
||||
650 PRINT "4=FEELERS"
|
||||
660 IF H=0 THEN 740
|
||||
670 IF A=2 THEN 720
|
||||
680 PRINT "I NOW GIVE YOU A FEELER."
|
||||
690 A=A+1
|
||||
700 C=0
|
||||
710 GOTO 970
|
||||
720 PRINT "YOU HAVE TWO FEELERS ALREADY."
|
||||
730 GOTO 970
|
||||
740 PRINT "YOU DO NOT HAVE A HEAD."
|
||||
750 GOTO 970
|
||||
760 PRINT "5=TAIL"
|
||||
770 IF B=0 THEN 830
|
||||
780 IF T=1 THEN 850
|
||||
790 PRINT "I NOW GIVE YOU A TAIL."
|
||||
800 T=T+1
|
||||
810 C=0
|
||||
820 GOTO 970
|
||||
830 PRINT "YOU DO NOT HAVE A BODY."
|
||||
840 GOTO 970
|
||||
850 PRINT "YOU ALREADY HAVE A TAIL."
|
||||
860 GOTO 970
|
||||
870 PRINT "6=LEG"
|
||||
880 IF L=6 THEN 940
|
||||
890 IF B=0 THEN 960
|
||||
900 L=L+1
|
||||
910 C=0
|
||||
920 PRINT "YOU NOW HAVE";L;"LEGS."
|
||||
930 GOTO 970
|
||||
940 PRINT "YOU HAVE 6 FEET ALREADY."
|
||||
950 GOTO 970
|
||||
960 PRINT "YOU DO NOT HAVE A BODY."
|
||||
970 X=INT(6*RND(1)+1)
|
||||
971 PRINT
|
||||
975 FOR DELAY=1 TO 2000:NEXT DELAY
|
||||
980 PRINT "I ROLLED A";X
|
||||
990 ON X GOTO 1000,1080,1190,1300,1410,1520
|
||||
1000 PRINT "1=BODY"
|
||||
1010 IF P=1 THEN 1060
|
||||
1020 PRINT "I NOW HAVE A BODY."
|
||||
1030 C=0
|
||||
1040 P=1
|
||||
1050 GOTO 1630
|
||||
1060 PRINT "I DO NOT NEED A BODY."
|
||||
1070 GOTO 1630
|
||||
1080 PRINT "2=NECK"
|
||||
1090 IF Q=1 THEN 1150
|
||||
1100 IF P=0 THEN 1170
|
||||
1110 PRINT "I NOW HAVE A NECK."
|
||||
1120 Q=1
|
||||
1130 C=0
|
||||
1140 GOTO 1630
|
||||
1150 PRINT "I DO NOT NEED A NECK."
|
||||
1160 GOTO 1630
|
||||
1170 PRINT "I DO NOT HAVE A BODY."
|
||||
1180 GOTO 1630
|
||||
1190 PRINT "3=HEAD"
|
||||
1200 IF Q=0 THEN 1260
|
||||
1210 IF R=1 THEN 1280
|
||||
1220 PRINT "I NEEDED A HEAD."
|
||||
1230 R=1
|
||||
1240 C=0
|
||||
1250 GOTO 1630
|
||||
1260 PRINT "I DO NOT HAVE A NECK."
|
||||
1270 GOTO 1630
|
||||
1280 PRINT "I DO NOT NEED A HEAD."
|
||||
1290 GOTO 1630
|
||||
1300 PRINT "4=FEELERS"
|
||||
1310 IF R=0 THEN 1390
|
||||
1320 IF S=2 THEN 1370
|
||||
1330 PRINT "I GET A FEELER."
|
||||
1340 S=S+1
|
||||
1350 C=0
|
||||
1360 GOTO 1630
|
||||
1370 PRINT "I HAVE 2 FEELERS ALREADY."
|
||||
1380 GOTO 1630
|
||||
1390 PRINT "I DO NOT HAVE A HEAD."
|
||||
1400 GOTO 1630
|
||||
1410 PRINT "5=TAIL"
|
||||
1420 IF P=0 THEN 1480
|
||||
1430 IF U=1 THEN 1500
|
||||
1440 PRINT "I NOW HAVE A TAIL."
|
||||
1450 U=1
|
||||
1460 C=0
|
||||
1470 GOTO 1630
|
||||
1480 PRINT "I DO NOT HAVE A BODY."
|
||||
1490 GOTO 1630
|
||||
1500 PRINT "I DO NOT NEED A TAIL."
|
||||
1510 GOTO 1630
|
||||
1520 PRINT "6=LEGS"
|
||||
1530 IF V=6 THEN 1590
|
||||
1540 IF P=0 THEN 1610
|
||||
1550 V=V+1
|
||||
1560 C=0
|
||||
1570 PRINT "I NOW HAVE";V;"LEGS."
|
||||
1580 GOTO 1630
|
||||
1590 PRINT,"I HAVE 6 FEET."
|
||||
1600 GOTO 1630
|
||||
1610 PRINT "I DO NOT HAVE A BODY."
|
||||
1620 GOTO 1630
|
||||
1630 IF A=2 AND T=1 AND L=6 THEN 1650
|
||||
1640 GOTO 1670
|
||||
1650 PRINT "YOUR BUG IS FINISHED."
|
||||
1660 Y=Y+1
|
||||
1670 IF S=2 AND P=1 AND V=6 THEN 1690
|
||||
1680 GOTO 1710
|
||||
1690 PRINT "MY BUG IS FINISHED."
|
||||
1700 Y=Y+2
|
||||
1710 IF C=1 THEN 300
|
||||
1720 PRINT "DO YOU WANT THE PICTURES";
|
||||
1730 INPUT Z$
|
||||
1740 IF Z$="NO" THEN 300
|
||||
1750 PRINT "*****YOUR BUG*****"
|
||||
1760 PRINT
|
||||
1770 PRINT
|
||||
1780 IF A=0 THEN 1860
|
||||
1790 FOR Z=1 TO 4
|
||||
1800 FOR X=1 TO A
|
||||
1810 PRINT TAB(10);
|
||||
1820 PRINT "A ";
|
||||
1830 NEXT X
|
||||
1840 PRINT
|
||||
1850 NEXT Z
|
||||
1860 IF H=0 THEN 1880
|
||||
1870 GOSUB 2470
|
||||
1880 IF N=0 THEN 1920
|
||||
1890 FOR Z=1 TO 2
|
||||
1900 PRINT " N N"
|
||||
1910 NEXT Z
|
||||
1920 IF B=0 THEN 2000
|
||||
1930 PRINT " BBBBBBBBBBBB"
|
||||
1940 FOR Z=1 TO 2
|
||||
1950 PRINT " B B"
|
||||
1960 NEXT Z
|
||||
1970 IF T<>1 THEN 1990
|
||||
1980 PRINT "TTTTTB B"
|
||||
1990 PRINT " BBBBBBBBBBBB"
|
||||
2000 IF L=0 THEN 2080
|
||||
2010 FOR Z=1 TO 2
|
||||
2020 PRINT TAB(5);
|
||||
2030 FOR X=1 TO L
|
||||
2040 PRINT " L";
|
||||
2050 NEXT X
|
||||
2060 PRINT
|
||||
2070 NEXT Z
|
||||
2080 FOR Z=1 TO 4
|
||||
2090 PRINT
|
||||
2100 NEXT Z
|
||||
2110 PRINT "*****MY BUG*****"
|
||||
2120 PRINT
|
||||
2130 PRINT
|
||||
2140 PRINT
|
||||
2150 IF S=0 THEN 2230
|
||||
2160 FOR Z=1 TO 4
|
||||
2170 PRINT TAB(10);
|
||||
2180 FOR X=1 TO S
|
||||
2190 PRINT "F ";
|
||||
2200 NEXT X
|
||||
2210 PRINT
|
||||
2220 NEXT Z
|
||||
2230 IF R<>1 THEN 2250
|
||||
2240 GOSUB 2470
|
||||
2250 IF Q=0 THEN 2280
|
||||
2260 PRINT " N N"
|
||||
2270 PRINT " N N"
|
||||
2280 IF P=0 THEN 2360
|
||||
2290 PRINT " BBBBBBBBBBBB"
|
||||
2300 FOR Z=1 TO 2
|
||||
2310 PRINT " B B"
|
||||
2320 NEXT Z
|
||||
2330 IF U<>1 THEN 2350
|
||||
2340 PRINT "TTTTTB B"
|
||||
2350 PRINT " BBBBBBBBBBBB"
|
||||
2360 IF V=0 THEN 2450
|
||||
2370 FOR Z=1 TO 2
|
||||
2380 PRINT TAB(5);
|
||||
2390 FOR X=1 TO V
|
||||
2400 PRINT " L";
|
||||
2410 NEXT X
|
||||
2420 PRINT
|
||||
2430 NEXT Z
|
||||
2450 IF Y<>0 THEN 2540
|
||||
2460 GOTO 300
|
||||
2470 PRINT " HHHHHHH"
|
||||
2480 PRINT " H H"
|
||||
2490 PRINT " H O O H"
|
||||
2500 PRINT " H H"
|
||||
2510 PRINT " H V H"
|
||||
2520 PRINT " HHHHHHH"
|
||||
2530 RETURN
|
||||
2540 PRINT "I HOPE YOU ENJOYED THE GAME, PLAY IT AGAIN SOON!!"
|
||||
2550 END
|
||||
3
16_Bug/csharp/README.md
Normal file
3
16_Bug/csharp/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Microsoft C#](https://docs.microsoft.com/en-us/dotnet/csharp/)
|
||||
3
16_Bug/java/README.md
Normal file
3
16_Bug/java/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Oracle Java](https://openjdk.java.net/)
|
||||
253
16_Bug/java/src/Bug.java
Normal file
253
16_Bug/java/src/Bug.java
Normal file
@@ -0,0 +1,253 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* Game of Bug
|
||||
* <p>
|
||||
* Based on the Basic game of Bug here
|
||||
* https://github.com/coding-horror/basic-computer-games/blob/main/16%20Bug/bug.bas
|
||||
* <p>
|
||||
* Note: The idea was to create a version of the 1970's Basic game in Java, without introducing
|
||||
* new features - no additional text, error checking, etc has been added.
|
||||
*/
|
||||
public class Bug {
|
||||
|
||||
// Dice roll
|
||||
public static final int SIX = 6;
|
||||
|
||||
private enum GAME_STATE {
|
||||
START,
|
||||
PLAYER_TURN,
|
||||
COMPUTER_TURN,
|
||||
CHECK_FOR_WINNER,
|
||||
GAME_OVER
|
||||
}
|
||||
|
||||
// Used for keyboard input
|
||||
private final Scanner kbScanner;
|
||||
|
||||
// Current game state
|
||||
private GAME_STATE gameState;
|
||||
|
||||
|
||||
private final Insect playersBug;
|
||||
|
||||
private final Insect computersBug;
|
||||
|
||||
// Used to show the result of dice roll.
|
||||
private final String[] ROLLS = new String[]{"BODY", "NECK", "HEAD", "FEELERS", "TAIL", "LEGS"};
|
||||
|
||||
public Bug() {
|
||||
|
||||
playersBug = new PlayerBug();
|
||||
computersBug = new ComputerBug();
|
||||
|
||||
gameState = GAME_STATE.START;
|
||||
|
||||
// Initialise kb scanner
|
||||
kbScanner = new Scanner(System.in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main game loop
|
||||
*/
|
||||
public void play() {
|
||||
|
||||
do {
|
||||
switch (gameState) {
|
||||
|
||||
// Show an introduction the first time the game is played.
|
||||
// And optionally instructions.
|
||||
case START:
|
||||
intro();
|
||||
if (!noEntered(displayTextAndGetInput("DO YOU WANT INSTRUCTIONS? "))) {
|
||||
instructions();
|
||||
}
|
||||
|
||||
gameState = GAME_STATE.PLAYER_TURN;
|
||||
break;
|
||||
|
||||
case PLAYER_TURN:
|
||||
int playersRoll = randomNumber();
|
||||
System.out.println("YOU ROLLED A " + playersRoll + "=" + ROLLS[playersRoll - 1]);
|
||||
switch (playersRoll) {
|
||||
case 1:
|
||||
System.out.println(playersBug.addBody());
|
||||
break;
|
||||
case 2:
|
||||
System.out.println(playersBug.addNeck());
|
||||
break;
|
||||
case 3:
|
||||
System.out.println(playersBug.addHead());
|
||||
break;
|
||||
case 4:
|
||||
System.out.println(playersBug.addFeelers());
|
||||
break;
|
||||
case 5:
|
||||
System.out.println(playersBug.addTail());
|
||||
break;
|
||||
case 6:
|
||||
System.out.println(playersBug.addLeg());
|
||||
break;
|
||||
}
|
||||
|
||||
gameState = GAME_STATE.COMPUTER_TURN;
|
||||
break;
|
||||
|
||||
case COMPUTER_TURN:
|
||||
int computersRoll = randomNumber();
|
||||
System.out.println("I ROLLED A " + computersRoll + "=" + ROLLS[computersRoll - 1]);
|
||||
switch (computersRoll) {
|
||||
case 1:
|
||||
System.out.println(computersBug.addBody());
|
||||
break;
|
||||
case 2:
|
||||
System.out.println(computersBug.addNeck());
|
||||
break;
|
||||
case 3:
|
||||
System.out.println(computersBug.addHead());
|
||||
break;
|
||||
case 4:
|
||||
System.out.println(computersBug.addFeelers());
|
||||
break;
|
||||
case 5:
|
||||
System.out.println(computersBug.addTail());
|
||||
break;
|
||||
case 6:
|
||||
System.out.println(computersBug.addLeg());
|
||||
break;
|
||||
}
|
||||
|
||||
gameState = GAME_STATE.CHECK_FOR_WINNER;
|
||||
break;
|
||||
|
||||
case CHECK_FOR_WINNER:
|
||||
boolean gameOver = false;
|
||||
|
||||
if (playersBug.complete()) {
|
||||
System.out.println("YOUR BUG IS FINISHED.");
|
||||
gameOver = true;
|
||||
} else if (computersBug.complete()) {
|
||||
System.out.println("MY BUG IS FINISHED.");
|
||||
gameOver = true;
|
||||
}
|
||||
|
||||
if (noEntered(displayTextAndGetInput("DO YOU WANT THE PICTURES? "))) {
|
||||
gameState = GAME_STATE.PLAYER_TURN;
|
||||
} else {
|
||||
System.out.println("*****YOUR BUG*****");
|
||||
System.out.println();
|
||||
draw(playersBug);
|
||||
|
||||
System.out.println();
|
||||
System.out.println("*****MY BUG*****");
|
||||
System.out.println();
|
||||
draw(computersBug);
|
||||
gameState = GAME_STATE.PLAYER_TURN;
|
||||
}
|
||||
if (gameOver) {
|
||||
System.out.println("I HOPE YOU ENJOYED THE GAME, PLAY IT AGAIN SOON!!");
|
||||
gameState = GAME_STATE.GAME_OVER;
|
||||
}
|
||||
}
|
||||
} while (gameState != GAME_STATE.GAME_OVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the bug (player or computer) based on what has
|
||||
* already been added to it.
|
||||
*
|
||||
* @param bug The bug to be drawn.
|
||||
*/
|
||||
private void draw(Insect bug) {
|
||||
ArrayList<String> insectOutput = bug.draw();
|
||||
for (String s : insectOutput) {
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display an intro
|
||||
*/
|
||||
private void intro() {
|
||||
System.out.println("BUG");
|
||||
System.out.println("CREATIVE COMPUTING MORRISTOWN, NEW JERSEY");
|
||||
System.out.println();
|
||||
System.out.println("THE GAME BUG");
|
||||
System.out.println("I HOPE YOU ENJOY THIS GAME.");
|
||||
}
|
||||
|
||||
private void instructions() {
|
||||
System.out.println("THE OBJECT OF BUG IS TO FINISH YOUR BUG BEFORE I FINISH");
|
||||
System.out.println("MINE. EACH NUMBER STANDS FOR A PART OF THE BUG BODY.");
|
||||
System.out.println("I WILL ROLL THE DIE FOR YOU, TELL YOU WHAT I ROLLED FOR YOU");
|
||||
System.out.println("WHAT THE NUMBER STANDS FOR, AND IF YOU CAN GET THE PART.");
|
||||
System.out.println("IF YOU CAN GET THE PART I WILL GIVE IT TO YOU.");
|
||||
System.out.println("THE SAME WILL HAPPEN ON MY TURN.");
|
||||
System.out.println("IF THERE IS A CHANGE IN EITHER BUG I WILL GIVE YOU THE");
|
||||
System.out.println("OPTION OF SEEING THE PICTURES OF THE BUGS.");
|
||||
System.out.println("THE NUMBERS STAND FOR PARTS AS FOLLOWS:");
|
||||
System.out.println("NUMBER\tPART\tNUMBER OF PART NEEDED");
|
||||
System.out.println("1\tBODY\t1");
|
||||
System.out.println("2\tNECK\t1");
|
||||
System.out.println("3\tHEAD\t1");
|
||||
System.out.println("4\tFEELERS\t2");
|
||||
System.out.println("5\tTAIL\t1");
|
||||
System.out.println("6\tLEGS\t6");
|
||||
System.out.println();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether player entered N or NO to a question.
|
||||
*
|
||||
* @param text player string from kb
|
||||
* @return true if N or NO was entered, otherwise false
|
||||
*/
|
||||
private boolean noEntered(String text) {
|
||||
return stringIsAnyValue(text, "N", "NO");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a string equals one of a variable number of values
|
||||
* Useful to check for Y or YES for example
|
||||
* Comparison is case insensitive.
|
||||
*
|
||||
* @param text source string
|
||||
* @param values a range of values to compare against the source string
|
||||
* @return true if a comparison was found in one of the variable number of strings passed
|
||||
*/
|
||||
private boolean stringIsAnyValue(String text, String... values) {
|
||||
|
||||
// Cycle through the variable number of values and test each
|
||||
for (String val : values) {
|
||||
if (text.equalsIgnoreCase(val)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// no matches
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a message on the screen, then accept input from Keyboard.
|
||||
*
|
||||
* @param text message to be displayed on screen.
|
||||
* @return what was typed by the player.
|
||||
*/
|
||||
private String displayTextAndGetInput(String text) {
|
||||
System.out.print(text);
|
||||
return kbScanner.next();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate random number
|
||||
*
|
||||
* @return random number
|
||||
*/
|
||||
private int randomNumber() {
|
||||
return (int) (Math.random()
|
||||
* (SIX) + 1);
|
||||
}
|
||||
}
|
||||
10
16_Bug/java/src/BugGame.java
Normal file
10
16_Bug/java/src/BugGame.java
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
|
||||
public class BugGame {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Bug bug = new Bug();
|
||||
bug.play();
|
||||
}
|
||||
}
|
||||
15
16_Bug/java/src/ComputerBug.java
Normal file
15
16_Bug/java/src/ComputerBug.java
Normal file
@@ -0,0 +1,15 @@
|
||||
public class ComputerBug extends Insect {
|
||||
|
||||
// Create messages specific to the computer player.
|
||||
|
||||
public ComputerBug() {
|
||||
// Call superclass constructor for initialization.
|
||||
super();
|
||||
addMessages(new String[]{"I GET A FEELER.", "I HAVE " + MAX_FEELERS + " FEELERS ALREADY.", "I DO NOT HAVE A HEAD."}, PARTS.FEELERS);
|
||||
addMessages(new String[]{"I NEEDED A HEAD.", "I DO NOT NEED A HEAD.", "I DO NOT HAVE A NECK."}, PARTS.HEAD);
|
||||
addMessages(new String[]{"I NOW HAVE A NECK.", "I DO NOT NEED A NECK.", "I DO NOT HAVE A BODY."}, PARTS.NECK);
|
||||
addMessages(new String[]{"I NOW HAVE A BODY.", "I DO NOT NEED A BODY."}, PARTS.BODY);
|
||||
addMessages(new String[]{"I NOW HAVE A TAIL.", "I DO NOT NEED A TAIL.", "I DO NOT HAVE A BODY."}, PARTS.TAIL);
|
||||
addMessages(new String[]{"I NOW HAVE ^^^" + " LEG", "I HAVE " + MAX_LEGS + " FEET.", "I DO NOT HAVE A BODY."}, PARTS.LEGS);
|
||||
}
|
||||
}
|
||||
363
16_Bug/java/src/Insect.java
Normal file
363
16_Bug/java/src/Insect.java
Normal file
@@ -0,0 +1,363 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This tracks the insect (bug) and has methods to
|
||||
* add body parts, create an array of output so it
|
||||
* can be drawn and to determine if a bug is complete.
|
||||
* N.B. This is a super class for ComputerBug and PlayerBug
|
||||
*/
|
||||
public class Insect {
|
||||
|
||||
public static final int MAX_FEELERS = 2;
|
||||
public static final int MAX_LEGS = 6;
|
||||
|
||||
public static final int ADDED = 0;
|
||||
public static final int NOT_ADDED = 1;
|
||||
public static final int MISSING = 2;
|
||||
|
||||
// Various parts of the bug
|
||||
public enum PARTS {
|
||||
FEELERS,
|
||||
HEAD,
|
||||
NECK,
|
||||
BODY,
|
||||
TAIL,
|
||||
LEGS
|
||||
}
|
||||
|
||||
// Tracks what parts of the bug have been added
|
||||
private boolean body;
|
||||
private boolean neck;
|
||||
private boolean head;
|
||||
private int feelers;
|
||||
private boolean tail;
|
||||
private int legs;
|
||||
|
||||
// Messages about for various body parts
|
||||
// These are set in the subclass ComputerBug or PlayerBug
|
||||
private String[] bodyMessages;
|
||||
private String[] neckMessages;
|
||||
private String[] headMessages;
|
||||
private String[] feelerMessages;
|
||||
private String[] tailMessages;
|
||||
private String[] legMessages;
|
||||
|
||||
public Insect() {
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a body to the bug if there is not one already added.
|
||||
*
|
||||
* @return return an appropriate message about the status of the operation.
|
||||
*/
|
||||
public String addBody() {
|
||||
|
||||
boolean currentState = false;
|
||||
|
||||
if (!body) {
|
||||
body = true;
|
||||
currentState = true;
|
||||
}
|
||||
|
||||
return addBodyMessage(currentState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create output based on adding the body or it being already added previously
|
||||
*
|
||||
* @return contains the output message
|
||||
*/
|
||||
|
||||
private String addBodyMessage(boolean wasAdded) {
|
||||
|
||||
// Return the appropriate message depending on whether the
|
||||
// body was added or not.
|
||||
if (wasAdded) {
|
||||
return bodyMessages[ADDED];
|
||||
} else {
|
||||
return bodyMessages[NOT_ADDED];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a neck if a) a body has previously been added and
|
||||
* b) a neck has not previously been added.
|
||||
*
|
||||
* @return text containing the status of the operation
|
||||
*/
|
||||
public String addNeck() {
|
||||
|
||||
int status = NOT_ADDED; // Default is not added
|
||||
|
||||
if (!body) {
|
||||
// No body, cannot add a neck
|
||||
status = MISSING;
|
||||
} else if (!neck) {
|
||||
neck = true;
|
||||
status = ADDED;
|
||||
}
|
||||
|
||||
return neckMessages[status];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a head to the bug if a) there already exists a neck and
|
||||
* b) a head has not previously been added
|
||||
*
|
||||
* @return text outlining the success of the operation
|
||||
*/
|
||||
public String addHead() {
|
||||
|
||||
int status = NOT_ADDED; // Default is not added
|
||||
|
||||
if (!neck) {
|
||||
// No neck, cannot add a head
|
||||
status = MISSING;
|
||||
} else if (!head) {
|
||||
head = true;
|
||||
status = ADDED;
|
||||
}
|
||||
|
||||
return headMessages[status];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a feeler to the head if a) there has been a head added to
|
||||
* the bug previously, and b) there are not already 2 (MAX_FEELERS)
|
||||
* feelers previously added to the bug.
|
||||
*
|
||||
* @return text outlining the status of the operation
|
||||
*/
|
||||
public String addFeelers() {
|
||||
|
||||
int status = NOT_ADDED; // Default is not added
|
||||
|
||||
if (!head) {
|
||||
// No head, cannot add a feeler
|
||||
status = MISSING;
|
||||
} else if (feelers < MAX_FEELERS) {
|
||||
feelers++;
|
||||
status = ADDED;
|
||||
}
|
||||
|
||||
return feelerMessages[status];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a tail to the bug if a) there is already a body previously added
|
||||
* to the bug and b) there is not already a tail added.
|
||||
*
|
||||
* @return text outlining the status of the operation.
|
||||
*/
|
||||
public String addTail() {
|
||||
|
||||
int status = NOT_ADDED; // Default is not added
|
||||
|
||||
if (!body) {
|
||||
// No body, cannot add a tail
|
||||
status = MISSING;
|
||||
} else if (!tail) {
|
||||
tail = true;
|
||||
status = ADDED;
|
||||
}
|
||||
|
||||
return tailMessages[status];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a leg to the bug if a) there is already a body previously added
|
||||
* b) there are less than 6 (MAX_LEGS) previously added.
|
||||
*
|
||||
* @return text outlining status of the operation.
|
||||
*/
|
||||
public String addLeg() {
|
||||
|
||||
int status = NOT_ADDED; // Default is not added
|
||||
|
||||
if (!body) {
|
||||
// No body, cannot add a leg
|
||||
status = MISSING;
|
||||
} else if (legs < MAX_LEGS) {
|
||||
legs++;
|
||||
status = ADDED;
|
||||
}
|
||||
|
||||
String message = "";
|
||||
|
||||
// Create a string showing the result of the operation
|
||||
|
||||
switch(status) {
|
||||
case ADDED:
|
||||
// Replace # with number of legs
|
||||
message = legMessages[status].replace("^^^", String.valueOf(legs));
|
||||
// Add text S. if >1 leg, or just . if one leg.
|
||||
if (legs > 1) {
|
||||
message += "S.";
|
||||
} else {
|
||||
message += ".";
|
||||
}
|
||||
break;
|
||||
|
||||
case NOT_ADDED:
|
||||
|
||||
// Deliberate fall through to next case as its the
|
||||
// same code to be executed
|
||||
case MISSING:
|
||||
message = legMessages[status];
|
||||
break;
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise
|
||||
*/
|
||||
public void init() {
|
||||
body = false;
|
||||
neck = false;
|
||||
head = false;
|
||||
feelers = 0;
|
||||
tail = false;
|
||||
legs = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add unique messages depending on type of player
|
||||
* A subclass of this class calls this method
|
||||
* e.g. See ComputerBug or PlayerBug classes
|
||||
*
|
||||
* @param messages an array of messages
|
||||
* @param bodyPart the bodypart the messages relate to.
|
||||
*/
|
||||
public void addMessages(String[] messages, PARTS bodyPart) {
|
||||
|
||||
switch (bodyPart) {
|
||||
case FEELERS:
|
||||
feelerMessages = messages;
|
||||
break;
|
||||
|
||||
case HEAD:
|
||||
headMessages = messages;
|
||||
break;
|
||||
|
||||
case NECK:
|
||||
neckMessages = messages;
|
||||
break;
|
||||
|
||||
case BODY:
|
||||
bodyMessages = messages;
|
||||
break;
|
||||
|
||||
case TAIL:
|
||||
tailMessages = messages;
|
||||
break;
|
||||
|
||||
case LEGS:
|
||||
legMessages = messages;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string array containing
|
||||
* the "bug" that can be output to console
|
||||
*
|
||||
* @return the bug ready to draw
|
||||
*/
|
||||
public ArrayList<String> draw() {
|
||||
ArrayList<String> bug = new ArrayList<>();
|
||||
StringBuilder lineOutput;
|
||||
|
||||
// Feelers
|
||||
if (feelers > 0) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
lineOutput = new StringBuilder(addSpaces(10));
|
||||
for (int j = 0; j < feelers; j++) {
|
||||
lineOutput.append("A ");
|
||||
}
|
||||
bug.add(lineOutput.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (head) {
|
||||
lineOutput = new StringBuilder(addSpaces(8) + "HHHHHHH");
|
||||
bug.add(lineOutput.toString());
|
||||
lineOutput = new StringBuilder(addSpaces(8) + "H" + addSpaces(5) + "H");
|
||||
bug.add(lineOutput.toString());
|
||||
lineOutput = new StringBuilder(addSpaces(8) + "H O O H");
|
||||
bug.add(lineOutput.toString());
|
||||
lineOutput = new StringBuilder(addSpaces(8) + "H" + addSpaces(5) + "H");
|
||||
bug.add(lineOutput.toString());
|
||||
lineOutput = new StringBuilder(addSpaces(8) + "H" + addSpaces(2) + "V" + addSpaces(2) + "H");
|
||||
bug.add(lineOutput.toString());
|
||||
lineOutput = new StringBuilder(addSpaces(8) + "HHHHHHH");
|
||||
bug.add(lineOutput.toString());
|
||||
}
|
||||
|
||||
if (neck) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
lineOutput = new StringBuilder(addSpaces(10) + "N N");
|
||||
bug.add(lineOutput.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (body) {
|
||||
lineOutput = new StringBuilder(addSpaces(5) + "BBBBBBBBBBBB");
|
||||
bug.add(lineOutput.toString());
|
||||
for (int i = 0; i < 2; i++) {
|
||||
lineOutput = new StringBuilder(addSpaces(5) + "B" + addSpaces(10) + "B");
|
||||
bug.add(lineOutput.toString());
|
||||
}
|
||||
if (tail) {
|
||||
lineOutput = new StringBuilder("TTTTTB" + addSpaces(10) + "B");
|
||||
bug.add(lineOutput.toString());
|
||||
}
|
||||
lineOutput = new StringBuilder(addSpaces(5) + "BBBBBBBBBBBB");
|
||||
bug.add(lineOutput.toString());
|
||||
}
|
||||
|
||||
if (legs > 0) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
lineOutput = new StringBuilder(addSpaces(5));
|
||||
for (int j = 0; j < legs; j++) {
|
||||
lineOutput.append(" L");
|
||||
}
|
||||
bug.add(lineOutput.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return bug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the bug is complete i.e. it has
|
||||
* 2 (MAX_FEELERS) feelers, a head, a neck, a body
|
||||
* a tail and 6 (MAX_FEET) feet.
|
||||
*
|
||||
* @return true if complete.
|
||||
*/
|
||||
public boolean complete() {
|
||||
return (feelers == MAX_FEELERS)
|
||||
&& head
|
||||
&& neck
|
||||
&& body
|
||||
&& tail
|
||||
&& (legs == MAX_LEGS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulate tabs be creating a string of X spaces.
|
||||
*
|
||||
* @param number contains number of spaces needed.
|
||||
* @return a String containing the spaces
|
||||
*/
|
||||
private String addSpaces(int number) {
|
||||
char[] spaces = new char[number];
|
||||
Arrays.fill(spaces, ' ');
|
||||
return new String(spaces);
|
||||
|
||||
}
|
||||
}
|
||||
18
16_Bug/java/src/PlayerBug.java
Normal file
18
16_Bug/java/src/PlayerBug.java
Normal file
@@ -0,0 +1,18 @@
|
||||
public class PlayerBug extends Insect {
|
||||
|
||||
// Create messages specific to the player.
|
||||
|
||||
public PlayerBug() {
|
||||
// Call superclass constructor for initialization.
|
||||
super();
|
||||
addMessages(new String[]{"I NOW GIVE YOU A FEELER.", "YOU HAVE " + MAX_FEELERS + " FEELERS ALREADY.", "YOU DO NOT HAVE A HEAD."}, PARTS.FEELERS);
|
||||
addMessages(new String[]{"YOU NEEDED A HEAD.", "YOU HAVE A HEAD.", "YOU DO NOT HAVE A NECK."}, PARTS.HEAD);
|
||||
addMessages(new String[]{"YOU NOW HAVE A NECK.", "YOU DO NOT NEED A NECK.", "YOU DO NOT HAVE A BODY."}, PARTS.NECK);
|
||||
addMessages(new String[]{"YOU NOW HAVE A BODY.", "YOU DO NOT NEED A BODY."}, PARTS.BODY);
|
||||
addMessages(new String[]{"I NOW GIVE YOU A TAIL.", "YOU ALREADY HAVE A TAIL.", "YOU DO NOT HAVE A BODY."}, PARTS.TAIL);
|
||||
addMessages(new String[]{"YOU NOW HAVE ^^^ LEG", "YOU HAVE " + MAX_LEGS + " FEET ALREADY.", "YOU DO NOT HAVE A BODY."}, PARTS.LEGS);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
3
16_Bug/javascript/README.md
Normal file
3
16_Bug/javascript/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Shells)
|
||||
9
16_Bug/javascript/bug.html
Normal file
9
16_Bug/javascript/bug.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>BUG</title>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="output" style="font-size: 12pt;"></pre>
|
||||
<script src="bug.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
347
16_Bug/javascript/bug.js
Normal file
347
16_Bug/javascript/bug.js
Normal file
@@ -0,0 +1,347 @@
|
||||
// BUG
|
||||
//
|
||||
// Converted from BASIC to Javascript by Oscar Toledo G. (nanochess)
|
||||
//
|
||||
|
||||
function print(str)
|
||||
{
|
||||
document.getElementById("output").appendChild(document.createTextNode(str));
|
||||
}
|
||||
|
||||
function input()
|
||||
{
|
||||
var input_element;
|
||||
var input_str;
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
input_element = document.createElement("INPUT");
|
||||
|
||||
print("? ");
|
||||
input_element.setAttribute("type", "text");
|
||||
input_element.setAttribute("length", "50");
|
||||
document.getElementById("output").appendChild(input_element);
|
||||
input_element.focus();
|
||||
input_str = undefined;
|
||||
input_element.addEventListener("keydown", function (event) {
|
||||
if (event.keyCode == 13) {
|
||||
input_str = input_element.value;
|
||||
document.getElementById("output").removeChild(input_element);
|
||||
print(input_str);
|
||||
print("\n");
|
||||
resolve(input_str);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function tab(space)
|
||||
{
|
||||
var str = "";
|
||||
while (space-- > 0)
|
||||
str += " ";
|
||||
return str;
|
||||
}
|
||||
|
||||
function draw_head()
|
||||
{
|
||||
print(" HHHHHHH\n");
|
||||
print(" H H\n");
|
||||
print(" H O O H\n");
|
||||
print(" H H\n");
|
||||
print(" H V H\n");
|
||||
print(" HHHHHHH\n");
|
||||
}
|
||||
|
||||
// Main program
|
||||
async function main()
|
||||
{
|
||||
print(tab(34) + "BUG\n");
|
||||
print(tab(15) + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
a = 0;
|
||||
b = 0;
|
||||
h = 0;
|
||||
l = 0;
|
||||
n = 0;
|
||||
p = 0;
|
||||
q = 0;
|
||||
r = 0;
|
||||
s = 0;
|
||||
t = 0;
|
||||
u = 0;
|
||||
v = 0;
|
||||
y = 0;
|
||||
print("THE GAME BUG\n");
|
||||
print("I HOPE YOU ENJOY THIS GAME.\n");
|
||||
print("\n");
|
||||
print("DO YOU WANT INSTRUCTIONS");
|
||||
str = await input();
|
||||
if (str != "NO") {
|
||||
print("THE OBJECT OF BUG IS TO FINISH YOUR BUG BEFORE I FINISH\n");
|
||||
print("MINE. EACH NUMBER STANDS FOR A PART OF THE BUG BODY.\n");
|
||||
print("I WILL ROLL THE DIE FOR YOU, TELL YOU WHAT I ROLLED FOR YOU\n");
|
||||
print("WHAT THE NUMBER STANDS FOR, AND IF YOU CAN GET THE PART.\n");
|
||||
print("IF YOU CAN GET THE PART I WILL GIVE IT TO YOU.\n");
|
||||
print("THE SAME WILL HAPPEN ON MY TURN.\n");
|
||||
print("IF THERE IS A CHANGE IN EITHER BUG I WILL GIVE YOU THE\n");
|
||||
print("OPTION OF SEEING THE PICTURES OF THE BUGS.\n");
|
||||
print("THE NUMBERS STAND FOR PARTS AS FOLLOWS:\n");
|
||||
print("NUMBER\tPART\tNUMBER OF PART NEEDED\n");
|
||||
print("1\tBODY\t1\n");
|
||||
print("2\tNECK\t1\n");
|
||||
print("3\tHEAD\t1\n");
|
||||
print("4\tFEELERS\t2\n");
|
||||
print("5\tTAIL\t1\n");
|
||||
print("6\tLEGS\t6\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
}
|
||||
while (y == 0) {
|
||||
z = Math.floor(6 * Math.random() + 1);
|
||||
c = 1;
|
||||
print("YOU ROLLED A " + z + "\n");
|
||||
switch (z) {
|
||||
case 1:
|
||||
print("1=BODY\n");
|
||||
if (b == 0) {
|
||||
print("YOU NOW HAVE A BODY.\n");
|
||||
b = 1;
|
||||
c = 0;
|
||||
} else {
|
||||
print("YOU DO NOT NEED A BODY.\n");
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
print("2=NECK\n");
|
||||
if (n == 0) {
|
||||
if (b == 0) {
|
||||
print("YOU DO NOT HAVE A BODY.\n");
|
||||
} else {
|
||||
print("YOU NOW HAVE A NECK.\n");
|
||||
n = 1;
|
||||
c = 0;
|
||||
}
|
||||
} else {
|
||||
print("YOU DO NOT NEED A NECK.\n");
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
print("3=HEAD\n");
|
||||
if (n == 0) {
|
||||
print("YOU DO NOT HAVE A NECK.\n");
|
||||
} else if (h == 0) {
|
||||
print("YOU NEEDED A HEAD.\n");
|
||||
h = 1;
|
||||
c = 0;
|
||||
} else {
|
||||
print("YOU HAVE A HEAD.\n");
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
print("4=FEELERS\n");
|
||||
if (h == 0) {
|
||||
print("YOU DO NOT HAVE A HEAD.\n");
|
||||
} else if (a == 2) {
|
||||
print("YOU HAVE TWO FEELERS ALREADY.\n");
|
||||
} else {
|
||||
print("I NOW GIVE YOU A FEELER.\n");
|
||||
a++;
|
||||
c = 0;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
print("5=TAIL\n");
|
||||
if (b == 0) {
|
||||
print("YOU DO NOT HAVE A BODY.\n");
|
||||
} else if (t == 1) {
|
||||
print("YOU ALREADY HAVE A TAIL.\n");
|
||||
} else {
|
||||
print("I NOW GIVE YOU A TAIL.\n");
|
||||
t++;
|
||||
c = 0;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
print("6=LEG\n");
|
||||
if (l == 6) {
|
||||
print("YOU HAVE 6 FEET ALREADY.\n");
|
||||
} else if (b == 0) {
|
||||
print("YOU DO NOT HAVE A BODY.\n");
|
||||
} else {
|
||||
l++;
|
||||
c = 0;
|
||||
print("YOU NOW HAVE " + l + " LEGS.\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
x = Math.floor(6 * Math.random() + 1) ;
|
||||
print("\n");
|
||||
date = new Date().valueOf;
|
||||
while (date - new Date().valueOf < 1000000) ;
|
||||
print("I ROLLED A " + x + "\n");
|
||||
switch (x) {
|
||||
case 1:
|
||||
print("1=BODY\n");
|
||||
if (p == 1) {
|
||||
print("I DO NOT NEED A BODY.\n");
|
||||
} else {
|
||||
print("I NOW HAVE A BODY.\n");
|
||||
c = 0;
|
||||
p = 1;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
print("2=NECK\n");
|
||||
if (q == 1) {
|
||||
print("I DO NOT NEED A NECK.\n");
|
||||
} else if (p == 0) {
|
||||
print("I DO NOT HAVE A BODY.\n");
|
||||
} else {
|
||||
print("I NOW HAVE A NECK.\n");
|
||||
q = 1;
|
||||
c = 0;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
print("3=HEAD\n");
|
||||
if (q == 0) {
|
||||
print("I DO NOT HAVE A NECK.\n");
|
||||
} else if (r == 1) {
|
||||
print("I DO NOT NEED A HEAD.\n");
|
||||
} else {
|
||||
print("I NEEDED A HEAD.\n");
|
||||
r = 1;
|
||||
c = 0;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
print("4=FEELERS\n");
|
||||
if (r == 0) {
|
||||
print("I DO NOT HAVE A HEAD.\n");
|
||||
} else if (s == 2) {
|
||||
print("I HAVE 2 FEELERS ALREADY.\n");
|
||||
} else {
|
||||
print("I GET A FEELER.\n");
|
||||
s++;
|
||||
c = 0;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
print("5=TAIL\n");
|
||||
if (p == 0) {
|
||||
print("I DO NOT HAVE A BODY.\n");
|
||||
} else if (u == 1) {
|
||||
print("I DO NOT NEED A TAIL.\n");
|
||||
} else {
|
||||
print("I NOW HAVE A TAIL.\n");
|
||||
u = 1;
|
||||
c = 0;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
print("6=LEGS\n");
|
||||
if (v == 6) {
|
||||
print("I HAVE 6 FEET.\n");
|
||||
} else if (p == 0) {
|
||||
print("I DO NOT HAVE A BODY.\n");
|
||||
} else {
|
||||
v++;
|
||||
c = 0;
|
||||
print("I NOW HAVE " + v + " LEGS.\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (a == 2 && t == 1 && l == 6) {
|
||||
print("YOUR BUG IS FINISHED.\n");
|
||||
y++;
|
||||
}
|
||||
if (s == 2 && p == 1 && v == 6) {
|
||||
print("MY BUG IS FINISHED.\n");
|
||||
y += 2;
|
||||
}
|
||||
if (c == 1)
|
||||
continue;
|
||||
print("DO YOU WANT THE PICTURES");
|
||||
str = await input();
|
||||
if (str == "NO")
|
||||
continue;
|
||||
print("*****YOUR BUG*****\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
if (a != 0) {
|
||||
for (z = 1; z <= 4; z++) {
|
||||
print(tab(10));
|
||||
for (x = 1; x <= a; x++) {
|
||||
print("A ");
|
||||
}
|
||||
print("\n");
|
||||
}
|
||||
}
|
||||
if (h != 0)
|
||||
draw_head();
|
||||
if (n != 0) {
|
||||
for (z = 1; z <= 2; z++)
|
||||
print(" N N\n");
|
||||
}
|
||||
if (b != 0) {
|
||||
print(" BBBBBBBBBBBB\n");
|
||||
for (z = 1; z <= 2; z++)
|
||||
print(" B B\n");
|
||||
if (t == 1)
|
||||
print("TTTTTB B\n");
|
||||
print(" BBBBBBBBBBBB\n");
|
||||
}
|
||||
if (l != 0) {
|
||||
for (z = 1; z <= 2; z++) {
|
||||
print(tab(5));
|
||||
for (x = 1; x <= l; x++)
|
||||
print(" L");
|
||||
print("\n");
|
||||
}
|
||||
}
|
||||
for (z = 1; z <= 4; z++)
|
||||
print("\n");
|
||||
print("*****MY BUG*****\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
if (s != 0) {
|
||||
for (z = 1; z <= 4; z++) {
|
||||
print(tab(10));
|
||||
for (x = 1; x <= s; x++) {
|
||||
print("F ");
|
||||
}
|
||||
print("\n");
|
||||
}
|
||||
}
|
||||
if (r != 0)
|
||||
draw_head();
|
||||
if (q != 0) {
|
||||
for (z = 1; z <= 2; z++)
|
||||
print(" N N\n");
|
||||
}
|
||||
if (p != 0) {
|
||||
print(" BBBBBBBBBBBB\n");
|
||||
for (z = 1; z <= 2; z++)
|
||||
print(" B B\n");
|
||||
if (u == 1)
|
||||
print("TTTTTB B\n");
|
||||
print(" BBBBBBBBBBBB\n");
|
||||
}
|
||||
if (v != 0) {
|
||||
for (z = 1; z <= 2; z++) {
|
||||
print(tab(5));
|
||||
for (x = 1; x <= v; x++)
|
||||
print(" L");
|
||||
print("\n");
|
||||
}
|
||||
}
|
||||
for (z = 1; z <= 4; z++)
|
||||
print("\n");
|
||||
}
|
||||
print("I HOPE YOU ENJOYED THE GAME, PLAY IT AGAIN SOON!!\n");
|
||||
}
|
||||
|
||||
main();
|
||||
3
16_Bug/pascal/README.md
Normal file
3
16_Bug/pascal/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language))
|
||||
3
16_Bug/perl/README.md
Normal file
3
16_Bug/perl/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Perl](https://www.perl.org/)
|
||||
3
16_Bug/python/README.md
Normal file
3
16_Bug/python/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Python](https://www.python.org/about/)
|
||||
3
16_Bug/ruby/README.md
Normal file
3
16_Bug/ruby/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Ruby](https://www.ruby-lang.org/en/)
|
||||
3
16_Bug/vbnet/README.md
Normal file
3
16_Bug/vbnet/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original BASIC source [downloaded from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Visual Basic .NET](https://en.wikipedia.org/wiki/Visual_Basic_.NET)
|
||||
Reference in New Issue
Block a user