mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-12 15:50:20 -08:00
Added MiniScript verions of 37_Football and 38_Fur_Trader.
This commit is contained in:
30
00_Alternate_Languages/37_Football/MiniScript/README.md
Normal file
30
00_Alternate_Languages/37_Football/MiniScript/README.md
Normal file
@@ -0,0 +1,30 @@
|
||||
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
|
||||
|
||||
Conversion to [MiniScript](https://miniscript.org).
|
||||
|
||||
Ways to play:
|
||||
|
||||
1. Command-Line MiniScript:
|
||||
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
|
||||
|
||||
miniscript football.ms
|
||||
or
|
||||
miniscript ftball.ms
|
||||
|
||||
2. Mini Micro:
|
||||
Download Mini Micro from https://miniscript.org/MiniMicro/, launch, and then click the top disk slot and chose "Mount Folder..." Select the folder containing the BASIC program. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
load "football"
|
||||
run
|
||||
or
|
||||
load "ftball"
|
||||
run
|
||||
|
||||
|
||||
#### Apology from the Translator
|
||||
|
||||
These MiniScript programs were actually ported from the JavaScript ports of the original BASIC programs. I did that because the BASIC code (of both programs) was incomprehensible spaghetti. The JavaScript port, however, was essentially the same — and so are the MiniScript ports. The very structure of these programs makes them near-impossible to untangle.
|
||||
|
||||
If I were going to write a football simulation from scratch, I would approach it very differently. But in that case I would have either a detailed specification of how the program should behave, or at least enough understanding of American football to design it myself as I go. Neither is the case here (and we're supposed to be porting the original programs, not making up our own).
|
||||
|
||||
So, I'm sorry. Please take these programs as proof that you can write bad code even in the most simple, elegant languages. And I promise to try harder on future translations!
|
||||
402
00_Alternate_Languages/37_Football/MiniScript/football.ms
Normal file
402
00_Alternate_Languages/37_Football/MiniScript/football.ms
Normal file
@@ -0,0 +1,402 @@
|
||||
player_data = [17,8,4,14,19,3,10,1,7,11,15,9,5,20,13,18,16,2,12,6,
|
||||
20,2,17,5,8,18,12,11,1,4,19,14,10,7,9,15,6,13,16,3]
|
||||
aa = [0]*21
|
||||
ba = [0]*21
|
||||
ca = [0]*41
|
||||
ha = [0]*3
|
||||
ta = [0]*3
|
||||
wa = [0]*3
|
||||
xa = [0]*3
|
||||
ya = [0]*3
|
||||
za = [0]*3
|
||||
ms = [null, "",""]
|
||||
da = [0]*3
|
||||
ps = ["", "PITCHOUT","TRIPLE REVERSE","DRAW","QB SNEAK","END AROUND",
|
||||
"DOUBLE REVERSE","LEFT SWEEP","RIGHT SWEEP","OFF TACKLE",
|
||||
"WISHBONE OPTION","FLARE PASS","SCREEN PASS",
|
||||
"ROLL OUT OPTION","RIGHT CURL","LEFT CURL","WISHBONE OPTION",
|
||||
"SIDELINE PASS","HALF-BACK OPTION","RAZZLE-DAZZLE","BOMB!!!!"]
|
||||
globals.p = 0
|
||||
globals.t = 0
|
||||
|
||||
printFieldHeaders = function
|
||||
print "TEAM 1 [0 10 20 30 40 50 60 70 80 90 100] TEAM 2"
|
||||
print
|
||||
end function
|
||||
|
||||
printSeparator = function
|
||||
print "+" * 67
|
||||
end function
|
||||
|
||||
showBall = function
|
||||
print " " * (da[t] + 5 + p / 2) + ms[t]
|
||||
printFieldHeaders
|
||||
end function
|
||||
|
||||
showScores = function
|
||||
print
|
||||
print "TEAM 1 SCORE IS " + ha[1]
|
||||
print "TEAM 2 SCORE IS " + ha[2]
|
||||
print
|
||||
if ha[t] >= e then
|
||||
print "TEAM " + t + " WINS*******************"
|
||||
return true
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
losePossession = function
|
||||
print
|
||||
print "** LOSS OF POSSESSION FROM TEAM " + t + " TO TEAM " + ta[t]
|
||||
print
|
||||
printSeparator
|
||||
print
|
||||
globals.t = ta[t]
|
||||
end function
|
||||
|
||||
touchdown = function
|
||||
print
|
||||
print "TOUCHDOWN BY TEAM " + t + " *********************YEA TEAM"
|
||||
q = 7
|
||||
if rnd <= 0.1 then
|
||||
q = 6
|
||||
print "EXTRA POINT NO GOOD"
|
||||
else
|
||||
print "EXTRA POINT GOOD"
|
||||
end if
|
||||
ha[t] += q
|
||||
end function
|
||||
|
||||
askYesNo = function(prompt)
|
||||
while true
|
||||
yn = input(prompt + "? ").lower
|
||||
if not yn then continue
|
||||
if yn[0] == "y" then return "YES"
|
||||
if yn[0] == "n" then return "NO"
|
||||
end while
|
||||
end function
|
||||
|
||||
|
||||
print " "*32 + "FOOTBALL"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
print "Presenting N.F.U. Football (No FORTRAN Used)"
|
||||
print; print
|
||||
if askYesNo("Do you want instructions") == "YES" then
|
||||
print "This is a football game for two teams in which players must"
|
||||
print "prepare a tape with a data statement (1770 for team 1,"
|
||||
print "1780 for team 2) in which each team scrambles nos. 1-20"
|
||||
print "These numbers are then assigned to twenty given plays."
|
||||
print "A list of nos. and their plays is provided with"
|
||||
print "both teams having the same plays. The more similar the"
|
||||
print "plays the less yardage gained. Scores are given"
|
||||
print "whenever scores are made. Scores may also be obtained"
|
||||
print "by inputting 99,99 for play nos. To punt or attempt a"
|
||||
print "field goal, input 77,77 for play numbers. Questions will be"
|
||||
print "asked then. On 4th down, you will also be asked whether"
|
||||
print "you want to punt or attempt a field goal. If the answer to"
|
||||
print "both questions is no it will be assumed you want to"
|
||||
print "try and gain yardage. Answer all questions Yes or No."
|
||||
print "The game is played until players terminate (control-c)."
|
||||
print "Please prepare a tape and run."
|
||||
end if
|
||||
print
|
||||
e = input("Please input score limit on game: ").val
|
||||
for i in range(1, 40)
|
||||
if i <= 20 then
|
||||
aa[player_data[i - 1]] = i
|
||||
else
|
||||
ba[player_data[i - 1]] = i - 20
|
||||
end if
|
||||
ca[i] = player_data[i - 1]
|
||||
end for
|
||||
l = 0
|
||||
globals.t = 1
|
||||
while true
|
||||
print "TEAM " + t + " PLAY CHART"
|
||||
print "NO. PLAY"
|
||||
for i in range(1, 20)
|
||||
print (ca[i+1] + " "*6)[:6] + ps[i]
|
||||
end for
|
||||
l += 20
|
||||
globals.t = 2
|
||||
print
|
||||
print "TEAR OFF HERE----------------------------------------------"
|
||||
for x in range(1, 11); print; end for
|
||||
wait 3
|
||||
if l != 20 then break
|
||||
end while
|
||||
|
||||
playGame = function
|
||||
da[1] = 0
|
||||
da[2] = 3
|
||||
ms[1] = "--->"
|
||||
ms[2] = "<---"
|
||||
ha[1] = 0
|
||||
ha[2] = 0
|
||||
ta[1] = 2
|
||||
ta[2] = 1
|
||||
wa[1] = -1
|
||||
wa[2] = 1
|
||||
xa[1] = 100
|
||||
xa[2] = 0
|
||||
ya[1] = 1
|
||||
ya[2] = -1
|
||||
za[1] = 0
|
||||
za[2] = 100
|
||||
globals.p = 0
|
||||
printFieldHeaders
|
||||
print "TEAM 1 defend 0 YD goal -- TEAM 2 defends 100 YD goal."
|
||||
globals.t = floor(2 * rnd + 1)
|
||||
print
|
||||
print "The coin is flipped"
|
||||
routine = 1
|
||||
while true
|
||||
if routine <= 1 then
|
||||
globals.p = xa[t] - ya[t] * 40
|
||||
printSeparator
|
||||
print
|
||||
print "Team " + t + " receives kick-off"
|
||||
k = floor(26 * rnd + 40)
|
||||
end if
|
||||
if routine <= 2 then
|
||||
globals.p = p - ya[t] * k
|
||||
end if
|
||||
if routine <= 3 then
|
||||
if wa[t] * p >= za[t] + 10 then
|
||||
print
|
||||
print "Ball went out of endzone --automatic touchback--"
|
||||
globals.p = za[t] - wa[t] * 20
|
||||
if routine <= 4 then routine = 5
|
||||
else
|
||||
print "Ball went " + k + " yards. Now on " + p
|
||||
showBall
|
||||
end if
|
||||
end if
|
||||
if routine <= 4 then
|
||||
if askYesNo("Team " + t + " do you want to runback") == "YES" then
|
||||
k = floor(9 * rnd + 1)
|
||||
r = floor(((xa[t] - ya[t] * p + 25) * rnd - 15) / k)
|
||||
globals.p = p - wa[t] * r
|
||||
print
|
||||
print "Runback team " + t + " " + r + " yards"
|
||||
g = rnd
|
||||
if g < 0.25 then
|
||||
losePossession
|
||||
routine = 4
|
||||
continue
|
||||
else if ya[t] * p >= xa[t] then
|
||||
touchdown
|
||||
if showScores then return
|
||||
globals.t = ta[t]
|
||||
routine = 1
|
||||
continue
|
||||
else if wa[t] * p >= za[t] then
|
||||
print
|
||||
print "Safety against team " + t + " **********************OH-OH"
|
||||
ha[ta[t]] += 2
|
||||
if showScores then return
|
||||
globals.p = za[t] - wa[t] * 20
|
||||
if askYesNo("Team " + t + " do you want to punt instead of a kickoff") == "YES" then
|
||||
print
|
||||
print "Team " + t + " will punt"
|
||||
g = rnd
|
||||
if g < 0.25 then
|
||||
losePossession
|
||||
routine = 4
|
||||
continue
|
||||
end if
|
||||
print
|
||||
printSeparator
|
||||
k = floor(25 * rnd + 35)
|
||||
globals.t = ta[t]
|
||||
routine = 2
|
||||
continue
|
||||
end if
|
||||
touchdown
|
||||
if showScores then return
|
||||
globals.t = ta[t]
|
||||
routine = 1
|
||||
continue
|
||||
else
|
||||
routine = 5
|
||||
continue
|
||||
end if
|
||||
else // player does not want to runback
|
||||
if wa[t] * p >= za[t] then globals.p = za[t] - wa[t] * 20
|
||||
end if
|
||||
end if
|
||||
if routine <= 5 then
|
||||
d = 1
|
||||
s = p
|
||||
end if
|
||||
if routine <= 6 then
|
||||
print "=" * 67
|
||||
print "TEAM " + t + " DOWN " + d + " ON " + p
|
||||
if d == 1 then
|
||||
if ya[t] * (p + ya[t] * 10) >= xa[t] then
|
||||
c = 8
|
||||
else
|
||||
c = 4
|
||||
end if
|
||||
end if
|
||||
if c != 8 then
|
||||
print " "*27 + (10 - (ya[t] * p - ya[t] * s)) + " yards to 1st down"
|
||||
else
|
||||
print " "*27 + (xa[t] - ya[t] * p) + " yards"
|
||||
end if
|
||||
showBall
|
||||
if d == 4 then routine = 8
|
||||
end if
|
||||
if routine <= 7 then
|
||||
u = floor(3 * rnd - 1)
|
||||
while true
|
||||
str = input("Input offensive play, defensive play: ")
|
||||
str = str.replace(",", " ").replace(" ", " ").split
|
||||
if t == 1 then
|
||||
p1 = str[0].val
|
||||
p2 = str[1].val
|
||||
else
|
||||
p2 = str[0].val
|
||||
p1 = str[1].val
|
||||
end if
|
||||
if p1 == 99 then
|
||||
if showScores then return
|
||||
continue
|
||||
end if
|
||||
if 1 <= p1 <= 20 and 1 <= p2 <= 20 then break
|
||||
print "Illegal play number, check and"
|
||||
end while
|
||||
end if
|
||||
if d == 4 or p1 == 77 then
|
||||
if askYesNo("Does team " + t + " want to punt") == "YES" then
|
||||
print
|
||||
print "Team " + t + " will punt"
|
||||
if rnd < 0.25 then
|
||||
losePossession
|
||||
routine = 4
|
||||
continue
|
||||
end if
|
||||
print
|
||||
printSeparator
|
||||
k = floor(25 * rnd + 35)
|
||||
globals.t = ta[t]
|
||||
routine = 2
|
||||
continue
|
||||
end if
|
||||
if askYesNo("Does team " + t + " want to attempt a field goal") == "YES" then
|
||||
print
|
||||
print "Team " + t + " will attempt a field goal"
|
||||
if rnd < 0.025 then
|
||||
losePossession
|
||||
routine = 4
|
||||
continue
|
||||
else
|
||||
f = floor(35 * rnd + 20)
|
||||
print
|
||||
print "Kick is " + f + " yards long"
|
||||
globals.p = p - wa[t] * f
|
||||
if rnd < 0.35 then
|
||||
print "Ball went wide"
|
||||
else if ya[t] * p >= xa[t] then
|
||||
print "FIELD GOLD GOOD FOR TEAM " + t + " *********************YEA"
|
||||
q = 3
|
||||
ha[t] = ha[t] + q
|
||||
if showScores then return
|
||||
globals.t = ta[t]
|
||||
routine = 1
|
||||
continue
|
||||
end if
|
||||
print "Field goal unsuccesful team " + t + "-----------------too bad"
|
||||
print
|
||||
printSeparator
|
||||
if ya[t] * p < xa[t] + 10 then
|
||||
print
|
||||
print "Ball now on " + p
|
||||
globals.t = ta[t]
|
||||
showBall
|
||||
routine = 4
|
||||
continue
|
||||
else
|
||||
globals.t = ta[t]
|
||||
routine = 3
|
||||
continue
|
||||
end if
|
||||
end if
|
||||
else
|
||||
routine = 7
|
||||
continue
|
||||
end if
|
||||
end if
|
||||
y = floor(abs(aa[p1] - ba[p2]) / 19 * ((xa[t] - ya[t] * p + 25) * rnd - 15))
|
||||
print
|
||||
if t == 1 and aa[p1] < 11 or t == 2 and ba[p2] < 11 then
|
||||
print "The ball was run"
|
||||
else if u == 0 then
|
||||
print "Pass incomplete team " + t
|
||||
y = 0
|
||||
else
|
||||
if rnd <= 0.025 and y > 2 then
|
||||
print "Pass completed"
|
||||
else
|
||||
print "Quarterback scrambled"
|
||||
end if
|
||||
end if
|
||||
globals.p = p - wa[t] * y
|
||||
print
|
||||
print "Net yards gained on down " + d + " are " + y
|
||||
|
||||
if rnd <= 0.025 then
|
||||
losePossession
|
||||
routine = 4
|
||||
continue
|
||||
else if ya[t] * p >= xa[t] then
|
||||
touchdown
|
||||
if showScores then return
|
||||
globals.t = ta[t]
|
||||
routine = 1
|
||||
continue
|
||||
else if wa[t] * p >= za[t] then
|
||||
print
|
||||
print "SAFETY AGAINST TEAM " + t + " **********************OH-OH"
|
||||
ha[ta[t]] = ha[ta[t]] + 2
|
||||
if showScores then return
|
||||
globals.p = za[t] - wa[t] * 20
|
||||
if askYesNo("Team " + t + " do you want to punt instead of a kickoff") == "YES" then
|
||||
print
|
||||
print "Team " + t + " will punt"
|
||||
if rnd < 0.25 then
|
||||
losePossession
|
||||
routine = 4
|
||||
continue
|
||||
end if
|
||||
print
|
||||
printSeparator
|
||||
k = floor(25 * rnd + 35)
|
||||
globals.t = ta[t]
|
||||
routine = 2
|
||||
continue
|
||||
end if
|
||||
touchdown
|
||||
if showScores then return
|
||||
globals.t = ta[t]
|
||||
routine = 1
|
||||
else if ya[t] * p - ya[t] * s >= 10 then
|
||||
routine = 5
|
||||
else
|
||||
d += 1
|
||||
if d != 5 then
|
||||
routine = 6
|
||||
else
|
||||
print
|
||||
print "Conversion unsuccessful team " + t
|
||||
globals.t = ta[t]
|
||||
print
|
||||
printSeparator
|
||||
routine = 5
|
||||
end if
|
||||
end if
|
||||
end while
|
||||
end function
|
||||
|
||||
playGame
|
||||
431
00_Alternate_Languages/37_Football/MiniScript/ftball.ms
Normal file
431
00_Alternate_Languages/37_Football/MiniScript/ftball.ms
Normal file
@@ -0,0 +1,431 @@
|
||||
os = ["Dartmouth", ""]
|
||||
sa = [0, 1]
|
||||
ls = ["", "Kick","receive"," yard ","run back for ","ball on ",
|
||||
"yard line"," simple run"," tricky run"," short pass",
|
||||
" long pass","punt"," quick kick "," place kick"," loss ",
|
||||
" no gain","gain "," touchdown "," touchback ","safety***",
|
||||
"junk"]
|
||||
p = 0
|
||||
x = 0
|
||||
x1 = 0
|
||||
|
||||
fnf = function(x); return 1 - 2 * p; end function
|
||||
fng = function(z); return p * (x1 - x) + (1 - p) * (x - x1); end function
|
||||
|
||||
show_score = function
|
||||
print
|
||||
print "SCORE: " + sa[0] + " TO " + sa[1]
|
||||
print
|
||||
print
|
||||
end function
|
||||
|
||||
show_position = function
|
||||
if x <= 50 then
|
||||
print ls[5] + os[0] + " " + x + " " + ls[6]
|
||||
else
|
||||
print ls[5] + os[1] + " " + (100 - x) + " " + ls[6]
|
||||
end if
|
||||
end function
|
||||
|
||||
offensive_td = function
|
||||
print ls[17] + "***"
|
||||
if rnd <= 0.8 then
|
||||
sa[p] += 7
|
||||
print "Kick is good."
|
||||
else
|
||||
print "Kick is off to the side"
|
||||
sa[p] += 6
|
||||
end if
|
||||
show_score
|
||||
print os[p] + " kicks off"
|
||||
globals.p = 1 - p
|
||||
end function
|
||||
|
||||
// Main program
|
||||
main = function
|
||||
print " "*33 + "FTBALL"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print
|
||||
print
|
||||
print "This is Dartmouth championship football."
|
||||
print
|
||||
print "You will quarterback Dartmouth. Call plays as follows:"
|
||||
print "1= simple run; 2= tricky run; 3= short pass;"
|
||||
print "4= long pass; 5= punt; 6= quick kick; 7= place kick."
|
||||
print
|
||||
os[1] = input("Choose your opponent: ").upper
|
||||
os[0] = "DARMOUTH"
|
||||
print
|
||||
sa[0] = 0
|
||||
sa[1] = 0
|
||||
globals.p = floor(rnd * 2)
|
||||
print os[p] + " won the toss"
|
||||
if p != 0 then
|
||||
print os[1] + " Elects to receive."
|
||||
print
|
||||
else
|
||||
print "Do you elect to kick or receive? "
|
||||
while true
|
||||
str = input.lower
|
||||
if str and (str[0] == "k" or str[0] == "r") then break
|
||||
print "Incorrect answer. Please type 'kick' or 'receive'"
|
||||
end while
|
||||
if str[0] == "k" then e = 1 else e = 2
|
||||
if e == 1 then globals.p = 1
|
||||
end if
|
||||
globals.t = 0
|
||||
start = 1
|
||||
while true
|
||||
if start <= 1 then
|
||||
x = 40 + (1 - p) * 20
|
||||
end if
|
||||
if start <= 2 then
|
||||
y = floor(200 * ((rnd - 0.5))^3 + 55)
|
||||
print " " + y + " " + ls[3] + " kickoff"
|
||||
x = x - fnf(1) * y
|
||||
if abs(x - 50) >= 50 then
|
||||
print "Touchback for " + os[p] + "."
|
||||
x = 20 + p * 60
|
||||
start = 4
|
||||
else
|
||||
start = 3
|
||||
end if
|
||||
end if
|
||||
if start <= 3 then
|
||||
y = floor(50 * (rnd)^2) + (1 - p) * floor(50 * (rnd)^4)
|
||||
x = x + fnf(1) * y
|
||||
if abs(x - 50) < 50 then
|
||||
print " " + y + " " + ls[3] + " runback"
|
||||
else
|
||||
print ls[4]
|
||||
offensive_td
|
||||
start = 1
|
||||
continue
|
||||
end if
|
||||
end if
|
||||
if start <= 4 then
|
||||
// First down
|
||||
show_position
|
||||
end if
|
||||
if start <= 5 then
|
||||
x1 = x
|
||||
d = 1
|
||||
print
|
||||
print "First down " + os[p] + "***"
|
||||
print
|
||||
print
|
||||
end if
|
||||
// New play
|
||||
globals.t += 1
|
||||
if t == 30 then
|
||||
if rnd <= 1.3 then
|
||||
print "Game delayed. Dog on field."
|
||||
print
|
||||
end if
|
||||
end if
|
||||
if t >= 50 and rnd <= 0.2 then break
|
||||
if p != 1 then
|
||||
// Opponent's play
|
||||
if d <= 1 then
|
||||
if rnd > 1/3 then z = 1 else z = 3
|
||||
else if d != 4 then
|
||||
if 10 + x - x1 < 5 or x < 5 then
|
||||
if rnd > 1/3 then z = 1 else z = 3
|
||||
else if x <= 10 then
|
||||
a = floor(2 * rnd)
|
||||
z = 2 + a
|
||||
else if x <= x1 or d < 3 or x < 45 then
|
||||
a = floor(2 * rnd)
|
||||
z = 2 + a * 2
|
||||
else
|
||||
if (rnd > 1 / 4) then
|
||||
z = 4
|
||||
else
|
||||
z = 6
|
||||
end if
|
||||
end if
|
||||
else
|
||||
if x <= 30 then
|
||||
z = 5
|
||||
else if 10 + x - x1 < 3 or x < 3 then
|
||||
if rnd > 1/3 then z = 1 else z = 3
|
||||
else
|
||||
z = 7
|
||||
end if
|
||||
end if
|
||||
else
|
||||
while true
|
||||
z = input("Next play? ").val
|
||||
if 1 <= z <= 7 then break
|
||||
print "Illegal play number, retype"
|
||||
end while
|
||||
end if
|
||||
f = 0
|
||||
print ls[z + 6] + ". "
|
||||
r = rnd * (0.98 + fnf(1) * 0.02)
|
||||
r1 = rnd
|
||||
if z == 1 or z == 2 then // Simple Run or Tricky Run
|
||||
done = false
|
||||
if z == 1 then
|
||||
y = floor(24 * (r - 0.5)^3 + 3)
|
||||
if rnd >= 0.05 then
|
||||
routine = 1
|
||||
done = true
|
||||
end if
|
||||
else
|
||||
y = floor(20 * r - 5)
|
||||
if rnd > 0.1 then
|
||||
routine = 1
|
||||
done = true
|
||||
end if
|
||||
end if
|
||||
if not done then
|
||||
f = -1
|
||||
x3 = x
|
||||
x = x + fnf(1) * y
|
||||
if abs(x - 50) < 50 then
|
||||
print "*** Fumble after "
|
||||
routine = 2
|
||||
else
|
||||
print "*** Fumble."
|
||||
routine = 4
|
||||
end if
|
||||
end if
|
||||
else if z == 3 or z == 4 then // Short Pass or Long Pass
|
||||
if z == 3 then
|
||||
y = floor(60 * (r1 - 0.5)^3 + 10)
|
||||
else
|
||||
y = floor(160 * ((r1 - 0.5))^3 + 30)
|
||||
end if
|
||||
if z == 3 and r < 0.05 or z == 4 and r < 0.1 then
|
||||
if d != 4 then
|
||||
print "Intercepted."
|
||||
f = -1
|
||||
x = x + fnf(1) * y
|
||||
if abs(x - 50) >= 50 then
|
||||
routine = 4
|
||||
else
|
||||
routine = 3
|
||||
end if
|
||||
else
|
||||
y = 0
|
||||
if rnd < 0.3 then
|
||||
print "Batted down. ", ""
|
||||
else
|
||||
print "Incomplete. ", ""
|
||||
end if
|
||||
routine = 1
|
||||
end if
|
||||
else if z == 4 and r < 0.3 then
|
||||
print "Passer tackled. ", ""
|
||||
y = -floor(15 * r1 + 3)
|
||||
routine = 1
|
||||
else if z == 3 and r < 0.15 then
|
||||
print "Passer taclked. ", ""
|
||||
y = -floor(10 * r1)
|
||||
routine = 1
|
||||
else if z == 3 and r < 0.55 or z == 4 and r < 0.75 then
|
||||
y = 0
|
||||
if rnd < 0.3 then
|
||||
print "Batted down. ", ""
|
||||
else
|
||||
print "Incomplete. ", ""
|
||||
end if
|
||||
routine = 1
|
||||
else
|
||||
print "Complete. ", ""
|
||||
routine = 1
|
||||
end if
|
||||
else if z == 5 or z == 6 then // Punt or Quick Kick
|
||||
y = floor(100 * ((r - 0.5))^3 + 35)
|
||||
if (d != 4) then y = floor(y * 1.3)
|
||||
print " " + y + " " + ls[3] + " punt"
|
||||
if abs(x + y * fnf(1) - 50) < 50 and d >= 4 then
|
||||
y1 = floor((r1)^2 * 20)
|
||||
print " " + y1 + " " + ls[3] + " Run back"
|
||||
y = y - y1
|
||||
end if
|
||||
f = -1
|
||||
x = x + fnf(1) * y
|
||||
if abs(x - 50) >= 50 then routine = 4 else routine = 3
|
||||
else if z == 7 then // Place kick
|
||||
y = floor(100 * ((r - 0.5))^3 + 35)
|
||||
if r1 <= 0.15 then
|
||||
print "Kick is blocked ***"
|
||||
x = x - 5 * fnf(1)
|
||||
globals.p = 1 - p
|
||||
start = 4
|
||||
continue
|
||||
end if
|
||||
x = x + fnf(1) * y
|
||||
if abs(x - 50) >= 60 then
|
||||
if r1 <= 0.5 then
|
||||
print "Kick is off to the side."
|
||||
print ls[18]
|
||||
globals.p = 1 - p
|
||||
x = 20 + p * 60
|
||||
start = 4
|
||||
continue
|
||||
else
|
||||
print "Field goal ***"
|
||||
sa[p] = sa[p] + 3
|
||||
show_score
|
||||
print os[p] + " kicks off"
|
||||
globals.p = 1 - p
|
||||
start = 1
|
||||
continue
|
||||
end if
|
||||
else
|
||||
print "Kick is short."
|
||||
if abs(x - 50) >= 50 then
|
||||
// Touchback
|
||||
print ls[18]
|
||||
globals.p = 1 - p
|
||||
x = 20 + p * 60
|
||||
start = 4
|
||||
continue
|
||||
end if
|
||||
globals.p = 1 - p
|
||||
start = 3
|
||||
continue
|
||||
end if
|
||||
end if
|
||||
// Gain or loss
|
||||
if routine <= 1 then
|
||||
x3 = x
|
||||
x = x + fnf(1) * y
|
||||
if abs(x - 50) >= 50 then
|
||||
routine = 4
|
||||
end if
|
||||
end if
|
||||
if routine <= 2 then
|
||||
if y != 0 then
|
||||
print " " + abs(y) + " " + ls[3]
|
||||
if (y < 0) then
|
||||
yt = -1
|
||||
else if y > 0 then
|
||||
yt = 1
|
||||
else
|
||||
yt = 0
|
||||
end if
|
||||
print ls[15 + yt]
|
||||
if abs(x3 - 50) <= 40 and rnd < 0.1 then
|
||||
// Penalty
|
||||
p3 = floor(2 * rnd)
|
||||
print os[p3] + " offsides -- penalty of 5 yards."
|
||||
print
|
||||
print
|
||||
if p3 != 0 then
|
||||
print "Do you accept the penalty?"
|
||||
while true
|
||||
str = input.lower
|
||||
if str and (str[0] == "y" or str[0] == "n") then break
|
||||
print "Yype 'yes' or 'no'"
|
||||
end while
|
||||
if str[0] == "y" then
|
||||
f = 0
|
||||
d = d - 1
|
||||
if (p != p3) then
|
||||
x = x3 + fnf(1) * 5
|
||||
else
|
||||
x = x3 - fnf(1) * 5
|
||||
end if
|
||||
end if
|
||||
else
|
||||
// opponent's strategy on penalty
|
||||
if ((p != 1 and (y <= 0 or f < 0 or fng(1) < 3 * d - 2)) or
|
||||
(p == 1 and ((y > 5 and f >= 0) or d < 4 or fng(1) >= 10))) then
|
||||
print "penalty refused."
|
||||
else
|
||||
print "penalty accepted."
|
||||
f = 0
|
||||
d = d - 1
|
||||
if (p != p3) then
|
||||
x = x3 + fnf(1) * 5
|
||||
else
|
||||
x = x3 - fnf(1) * 5
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
routine = 3
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
if routine <= 3 then
|
||||
show_position
|
||||
if f != 0 then
|
||||
globals.p = 1 - p
|
||||
start = 5
|
||||
continue
|
||||
else if fng(1) >= 10 then
|
||||
start = 5
|
||||
continue
|
||||
else if d == 4 then
|
||||
globals.p = 1 - p
|
||||
start = 5
|
||||
continue
|
||||
else
|
||||
d += 1
|
||||
print "DOWN: " + d + " "
|
||||
if (x1 - 50) * fnf(1) >= 40 then
|
||||
print "Goal to go"
|
||||
else
|
||||
print "Yards to go: " + (10 - fng(1))
|
||||
end if
|
||||
print
|
||||
print
|
||||
start = 6
|
||||
continue
|
||||
end if
|
||||
end if
|
||||
if routine <= 4 then
|
||||
// Ball in end-zone
|
||||
e = (x >= 100)
|
||||
case = 1 + e - f * 2 + p * 4
|
||||
if case == 1 or case == 5 then
|
||||
// Safety
|
||||
sa[1 - p] = sa[1 - p] + 2
|
||||
print ls[19]
|
||||
show_score
|
||||
print os[p] + " kicks off from its 20 yard line."
|
||||
x = 20 + p * 60
|
||||
globals.p = 1 - p
|
||||
start = 2
|
||||
continue
|
||||
end if
|
||||
if case == 3 or case == 6 then
|
||||
// defensive td
|
||||
print ls[17] + "for " + os[1 - p] + "***"
|
||||
globals.p = 1 - p
|
||||
end if
|
||||
if case == 3 or case == 6 or case == 2 or case == 8 then
|
||||
// offensive td
|
||||
print ls[17] + "***"
|
||||
if rnd <= 0.8 then
|
||||
sa[p] = sa[p] + 7
|
||||
print "kick is good."
|
||||
else
|
||||
print "kick is off to the side"
|
||||
sa[p] = sa[p] + 6
|
||||
end if
|
||||
show_score
|
||||
print os[p] + " kicks off"
|
||||
globals.p = 1 - p
|
||||
start = 1
|
||||
continue
|
||||
end if
|
||||
if case == 4 or case == 7 then
|
||||
// Touchback
|
||||
print ls[18]
|
||||
globals.p = 1 - p
|
||||
x = 20 + p * 60
|
||||
start = 4
|
||||
continue
|
||||
end if
|
||||
end if
|
||||
end while
|
||||
print "END OF GAME ***"
|
||||
print "FINAL SCORE: " + os[0] + ": " + sa[0] + " " + os[1] + ": " + sa[1]
|
||||
end function
|
||||
|
||||
main
|
||||
16
00_Alternate_Languages/38_Fur_Trader/MiniScript/README.md
Normal file
16
00_Alternate_Languages/38_Fur_Trader/MiniScript/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
|
||||
|
||||
Conversion to [MiniScript](https://miniscript.org).
|
||||
|
||||
Ways to play:
|
||||
|
||||
1. Command-Line MiniScript:
|
||||
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
|
||||
|
||||
miniscript furtrader.ms
|
||||
|
||||
2. Mini Micro:
|
||||
Download Mini Micro from https://miniscript.org/MiniMicro/, launch, and then click the top disk slot and chose "Mount Folder..." Select the folder containing the BASIC program. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
load "furtrader"
|
||||
run
|
||||
171
00_Alternate_Languages/38_Fur_Trader/MiniScript/furtrader.ms
Normal file
171
00_Alternate_Languages/38_Fur_Trader/MiniScript/furtrader.ms
Normal file
@@ -0,0 +1,171 @@
|
||||
print " "*31 + "Fur Trader"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
|
||||
furs = [0,0,0,0] // how many of each type of fur you have
|
||||
value = [0,0,0,0] // value of each type of fur
|
||||
furNames = "mink beaver ermine fox".split
|
||||
|
||||
getYesNo = function
|
||||
while true
|
||||
ans = input("Answer yes or no: ").upper
|
||||
if not ans then continue
|
||||
if ans[0] == "Y" then return "YES"
|
||||
if ans[0] == "N" then return "NO"
|
||||
end while
|
||||
end function
|
||||
|
||||
printInstructions = function
|
||||
print "You are the leader of a French fur trading expedition in "
|
||||
print "1776 leaving the Lake Ontario area to sell furs and get"
|
||||
print "supplies for the next year. You have a choice of three"
|
||||
print "forts at which you may trade. The cost of supplies"
|
||||
print "and the amount you receive for your furs will depend"
|
||||
print "on the fort that you choose."
|
||||
print
|
||||
end function
|
||||
|
||||
pickFort = function
|
||||
print
|
||||
while true
|
||||
print "You may trade your furs at fort 1, fort 2,"
|
||||
print "or fort 3. Fort 1 is Fort Hochelaga (Montreal)"
|
||||
print "and is under the protection of the French army."
|
||||
print "Fort 2 is Fort Stadacona (Quebec) and is under the"
|
||||
print "protection of the French Army. However, you must"
|
||||
print "make a portage and cross the Lachine rapids."
|
||||
print "Fort 3 is Fort New York and is under Dutch control."
|
||||
print "You must cross through Iroquois land."
|
||||
b = input("Answer 1, 2, or 3: ").val
|
||||
if b == 1 then
|
||||
print "You have chosen the easiest route. However, the fort"
|
||||
print "is far from any seaport. The value"
|
||||
print "you receive for your furs will be low and the cost"
|
||||
print "of supplies higher than at Forts Stadacona or New York."
|
||||
else if b == 2 then
|
||||
print "You have chosen a hard route. It is, in comparsion,"
|
||||
print "harder than the route to Hochelaga but easier than"
|
||||
print "the route to New York. You will receive an average value"
|
||||
print "for your furs and the cost of your supplies will be average."
|
||||
else if b == 3 then
|
||||
print "You have chosen the most difficult route. At"
|
||||
print "Fort New York you will receive the highest value"
|
||||
print "for your furs. The cost of your supplies"
|
||||
print "will be lower than at all the other forts."
|
||||
else
|
||||
continue
|
||||
end if
|
||||
print "Do you want to trade at another fort?"
|
||||
if getYesNo == "NO" then return b
|
||||
end while
|
||||
end function
|
||||
|
||||
visitFort = function(fort)
|
||||
print
|
||||
if fort == 1 then
|
||||
value[0] = floor((.2*rnd+.7)*100+.5)/100
|
||||
value[2] = floor((.2*rnd+.65)*100+.5)/100
|
||||
value[1] = floor((.2*rnd+.75)*100+.5)/100
|
||||
value[3] = floor((.2*rnd+.8)*100+.5)/100
|
||||
print "Supplies at Fort Hochelaga cost $150.00."
|
||||
print "Your travel expenses to Hochelaga were $10.00."
|
||||
globals.money -= 150 + 10
|
||||
else if fort == 2 then
|
||||
value[0] = floor((.3*rnd+.85)*100+.5)/100
|
||||
value[2] = floor((.15*rnd+.8)*100+.5)/100
|
||||
value[1] = floor((.2*rnd+.9)*100+.5)/100
|
||||
p = floor(10*rnd)+1
|
||||
if p <= 2 then
|
||||
furs[1] = 0
|
||||
print "Your beaver were too heavy to carry across"
|
||||
print "the portage. You had to leave the pelts, but found"
|
||||
print "them stolen when you returned."
|
||||
else if p <= 6 then
|
||||
print "You arrived safely at Fort Stadacona."
|
||||
else if p <= 8 then
|
||||
for j in range(0,3); furs[j] = 0; end for
|
||||
print "Your canoe upset in the Lachine rapids. You"
|
||||
print "lost all your furs."
|
||||
else if furs[3] then
|
||||
furs[3] = 0
|
||||
print "Your fox pelts were not cured properly."
|
||||
print "No one will buy them."
|
||||
end if
|
||||
print "Supplies at Fort Stadacona cost $125.00."
|
||||
print "Your travel expenses to Stadacona were $15.00."
|
||||
globals.money -= 125 + 15
|
||||
else
|
||||
value[0] = floor((.15*rnd+1.05)*100+.5)/100
|
||||
value[3] = floor((.25*rnd+1.1)*100+.5)/100
|
||||
p = floor(10*rnd)+1
|
||||
if p <= 2 then
|
||||
print "You were attacked by a party of Iroquois."
|
||||
print "All people in your trading group were"
|
||||
print "killed. This ends the game."
|
||||
globals.gameOver = true
|
||||
return
|
||||
else if p<=6 then
|
||||
print "You were lucky. You arrived safely"
|
||||
print "at Fort New York."
|
||||
else if p<=8 then
|
||||
for j in range(0,3); furs[j] = 0; end for
|
||||
print "You narrowly escaped an iroquois raiding party."
|
||||
print "However, you had to leave all your furs behind."
|
||||
else
|
||||
value[1] /= 2
|
||||
value[0] /= 2
|
||||
print "Your mink and beaver were damaged on your trip."
|
||||
print "You receive only half the current price for these furs."
|
||||
end if
|
||||
print "Supplies at New York cost $80.00."
|
||||
print "Your travel expenses to New York were $25.00."
|
||||
globals.money -= 80 + 25
|
||||
end if
|
||||
end function
|
||||
|
||||
printInstructions
|
||||
|
||||
gameOver = false
|
||||
money=600
|
||||
while not gameOver
|
||||
print "Do you wish to trade furs?"
|
||||
if getYesNo == "NO" then break
|
||||
|
||||
value[2]=floor((.15*rnd+.95)*100+.5)/100 // ermine value
|
||||
value[1]=floor((.25*rnd+1.00)*100+.5)/100 // beaver value
|
||||
|
||||
print
|
||||
print "You have $" + money + " savings."
|
||||
print "And 190 furs to begin the expedition."
|
||||
print
|
||||
print "Your 190 furs are distributed among the following"
|
||||
print "kinds of pelts: mink, beaver, ermine and fox."
|
||||
print
|
||||
furs = [0,0,0,0]
|
||||
for j in range(0, 3)
|
||||
furs[j] = input("How many " + furNames[j] + " do you have? ").val
|
||||
if furs.sum >= 190 then break
|
||||
end for
|
||||
if furs.sum > 190 then
|
||||
print "You may not have that many furs."
|
||||
print "Do not try to cheat. I can add."
|
||||
print "You must start again."
|
||||
continue
|
||||
end if
|
||||
|
||||
fort = pickFort
|
||||
visitFort fort
|
||||
if gameOver then break
|
||||
|
||||
print
|
||||
for j in [1, 3, 2, 0]
|
||||
if not furs[j] then continue
|
||||
revenue = value[j] * furs[j]
|
||||
print "Your " + furNames[j] + " sold for $" + revenue + "."
|
||||
money += revenue
|
||||
end for
|
||||
print
|
||||
print "You now have $" + money + " including your previous savings."
|
||||
end while
|
||||
|
||||
|
||||
@@ -15,6 +15,10 @@ As published in Basic Computer Games (1978):
|
||||
Downloaded from Vintage Basic at
|
||||
http://www.vintage-basic.net/games.html
|
||||
|
||||
#### Known Bugs
|
||||
|
||||
- The value of some furs are not changed from the previous fort when you select fort 2 or 3. As a result, you will get a different value for your firs depending on whether you have previously visited a different fort. (All fur values are set when you visit Fort 1.)
|
||||
|
||||
#### Porting Notes
|
||||
|
||||
(please note any difficulties or challenges in porting here)
|
||||
|
||||
Reference in New Issue
Block a user