-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added MiniScript version of 08_Batnum; also updated a couple of READMEs.
- Loading branch information
Showing
4 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 batnum.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 "batnum" | ||
run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
print " "*33 + "Batnum" | ||
print " "*15 + "Creative Computing Morristown, New Jersey" | ||
print; print; print | ||
print "This program is a 'Battle of Numbers' game, where the" | ||
print "computer is your opponent." | ||
print "The game starts with an assumed pile of objects. You" | ||
print "and your opponent alternately remove objects from the pile." | ||
print "Winning is defined in advance as taking the last object or" | ||
print "not. You can also specify some other beginning conditions." | ||
print "Don't use zero, however, in playing the game." | ||
print "Enter a negative number for new pile size to stop playing." | ||
|
||
options = {} | ||
getOptions = function | ||
while true | ||
options.pileSize = input("Enter pile size? ").val | ||
if options.pileSize != 0 and options.pileSize == floor(options.pileSize) then break | ||
end while | ||
if options.pileSize < 0 then return | ||
|
||
while true | ||
winOption = input("Enter win option - 1 to take last, 2 to avoid last: ") | ||
if winOption == "1" or winOption == "2" then break | ||
end while | ||
options.takeLast = (winOption == "1") | ||
|
||
while true | ||
minMax = input("Enter min and max? ").replace(",", " ").split | ||
if minMax.len < 2 then continue | ||
options.minTake = minMax[0].val | ||
options.maxTake = minMax[-1].val | ||
if options.minTake >= 1 and options.minTake < options.maxTake then break | ||
end while | ||
|
||
while true | ||
startOpt = input("Enter start option - 1 computer first, 2 you first: ") | ||
if startOpt == "1" or startOpt == "2" then break | ||
end while | ||
options.computerFirst = (startOpt == "1") | ||
end function | ||
|
||
computerTurn = function | ||
// Random computer play (not in original program): | ||
take = options.minTake + floor(rnd * (options.maxTake - options.minTake)) | ||
|
||
// Proper (smart) computer play | ||
q = pile | ||
if not options.takeLast then q -= 1 | ||
take = q % (options.minTake + options.maxTake) | ||
if take < options.minTake then take = options.minTake | ||
if take > options.maxTake then take = options.maxTake | ||
|
||
if take >= pile then | ||
if options.takeLast then | ||
print "Computer takes " + pile + " and wins." | ||
else | ||
print "Computer takes " + pile + " and loses." | ||
end if | ||
globals.gameOver = true | ||
else | ||
globals.pile -= take | ||
print "Computer takes " + take + " and leaves " + pile | ||
end if | ||
end function | ||
|
||
playerTurn = function | ||
while true | ||
print; take = input("Your move? ").val | ||
if take == 0 then | ||
print "I told you not to use zero! Computer wins by forfeit." | ||
globals.gameOver = true | ||
return | ||
end if | ||
if options.minTake <= take <= options.maxTake and take <= pile then break | ||
print "Illegal move, reenter it" | ||
end while | ||
if take >= pile then | ||
if options.takeLast then | ||
print "Congratulations, you win." | ||
else | ||
print "Tough luck, you lose." | ||
end if | ||
globals.gameOver = true | ||
else | ||
globals.pile -= take | ||
//print "You take " + take + ", leaving " + pile // (not in original program) | ||
end if | ||
end function | ||
|
||
while true | ||
getOptions | ||
if options.pileSize < 0 then break | ||
pile = options.pileSize | ||
gameOver = false | ||
|
||
print; print | ||
|
||
if options.computerFirst then computerTurn | ||
while not gameOver | ||
playerTurn | ||
if gameOver then break | ||
computerTurn | ||
end while | ||
|
||
for i in range(1,10); print; end for | ||
end while | ||
print "OK, bye!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters