mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-12 15:50:20 -08:00
Ported 66_Number to MiniScript
This commit is contained in:
3
00_Alternate_Languages/66_Number/MiniScript/README.md
Normal file
3
00_Alternate_Languages/66_Number/MiniScript/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
|
||||
|
||||
Conversion to [MiniScript](https://miniscript.org).
|
||||
44
00_Alternate_Languages/66_Number/MiniScript/number.ms
Normal file
44
00_Alternate_Languages/66_Number/MiniScript/number.ms
Normal file
@@ -0,0 +1,44 @@
|
||||
// Number Game
|
||||
// originally by Tom Adametx
|
||||
// Ported from BASIC to MiniScript by Joe Strout, 2023
|
||||
|
||||
print " "*33 + "NUMBER"
|
||||
print " "*15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||
print; print; print
|
||||
|
||||
print "You have 100 points. By guessing numbers from 1 to 5, you"
|
||||
print "can gain or lose points depending on how close you get to"
|
||||
print "a random number selected by the computer."; print
|
||||
print "You occasionally will get a jackpot which will double(!)"
|
||||
print "your point count. You win when you get to 500 points."
|
||||
print
|
||||
|
||||
P = 100
|
||||
fnr = function; return ceil(5*rnd); end function
|
||||
while true
|
||||
guess = input("Guess a number from 1 to 5: ").val
|
||||
R = fnr
|
||||
S = fnr
|
||||
T = fnr
|
||||
U = fnr
|
||||
V = fnr
|
||||
if guess == R then
|
||||
P = P - 5
|
||||
else if guess == S then
|
||||
P = P + 5
|
||||
else if guess == T then
|
||||
P = P+P
|
||||
print "You hit the jackpot!!!"
|
||||
else if guess == U then
|
||||
P = P + 1
|
||||
else if guess == V then
|
||||
P = P - floor(P*0.5)
|
||||
else if guess > 5 then
|
||||
continue
|
||||
end if
|
||||
if P > 500 then
|
||||
print "!!!!You win!!!! with " + P + " points."
|
||||
exit
|
||||
end if
|
||||
print "You have " + P + " points."; print
|
||||
end while
|
||||
@@ -15,4 +15,4 @@ http://www.vintage-basic.net/games.html
|
||||
|
||||
#### Porting Notes
|
||||
|
||||
(please note any difficulties or challenges in porting here)
|
||||
Contrary to the description, the computer picks *five* random numbers per turn, not one. You are not rewarded based on how close your guess is to one number, but rather to which of these five random numbers (if any) it happens to match exactly.
|
||||
|
||||
Reference in New Issue
Block a user