mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-07 19:02:37 -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
39_Golf/README.md
Normal file
7
39_Golf/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
### Golf
|
||||
|
||||
As published in Basic Computer Games (1978)
|
||||
https://www.atariarchives.org/basicgames/showpage.php?page=71
|
||||
|
||||
Downloaded from Vintage Basic at
|
||||
http://www.vintage-basic.net/games.html
|
||||
1142
39_Golf/csharp/Program.cs
Normal file
1142
39_Golf/csharp/Program.cs
Normal file
File diff suppressed because it is too large
Load Diff
15
39_Golf/csharp/README.md
Normal file
15
39_Golf/csharp/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
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/)
|
||||
|
||||
There are 2 compiled executables in the compiled/ directory (windows and linux) that you can play right away!
|
||||
|
||||
Program.cs contains the C# source code.
|
||||
It has been written for .NET Core 3.1
|
||||
|
||||
The source code is well documented.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
244
39_Golf/golf.bas
Normal file
244
39_Golf/golf.bas
Normal file
@@ -0,0 +1,244 @@
|
||||
1 PRINT TAB(34);"GOLF"
|
||||
2 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||
3 PRINT:PRINT:PRINT
|
||||
4 PRINT "WELCOME TO THE CREATIVE COMPUTING COUNTRY CLUB,"
|
||||
5 PRINT "AN EIGHTEEN HOLE CHAMPIONSHIP LAYOUT LOCATED A SHORT"
|
||||
6 PRINT "DISTANCE FROM SCENIC DOWNTOWN MORRISTOWN. THE"
|
||||
7 PRINT "COMMENTATOR WILL EXPLAIN THE GAME AS YOU PLAY."
|
||||
8 PRINT "ENJOY YOUR GAME; SEE YOU AT THE 19TH HOLE..."
|
||||
9 PRINT:PRINT: DIM L(10)
|
||||
10 G1=18
|
||||
20 G2=0
|
||||
30 G3=0
|
||||
40 A=0
|
||||
50 N=.8
|
||||
60 S2=0
|
||||
70 F=1
|
||||
80 PRINT "WHAT IS YOUR HANDICAP";
|
||||
90 INPUT H:PRINT
|
||||
100 IF H>30 THEN 470
|
||||
110 IF H<0 THEN 470
|
||||
120 PRINT "DIFFICULTIES AT GOLF INCLUDE:"
|
||||
130 PRINT "0=HOOK, 1=SLICE, 2=POOR DISTANCE, 4=TRAP SHOTS, 5=PUTTING"
|
||||
140 PRINT "WHICH ONE (ONLY ONE) IS YOUR WORST";
|
||||
150 INPUT T:PRINT
|
||||
160 IF T>5 THEN 120
|
||||
170 S1=0
|
||||
210 REM
|
||||
230 L(0)=0
|
||||
240 J=0
|
||||
245 Q=0
|
||||
250 S2=S2+1
|
||||
260 K=0
|
||||
270 IF F=1 THEN 310
|
||||
290 PRINT "YOUR SCORE ON HOLE";F-1;"WAS";S1
|
||||
291 GOTO 1750
|
||||
292 IF S1>P+2 THEN 297
|
||||
293 IF S1=P THEN 299
|
||||
294 IF S1=P-1 THEN 301
|
||||
295 IF S1=P-2 THEN 303
|
||||
296 GOTO 310
|
||||
297 PRINT "KEEP YOUR HEAD DOWN."
|
||||
298 GOTO 310
|
||||
299 PRINT "A PAR. NICE GOING."
|
||||
300 GOTO 310
|
||||
301 PRINT "A BIRDIE."
|
||||
302 GOTO 310
|
||||
303 IF P=3 THEN 306
|
||||
304 PRINT "A GREAT BIG EAGLE."
|
||||
305 GOTO 310
|
||||
306 PRINT "A HOLE IN ONE."
|
||||
310 IF F=19 THEN 1710
|
||||
315 S1=0
|
||||
316 PRINT
|
||||
320 IF S1=0 THEN 1590
|
||||
330 IF L(0)<1 THEN 1150
|
||||
340 X=0
|
||||
350 IF L(0)>5 THEN 1190
|
||||
360 PRINT "SHOT WENT";D1;"YARDS. IT'S";D2;"YARDS FROM THE CUP."
|
||||
362 PRINT "BALL IS";INT(O);"YARDS OFF LINE... IN ";
|
||||
380 GOSUB 400
|
||||
390 GOTO 620
|
||||
400 IF L(X)=1 THEN 480
|
||||
410 IF L(X)=2 THEN 500
|
||||
420 IF L(X)=3 THEN 520
|
||||
430 IF L(X)=4 THEN 540
|
||||
440 IF L(X)=5 THEN 560
|
||||
450 IF L(X)=6 THEN 580
|
||||
460 PRINT "OUT OF BOUNDS."
|
||||
465 GOTO 1690
|
||||
470 PRINT "PGA HANDICAPS RANGE FROM 0 TO 30."
|
||||
472 GOTO 80
|
||||
480 PRINT "FAIRWAY."
|
||||
490 GOTO 1690
|
||||
500 PRINT "ROUGH."
|
||||
510 GOTO 1690
|
||||
520 PRINT "TREES."
|
||||
530 GOTO 1690
|
||||
540 PRINT "ADJACENT FAIRWAY."
|
||||
550 GOTO 1690
|
||||
560 PRINT "TRAP."
|
||||
570 GOTO 1690
|
||||
580 PRINT "WATER."
|
||||
590 GOTO 1690
|
||||
620 IF A=1 THEN 629
|
||||
621 PRINT "SELECTION OF CLUBS"
|
||||
622 PRINT "YARDAGE DESIRED SUGGESTED CLUBS"
|
||||
623 PRINT "200 TO 280 YARDS 1 TO 4"
|
||||
624 PRINT "100 TO 200 YARDS 19 TO 13"
|
||||
625 PRINT " 0 TO 100 YARDS 29 TO 23"
|
||||
626 A=1
|
||||
629 PRINT "WHAT CLUB DO YOU CHOOSE";
|
||||
630 INPUT C
|
||||
632 PRINT
|
||||
635 IF C<1 THEN 690
|
||||
637 IF C>29 THEN 690
|
||||
640 IF C>4 THEN 710
|
||||
650 IF L(0)<=5 THEN 740
|
||||
660 IF C=14 THEN 740
|
||||
665 IF C=23 THEN 740
|
||||
670 GOTO 690
|
||||
680 S1=S1-1
|
||||
690 PRINT "THAT CLUB IS NOT IN THE BAG."
|
||||
693 PRINT
|
||||
700 GOTO 620
|
||||
710 IF C<12 THEN 690
|
||||
720 C=C-6
|
||||
730 GOTO 650
|
||||
740 S1=S1+1
|
||||
741 W=1
|
||||
742 IF C>13 THEN 960
|
||||
746 IF INT(F/3)=F/3 THEN 952
|
||||
752 IF C<4 THEN 756
|
||||
754 GOTO 760
|
||||
756 IF L(0)=2 THEN 862
|
||||
760 IF S1>7 THEN 867
|
||||
770 D1=INT(((30-H)*2.5+187-((30-H)*.25+15)*C/2)+25*RND(1))
|
||||
780 D1=INT(D1*W)
|
||||
800 IF T=2 THEN 1170
|
||||
830 O=(RND(1)/.8)*(2*H+16)*ABS(TAN(D1*.0035))
|
||||
840 D2=INT(SQR(O^2+ABS(D-D1)^2))
|
||||
850 IF D-D1<0 THEN 870
|
||||
860 GOTO 890
|
||||
862 PRINT "YOU DUBBED IT."
|
||||
864 D1=35
|
||||
866 GOTO 830
|
||||
867 IF D<200 THEN 1300
|
||||
868 GOTO 770
|
||||
870 IF D2<20 THEN 890
|
||||
880 PRINT "TOO MUCH CLUB. YOU'RE PAST THE HOLE."
|
||||
890 B=D
|
||||
900 D=D2
|
||||
910 IF D2>27 THEN 1020
|
||||
920 IF D2>20 THEN 1100
|
||||
930 IF D2>.5 THEN 1120
|
||||
940 L(0)=9
|
||||
950 GOTO 1470
|
||||
952 IF S2+Q+(10*(F-1)/18)<(F-1)*(72+((H+1)/.85))/18 THEN 956
|
||||
954 GOTO 752
|
||||
956 Q=Q+1
|
||||
957 IF S1/2<>INT(S1/2) THEN 1011
|
||||
958 GOTO 862
|
||||
960 PRINT "NOW GAUGE YOUR DISTANCE BY A PERCENTAGE (1 TO 100)"
|
||||
961 PRINT "OF A FULL SWING";
|
||||
970 INPUT W: W=W/100
|
||||
972 PRINT
|
||||
980 IF W>1 THEN 680
|
||||
985 IF L(0)=5 THEN 1280
|
||||
990 IF C=14 THEN 760
|
||||
1000 C=C-10
|
||||
1010 GOTO 760
|
||||
1011 IF D<95 THEN 862
|
||||
1012 PRINT "BALL HIT TREE - BOUNCED INTO ROUGH";D-75;"YARDS FROM HOLE."
|
||||
1014 D=D-75
|
||||
1018 GOTO 620
|
||||
1020 IF O<30 THEN 1150
|
||||
1022 IF J>0 THEN 1150
|
||||
1030 IF T>0 THEN 1070
|
||||
1035 S9=(S2+1)/15
|
||||
1036 IF INT(S9)=S9 THEN 1075
|
||||
1040 PRINT "YOU HOOKED- ";
|
||||
1050 L(0)=L(2)
|
||||
1055 IF O>45 THEN 1092
|
||||
1060 GOTO 320
|
||||
1070 S9=(S2+1)/15
|
||||
1071 IF INT(S9)=S9 THEN 1040
|
||||
1075 PRINT "YOU SLICED- ";
|
||||
1080 L(0)=L(1)
|
||||
1090 GOTO 1055
|
||||
1092 PRINT "BADLY."
|
||||
1094 GOTO 320
|
||||
1100 L(0)=5
|
||||
1110 GOTO 320
|
||||
1120 L(0)=8
|
||||
1130 D2=INT(D2*3)
|
||||
1140 GOTO 1380
|
||||
1150 L(0)=1
|
||||
1160 GOTO 320
|
||||
1170 D1=INT(.85*D1)
|
||||
1180 GOTO 830
|
||||
1190 IF L(0)>6 THEN 1260
|
||||
1200 PRINT "YOUR SHOT WENT INTO THE WATER."
|
||||
1210 S1=S1+1
|
||||
1220 PRINT "PENALTY STROKE ASSESSED. HIT FROM PREVIOUS LOCATION."
|
||||
1230 J=J+1
|
||||
1240 L(0)=1
|
||||
1242 D=B
|
||||
1250 GOTO 620
|
||||
1260 PRINT "YOUR SHOT WENT OUT OF BOUNDS."
|
||||
1270 GOTO 1210
|
||||
1280 IF T=3 THEN 1320
|
||||
1300 D2=1+(3*INT((80/(40-H))*RND(1)))
|
||||
1310 GOTO 1380
|
||||
1320 IF RND(1)>N THEN 1360
|
||||
1330 N=N*.2
|
||||
1340 PRINT "SHOT DUBBED, STILL IN TRAP."
|
||||
1350 GOTO 620
|
||||
1360 N=.8
|
||||
1370 GOTO 1300
|
||||
1380 PRINT "ON GREEN,";D2;"FEET FROM THE PIN."
|
||||
1381 PRINT "CHOOSE YOUR PUTT POTENCY (1 TO 13):";
|
||||
1400 INPUT I
|
||||
1410 S1=S1+1
|
||||
1420 IF S1+1-P>(H*.072)+2 THEN 1470
|
||||
1425 IF K>2 THEN 1470
|
||||
1428 K=K+1
|
||||
1430 IF T=4 THEN 1530
|
||||
1440 D2=D2-I*(4+2*RND(1))+1.5
|
||||
1450 IF D2<-2 THEN 1560
|
||||
1460 IF D2>2 THEN 1500
|
||||
1470 PRINT "YOU HOLED IT."
|
||||
1472 PRINT
|
||||
1480 F=F+1
|
||||
1490 GOTO 230
|
||||
1500 PRINT "PUTT SHORT."
|
||||
1505 D2=INT(D2)
|
||||
1510 GOTO 1380
|
||||
1530 D2=D2-I*(4+1*RND(1))+1
|
||||
1550 GOTO 1450
|
||||
1560 PRINT "PASSED BY CUP."
|
||||
1570 D2=-D2
|
||||
1580 GOTO 1505
|
||||
1590 READ D,P,L(1),L(2)
|
||||
1595 PRINT
|
||||
1600 PRINT "YOU ARE AT THE TEE OFF HOLE";F;"DISTANCE";D;"YARDS, PAR";P
|
||||
1605 G3=G3+P
|
||||
1620 PRINT "ON YOUR RIGHT IS ";
|
||||
1630 X=1
|
||||
1640 GOSUB 400
|
||||
1650 PRINT "ON YOUR LEFT IS ";
|
||||
1660 X=2
|
||||
1670 GOSUB 400
|
||||
1680 GOTO 620
|
||||
1690 RETURN
|
||||
1700 DATA 361,4,4,2,389,4,3,3,206,3,4,2,500,5,7,2
|
||||
1702 DATA 408,4,2,4,359,4,6,4,424,4,4,2,388,4,4,4
|
||||
1704 DATA 196,3,7,2,400,4,7,2,560,5,7,2,132,3,2,2
|
||||
1706 DATA 357,4,4,4,294,4,2,4,475,5,2,3,375,4,4,2
|
||||
1708 DATA 180,3,6,2,550,5,6,6
|
||||
1710 PRINT
|
||||
1750 G2=G2+S1
|
||||
1760 PRINT "TOTAL PAR FOR";F-1;"HOLES IS";G3;" YOUR TOTAL IS";G2
|
||||
1761 IF G1=F-1 THEN 1770
|
||||
1765 GOTO 292
|
||||
1770 END
|
||||
3
39_Golf/java/README.md
Normal file
3
39_Golf/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/)
|
||||
3
39_Golf/javascript/README.md
Normal file
3
39_Golf/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
39_Golf/javascript/golf.html
Normal file
9
39_Golf/javascript/golf.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>GOLF</title>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="output" style="font-size: 12pt;"></pre>
|
||||
<script src="golf.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
369
39_Golf/javascript/golf.js
Normal file
369
39_Golf/javascript/golf.js
Normal file
@@ -0,0 +1,369 @@
|
||||
// GOLF
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
var la = [];
|
||||
var f;
|
||||
var s1;
|
||||
var g2;
|
||||
var g3;
|
||||
var x;
|
||||
|
||||
var hole_data = [
|
||||
361,4,4,2,389,4,3,3,206,3,4,2,500,5,7,2,
|
||||
408,4,2,4,359,4,6,4,424,4,4,2,388,4,4,4,
|
||||
196,3,7,2,400,4,7,2,560,5,7,2,132,3,2,2,
|
||||
357,4,4,4,294,4,2,4,475,5,2,3,375,4,4,2,
|
||||
180,3,6,2,550,5,6,6,
|
||||
];
|
||||
|
||||
function show_obstacle()
|
||||
{
|
||||
switch (la[x]) {
|
||||
case 1:
|
||||
print("FAIRWAY.\n");
|
||||
break;
|
||||
case 2:
|
||||
print("ROUGH.\n");
|
||||
break;
|
||||
case 3:
|
||||
print("TREES.\n");
|
||||
break;
|
||||
case 4:
|
||||
print("ADJACENT FAIRWAY.\n");
|
||||
break;
|
||||
case 5:
|
||||
print("TRAP.\n");
|
||||
break;
|
||||
case 6:
|
||||
print("WATER.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function show_score()
|
||||
{
|
||||
g2 += s1;
|
||||
print("TOTAL PAR FOR " + (f - 1) + " HOLES IS " + g3 + " YOUR TOTAL IS " + g2 + "\n");
|
||||
}
|
||||
|
||||
// Main program
|
||||
async function main()
|
||||
{
|
||||
print(tab(34) + "GOLF\n");
|
||||
print(tab(15) + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("WELCOME TO THE CREATIVE COMPUTING COUNTRY CLUB,\n");
|
||||
print("AN EIGHTEEN HOLE CHAMPIONSHIP LAYOUT LOCATED A SHORT\n");
|
||||
print("DISTANCE FROM SCENIC DOWNTOWN MORRISTOWN. THE\n");
|
||||
print("COMMENTATOR WILL EXPLAIN THE GAME AS YOU PLAY.\n");
|
||||
print("ENJOY YOUR GAME; SEE YOU AT THE 19TH HOLE...\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
next_hole = 0;
|
||||
g1 = 18;
|
||||
g2 = 0;
|
||||
g3 = 0;
|
||||
a = 0;
|
||||
n = 0.8;
|
||||
s2 = 0;
|
||||
f = 1;
|
||||
while (1) {
|
||||
print("WHAT IS YOUR HANDICAP");
|
||||
h = parseInt(await input());
|
||||
print("\n");
|
||||
if (h < 0 || h > 30) {
|
||||
print("PGA HANDICAPS RANGE FROM 0 TO 30.\n");
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
do {
|
||||
print("DIFFICULTIES AT GOLF INCLUDE:\n");
|
||||
print("0=HOOK, 1=SLICE, 2=POOR DISTANCE, 4=TRAP SHOTS, 5=PUTTING\n");
|
||||
print("WHICH ONE (ONLY ONE) IS YOUR WORST");
|
||||
t = parseInt(await input());
|
||||
print("\n");
|
||||
} while (t > 5) ;
|
||||
s1 = 0;
|
||||
first_routine = true;
|
||||
while (1) {
|
||||
if (first_routine) {
|
||||
la[0] = 0;
|
||||
j = 0;
|
||||
q = 0;
|
||||
s2++;
|
||||
k = 0;
|
||||
if (f != 1) {
|
||||
print("YOUR SCORE ON HOLE " + (f - 1) + " WAS " + s1 + "\n");
|
||||
show_score();
|
||||
if (g1 == f - 1) // Completed all holes?
|
||||
return; // Exit game
|
||||
if (s1 > p + 2) {
|
||||
print("KEEP YOUR HEAD DOWN.\n");
|
||||
} else if (s1 == p) {
|
||||
print("A PAR. NICE GOING.\n");
|
||||
} else if (s1 == p - 1) {
|
||||
print("A BIRDIE.\n");
|
||||
} else if (s1 == p - 2) {
|
||||
if (p != 3)
|
||||
print("A GREAT BIG EAGLE.\n");
|
||||
else
|
||||
print("A HOLE IN ONE.\n");
|
||||
}
|
||||
}
|
||||
if (f == 19) {
|
||||
print("\n");
|
||||
show_score();
|
||||
if (g1 == f - 1)
|
||||
return;
|
||||
}
|
||||
s1 = 0;
|
||||
print("\n");
|
||||
if (s1 != 0 && la[0] < 1)
|
||||
la[0] = 1;
|
||||
}
|
||||
if (s1 == 0) {
|
||||
d = hole_data[next_hole++];
|
||||
p = hole_data[next_hole++];
|
||||
la[1] = hole_data[next_hole++];
|
||||
la[2] = hole_data[next_hole++];
|
||||
print("\n");
|
||||
print("YOU ARE AT THE TEE OFF HOLE " + f + " DISTANCE " + d + " YARDS, PAR " + p + "\n");
|
||||
g3 += p;
|
||||
print("ON YOUR RIGHT IS ");
|
||||
x = 1;
|
||||
show_obstacle();
|
||||
print("ON YOUR LEFT IS ");
|
||||
x = 2
|
||||
show_obstacle();
|
||||
} else {
|
||||
x = 0;
|
||||
if (la[0] > 5) {
|
||||
if (la[0] > 6) {
|
||||
print("YOUR SHOT WENT OUT OF BOUNDS.\n");
|
||||
} else {
|
||||
print("YOUR SHOT WENT INTO THE WATER.\n");
|
||||
}
|
||||
s1++;
|
||||
print("PENALTY STROKE ASSESSED. HIT FROM PREVIOUS LOCATION.\n");
|
||||
j++;
|
||||
la[0] = 1;
|
||||
d = b;
|
||||
} else {
|
||||
print("SHOT WENT " + d1 + " YARDS. IT'S " + d2 + " YARDS FROM THE CUP.\n");
|
||||
print("BALL IS " + Math.floor(o) + " YARDS OFF LINE... IN ");
|
||||
show_obstacle();
|
||||
}
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if (a != 1) {
|
||||
print("SELECTION OF CLUBS\n");
|
||||
print("YARDAGE DESIRED SUGGESTED CLUBS\n");
|
||||
print("200 TO 280 YARDS 1 TO 4\n");
|
||||
print("100 TO 200 YARDS 19 TO 13\n");
|
||||
print(" 0 TO 100 YARDS 29 TO 23\n");
|
||||
a = 1;
|
||||
}
|
||||
print("WHAT CLUB DO YOU CHOOSE");
|
||||
c = parseInt(await input());
|
||||
print("\n");
|
||||
if (c >= 1 && c <= 29 && (c < 5 || c >= 12)) {
|
||||
if (c > 4)
|
||||
c -= 6;
|
||||
if (la[0] <= 5 || c == 14 || c == 23) {
|
||||
s1++;
|
||||
w = 1;
|
||||
if (c <= 13) {
|
||||
if (f % 3 == 0 && s2 + q + (10 * (f - 1) / 18) < (f - 1) * (72 + ((h + 1) / 0.85)) / 18) {
|
||||
q++;
|
||||
if (s1 % 2 != 0 && d >= 95) {
|
||||
print("BALL HIT TREE - BOUNCED INTO ROUGH " + (d - 75) + " YARDS FROM HOLE.\n");
|
||||
d -= 75;
|
||||
continue;
|
||||
}
|
||||
print("YOU DUBBED IT.\n");
|
||||
d1 = 35;
|
||||
second_routine = 1;
|
||||
break;
|
||||
} else if (c < 4 && la[0] == 2) {
|
||||
print("YOU DUBBED IT.\n");
|
||||
d1 = 35;
|
||||
second_routine = 1;
|
||||
break;
|
||||
} else {
|
||||
second_routine = 0;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
print("NOW GAUGE YOUR DISTANCE BY A PERCENTAGE (1 TO 100)\n");
|
||||
print("OF A FULL SWING");
|
||||
w = parseInt(await input());
|
||||
w /= 100;
|
||||
print("\n");
|
||||
if (w <= 1) {
|
||||
if (la[0] == 5) {
|
||||
if (t == 3) {
|
||||
if (Math.random() <= n) {
|
||||
n *= 0.2;
|
||||
print("SHOT DUBBED, STILL IN TRAP.\n");
|
||||
continue;
|
||||
}
|
||||
n = 0.8;
|
||||
}
|
||||
d2 = 1 + (3 * Math.floor((80 / (40 - h)) * Math.random()));
|
||||
second_routine = 2;
|
||||
break;
|
||||
}
|
||||
if (c != 14)
|
||||
c -= 10;
|
||||
second_routine = 0;
|
||||
break;
|
||||
}
|
||||
s1--;
|
||||
// Fall through to THAT CLUB IS NOT IN THE BAG.
|
||||
}
|
||||
}
|
||||
}
|
||||
print("THAT CLUB IS NOT IN THE BAG.\n");
|
||||
print("\n");
|
||||
}
|
||||
if (second_routine == 0) {
|
||||
if (s1 > 7 && d < 200) {
|
||||
d2 = 1 + (3 * Math.floor((80 / (40 - h)) * Math.random()));
|
||||
second_routine = 2;
|
||||
} else {
|
||||
d1 = Math.floor(((30 - h) * 2.5 + 187 - ((30 - h) * 0.25 + 15) * c / 2) + 25 * Math.random());
|
||||
d1 = Math.floor(d1 * w);
|
||||
if (t == 2)
|
||||
d1 = Math.floor(d1 * 0.85);
|
||||
}
|
||||
}
|
||||
if (second_routine <= 1) {
|
||||
o = (Math.random() / 0.8) * (2 * h + 16) * Math.abs(Math.tan(d1 * 0.0035));
|
||||
d2 = Math.floor(Math.sqrt(Math.pow(o, 2) + Math.pow(Math.abs(d - d1), 2)));
|
||||
if (d - d1 < 0) {
|
||||
if (d2 >= 20)
|
||||
print("TOO MUCH CLUB, YOU'RE PAST THE HOLE.\n");
|
||||
}
|
||||
b = d;
|
||||
d = d2;
|
||||
if (d2 > 27) {
|
||||
if (o < 30 || j > 0) {
|
||||
la[0] = 1;
|
||||
} else {
|
||||
if (t <= 0) {
|
||||
s9 = (s2 + 1) / 15;
|
||||
if (Math.floor(s9) == s9) {
|
||||
print("YOU SLICED- ");
|
||||
la[0] = la[1];
|
||||
} else {
|
||||
print("YOU HOOKED- ");
|
||||
la[0] = la[2];
|
||||
}
|
||||
} else {
|
||||
s9 = (s2 + 1) / 15;
|
||||
if (Math.floor(s9) == s9) {
|
||||
print("YOU HOOKED- ");
|
||||
la[0] = la[2];
|
||||
} else {
|
||||
print("YOU SLICED- ");
|
||||
la[0] = la[1];
|
||||
}
|
||||
}
|
||||
if (o > 45)
|
||||
print("BADLY.\n");
|
||||
}
|
||||
first_routine = false;
|
||||
} else if (d2 > 20) {
|
||||
la[0] = 5;
|
||||
first_routine = false;
|
||||
} else if (d2 > 0.5) {
|
||||
la[0] = 8;
|
||||
d2 = Math.floor(d2 * 3);
|
||||
second_routine = 2;
|
||||
} else {
|
||||
la[0] = 9;
|
||||
print("YOU HOLED IT.\n");
|
||||
print("\n");
|
||||
f++;
|
||||
first_routine = true;
|
||||
}
|
||||
}
|
||||
if (second_routine == 2) {
|
||||
while (1) {
|
||||
print("ON GREEN, " + d2 + " FEET FROM THE PIN.\n");
|
||||
print("CHOOSE YOUR PUTT POTENCY (1 TO 13):");
|
||||
i = parseInt(await input());
|
||||
s1++;
|
||||
if (s1 + 1 - p <= (h * 0.072) + 2 && k <= 2) {
|
||||
k++;
|
||||
if (t == 4)
|
||||
d2 -= i * (4 + 1 * Math.random()) + 1;
|
||||
else
|
||||
d2 -= i * (4 + 2 * Math.random()) + 1.5;
|
||||
if (d2 < -2) {
|
||||
print("PASSED BY CUP.\n");
|
||||
d2 = Math.floor(-d2);
|
||||
continue;
|
||||
}
|
||||
if (d2 > 2) {
|
||||
print("PUTT SHORT.\n");
|
||||
d2 = Math.floor(d2);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
print("YOU HOLED IT.\n");
|
||||
print("\n");
|
||||
f++;
|
||||
break;
|
||||
}
|
||||
first_routine = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
3
39_Golf/pascal/README.md
Normal file
3
39_Golf/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
39_Golf/perl/README.md
Normal file
3
39_Golf/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
39_Golf/python/README.md
Normal file
3
39_Golf/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
39_Golf/ruby/README.md
Normal file
3
39_Golf/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
39_Golf/vbnet/README.md
Normal file
3
39_Golf/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