Skip to content

Commit

Permalink
Added MiniScript version of 08_Batnum; also updated a couple of READMEs.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeStrout committed Jul 12, 2023
1 parent 82fd99b commit 85ee2c3
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 1 deletion.
16 changes: 16 additions & 0 deletions 00_Alternate_Languages/08_Batnum/MiniScript/README.md
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
109 changes: 109 additions & 0 deletions 00_Alternate_Languages/08_Batnum/MiniScript/batnum.ms
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
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."
print

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!"
4 changes: 4 additions & 0 deletions 08_Batnum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ As published in Basic Computer Games (1978):
Downloaded from Vintage Basic at
http://www.vintage-basic.net/games.html

#### Known Bugs

- Though the instructions say "Enter a negative number for new pile size to stop playing," this does not actually work.

#### Porting Notes

(please note any difficulties or challenges in porting here)
Expand Down
2 changes: 1 addition & 1 deletion 09_Battle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The first thing you should learn is how to locate and designate positions on the

The second thing you should learn about is the splash/hit ratio. “What is a ratio?” A good reply is “It’s a fraction or quotient.” Specifically, the spash/hit ratio is the number of splashes divided by the number of hits. If you had 9 splashes and 15 hits, the ratio would be 9/15 or 3/5, both of which are correct. The computer would give this splash/hit ratio as .6.

The main objective and primary education benefit of BATTLE comes from attempting to decode the bas guys’ fleet disposition code. To do this, you must make a comparison between the coded matrix and the actual matrix which you construct as you play the game.
The main objective and primary education benefit of BATTLE comes from attempting to decode the bad guys’ fleet disposition code. To do this, you must make a comparison between the coded matrix and the actual matrix which you construct as you play the game.

The original author of both the program and these descriptive notes is Ray Westergard of Lawrence Hall of Science, Berkeley, California.

Expand Down

0 comments on commit 85ee2c3

Please sign in to comment.