mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-12 15:50:20 -08:00
Merge branch 'coding-horror:main' into main
This commit is contained in:
@@ -7,10 +7,13 @@ 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 aceyducey.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "aceyducey"
|
||||
run
|
||||
```
|
||||
@@ -7,12 +7,15 @@ 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 amazing.ms
|
||||
|
||||
```
|
||||
Note that because this program imports "listUtil", you will need to have a the standard MiniScript libraries somewhere in your import path.
|
||||
|
||||
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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "amazing"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 animal.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "animal"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 awari.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "awari"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 bagels.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "bagels"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 banner.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "banner"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 basketball.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "basketball"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "batnum"
|
||||
run
|
||||
```
|
||||
@@ -9,10 +9,13 @@ 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 battle.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "battle"
|
||||
run
|
||||
```
|
||||
@@ -7,12 +7,15 @@ 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 blackjack.ms
|
||||
|
||||
```
|
||||
But note that the current release (1.2.1) of command-line MiniScript does not properly flush the output buffer when line breaks are suppressed, as this program does when prompting for your next action after a Hit. So, method 2 (below) is recommended for now.
|
||||
|
||||
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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "blackjack"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 bombardment.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "bombardment"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 bombsaway.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "bombsaway"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 bounce.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "bounce"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 bowling.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "bowling"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 boxing.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "boxing"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 bug.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "bug"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 bull.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "bull"
|
||||
run
|
||||
```
|
||||
@@ -10,10 +10,13 @@ Go to https://miniscript.org/tryit/, clear the sample code from the code editor,
|
||||
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 bullseye.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "bullseye"
|
||||
run
|
||||
```
|
||||
@@ -10,10 +10,13 @@ Go to https://miniscript.org/tryit/, clear the sample code from the code editor,
|
||||
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 bunny.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "bunny"
|
||||
run
|
||||
```
|
||||
@@ -10,10 +10,13 @@ Go to https://miniscript.org/tryit/, clear the sample code from the code editor,
|
||||
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 bunny.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "bunny"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 calendar.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "calendar"
|
||||
run
|
||||
```
|
||||
@@ -10,10 +10,13 @@ Go to https://miniscript.org/tryit/, clear the sample code from the code editor,
|
||||
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 change.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "change"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 checkers.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "checkers"
|
||||
run
|
||||
```
|
||||
@@ -10,10 +10,13 @@ Go to https://miniscript.org/tryit/, clear the sample code from the code editor,
|
||||
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 chemist.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "chemist"
|
||||
run
|
||||
```
|
||||
@@ -12,10 +12,13 @@ Go to https://miniscript.org/tryit/, clear the sample code from the code editor,
|
||||
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 chief.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "chief"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 chomp.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "chomp"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 civilwar.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "civilwar"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 combat.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "combat"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 craps.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "craps"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 cube.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "cube"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 depthcharge.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "depthcharge.ms"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 diamond.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "diamond"
|
||||
run
|
||||
```
|
||||
@@ -7,13 +7,15 @@ 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 dice.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "dice"
|
||||
run
|
||||
|
||||
```
|
||||
3. "Try-It!" page on the web:
|
||||
Go to https://miniscript.org/tryit/, clear the default program from the source code editor, paste in the contents of dice.ms, and click the "Run Script" button.
|
||||
|
||||
@@ -7,10 +7,13 @@ 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 digits.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "digits"
|
||||
run
|
||||
```
|
||||
@@ -9,20 +9,25 @@ 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 evenwins.ms
|
||||
|
||||
```
|
||||
or
|
||||
|
||||
```
|
||||
miniscript gameofevenwins.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "evenwins"
|
||||
run
|
||||
|
||||
```
|
||||
or
|
||||
|
||||
```
|
||||
load "gameofevenwins"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 flipflop.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "flipflop"
|
||||
run
|
||||
```
|
||||
@@ -7,19 +7,23 @@ 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
|
||||
```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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "football"
|
||||
run
|
||||
or
|
||||
```or
|
||||
```
|
||||
load "ftball"
|
||||
run
|
||||
|
||||
```
|
||||
|
||||
#### Apology from the Translator
|
||||
|
||||
|
||||
@@ -7,10 +7,13 @@ 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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "furtrader"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 golf.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "golf"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 gomoko.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "gomoko"
|
||||
run
|
||||
```
|
||||
@@ -7,13 +7,15 @@ 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 guess.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "guess"
|
||||
run
|
||||
|
||||
```
|
||||
3. "Try-It!" page on the web:
|
||||
Go to https://miniscript.org/tryit/, clear the default program from the source code editor, paste in the contents of guess.ms, and click the "Run Script" button.
|
||||
|
||||
@@ -7,10 +7,13 @@ 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 gunner.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "gunner"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 hammurabi.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "hammurabi"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 hangman.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "hangman"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 hello.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "hello"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 hexapawn.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "hexapawn"
|
||||
run
|
||||
```
|
||||
@@ -10,10 +10,13 @@ Go to https://miniscript.org/tryit/, clear the sample code from the code editor,
|
||||
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 hi-lo.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "hi-lo"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 highiq.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "highiq"
|
||||
run
|
||||
```
|
||||
@@ -7,10 +7,13 @@ 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 hockey.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "hockey"
|
||||
run
|
||||
```
|
||||
25
00_Alternate_Languages/50_Horserace/MiniScript/README.md
Normal file
25
00_Alternate_Languages/50_Horserace/MiniScript/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
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 horserace.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "horserace"
|
||||
run
|
||||
```
|
||||
|
||||
## Porting Notes
|
||||
|
||||
- The original program, designed to be played directly on a printer, drew a track 27 rows long. To fit better on modern screens, I've shortened the track to 23 rows. This is adjustable via the "trackLen" value assigned on line 72.
|
||||
|
||||
- Also because we're playing on a screen instead of a printer, I'm clearing the screen and pausing briefly before each new update of the track. This is done via the `clear` API when running in Mini Micro, or by using a VT100 escape sequence in other contexts.
|
||||
149
00_Alternate_Languages/50_Horserace/MiniScript/horserace.ms
Normal file
149
00_Alternate_Languages/50_Horserace/MiniScript/horserace.ms
Normal file
@@ -0,0 +1,149 @@
|
||||
print " "*31 + "Horserace"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
|
||||
print "Welcome to South Portland High Racetrack"
|
||||
print " ...owned by Laurie Chevalier"
|
||||
|
||||
// show directions, if wanted
|
||||
x = input("Do you want directions? ").lower
|
||||
if not x or x[0] != "n" then
|
||||
print "Up to 10 may play. A table of odds will be printed. You"
|
||||
print "may bet any + amount under 100000 on one horse."
|
||||
print "During the race, a horse will be shown by its"
|
||||
print "number. The horses race down the paper!"
|
||||
print
|
||||
end if
|
||||
|
||||
// get player names
|
||||
qtyPlayers = input("How many want to bet? ").val
|
||||
if qtyPlayers < 1 then exit
|
||||
print "When ? appears, type name"
|
||||
playerNames = [null]
|
||||
for i in range(1, qtyPlayers)
|
||||
playerNames.push input("?")
|
||||
end for
|
||||
print
|
||||
pick = [null] + [0]*qtyPlayers
|
||||
bet = [null] + [0]*qtyPlayers
|
||||
|
||||
d = [0] * 9 // odds denominator
|
||||
r = 0 // odds numerator
|
||||
|
||||
printInColumns = function(col0, col1, col2)
|
||||
print (col0+" "*16)[16] + (col1+" "*10)[:10] + (col2+" "*10)[:10]
|
||||
end function
|
||||
|
||||
setup = function
|
||||
// initialize the horses
|
||||
globals.names = [null] +
|
||||
"Joe Maw,L.B.J.,Mr.Washburn,Miss Karen,Jolly,Horse,Jelly Do Not,Midnight".split(",")
|
||||
for i in range(1,8)
|
||||
d[i] = floor(10*rnd+1)
|
||||
end for
|
||||
globals.r = d.sum
|
||||
|
||||
// print odds table
|
||||
printInColumns "Horse", "Number", "Odds"
|
||||
for i in range(1,8)
|
||||
printInColumns names[i], i, round(r/d[i],2) + ":1"
|
||||
end for
|
||||
|
||||
// get the players' bets
|
||||
print "--------------------------------------------------"
|
||||
print "Place your bets...Horse # then Amount"
|
||||
for j in range(1, qtyPlayers)
|
||||
while true
|
||||
s = input(playerNames[j] + "? ").replace(",", " ").split
|
||||
if s.len < 2 then s.push -1
|
||||
pick[j] = s[0].val
|
||||
bet[j] = s[-1].val
|
||||
if pick[j] < 1 or pick[j] > 8 or bet[j] < 1 or bet[j] >=100000 then
|
||||
print "You can't do that!"
|
||||
else
|
||||
break
|
||||
end if
|
||||
end while
|
||||
end for
|
||||
end function
|
||||
|
||||
// Draw a racetrack, with each horse the given number
|
||||
// of lines down from START to FINISH.
|
||||
trackLen = 23
|
||||
drawTrack = function(horsePositions)
|
||||
print
|
||||
if version.hostName == "Mini Micro" then clear else print char(27)+"c"
|
||||
if horsePositions[1] == 0 then print "1 2 3 4 5 6 7 8" else print
|
||||
print "XXXXSTARTXXXX"
|
||||
for row in range(1, trackLen)
|
||||
for h in range(1,8)
|
||||
p = horsePositions[h]
|
||||
if p > trackLen then p = trackLen
|
||||
if p == row then print h, " "
|
||||
end for
|
||||
print
|
||||
end for
|
||||
print "XXXXFINISHXXXX", ""
|
||||
if version.hostName != "Mini Micro" then print
|
||||
end function
|
||||
|
||||
runRace = function
|
||||
pos = [0]*9
|
||||
maxPos = 0
|
||||
while true
|
||||
drawTrack pos
|
||||
wait 1
|
||||
if maxPos >= trackLen then break
|
||||
for i in range(1,8)
|
||||
q = floor(100*rnd+1)
|
||||
x = floor(r/d[i]+0.5)
|
||||
if q < 10 then
|
||||
speed = 1
|
||||
else if q < x+17 then
|
||||
speed = 2
|
||||
else if q < x+37 then
|
||||
speed = 3
|
||||
else if q < x+57 then
|
||||
speed = 4
|
||||
else if q < x+77 then
|
||||
speed = 5
|
||||
else if q < x+92 then
|
||||
speed = 6
|
||||
else
|
||||
speed = 7
|
||||
end if
|
||||
pos[i] += speed
|
||||
if pos[i] > maxPos then maxPos = pos[i]
|
||||
end for
|
||||
end while
|
||||
|
||||
print
|
||||
print "---------------------------------------------"
|
||||
print
|
||||
print "The race results are:"
|
||||
results = []
|
||||
for i in range(1,8)
|
||||
results.push {"num":i, "pos":pos[i]}
|
||||
end for
|
||||
results.sort "pos", false
|
||||
for place in range(1, 8)
|
||||
h = results[place-1].num
|
||||
print " " + place + " Place Horse No. " + h + " at " + round(r/d[h],2) + ":1"
|
||||
print
|
||||
end for
|
||||
for p in range(1, qtyPlayers)
|
||||
if pick[p] == results[0].num then
|
||||
print playerNames[p] + " wins $" + round((r/d[pick[p]])*bet[p], 2)
|
||||
end if
|
||||
end for
|
||||
end function
|
||||
|
||||
// Main loop
|
||||
while true
|
||||
setup
|
||||
runRace
|
||||
print "Do you want to bet on the next race ?"
|
||||
yn = input("Yes or no? ").lower
|
||||
if not yn or yn[0] != "y" then break
|
||||
end while
|
||||
|
||||
22
00_Alternate_Languages/51_Hurkle/MiniScript/README.md
Normal file
22
00_Alternate_Languages/51_Hurkle/MiniScript/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
|
||||
|
||||
Conversion to [MiniScript](https://miniscript.org).
|
||||
|
||||
Ways to play:
|
||||
|
||||
0. Try-It! Page:
|
||||
Go to https://miniscript.org/tryit/, clear the sample code from the code editor, and paste in the contents of hurkle.ms. Then click the "Run Script" button. Program output (and input) will appear in the green-on-black terminal display to the right of or below the code editor.
|
||||
|
||||
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 hurkle.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "hurkle"
|
||||
run
|
||||
```
|
||||
56
00_Alternate_Languages/51_Hurkle/MiniScript/hurkle.ms
Normal file
56
00_Alternate_Languages/51_Hurkle/MiniScript/hurkle.ms
Normal file
@@ -0,0 +1,56 @@
|
||||
print " "*33 + "Hurcle"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
n = 5 // number of guesses allowed
|
||||
g = 10 // grid size
|
||||
print
|
||||
print "A hurkle is hiding on a " + g + " by " + g + " grid. Homebase"
|
||||
print "on the grid is point 0,0 in the southwest corner,"
|
||||
print "and any point on the grid is designated by a"
|
||||
print "pair of whole numbers seperated by a comma. The first"
|
||||
print "number is the horizontal position and the second number"
|
||||
print "is the vertical position. You must try to"
|
||||
print "guess the hurkle's gridpoint. You get " + n + "tries."
|
||||
print "After each try, I will tell you the approximate"
|
||||
print "direction to go to look for the hurkle."
|
||||
print
|
||||
|
||||
playOneGame = function
|
||||
a = floor(g*rnd)
|
||||
b = floor(g*rnd)
|
||||
for k in range(1, n)
|
||||
s = input("Guess #" + k + "? ").replace(",", " ").split
|
||||
x = s[0].val
|
||||
y = s[-1].val
|
||||
if x == a and y == b then
|
||||
print
|
||||
print "You found him in " + k + " guesses!"
|
||||
return
|
||||
end if
|
||||
if y == b then
|
||||
if x == a then
|
||||
print
|
||||
print "You found him in " + k + " guesses!"
|
||||
return
|
||||
else if x < a then
|
||||
dir = "east"
|
||||
else
|
||||
dir = "west"
|
||||
end if
|
||||
else if y < b then
|
||||
dir = "north"
|
||||
else
|
||||
dir = "south"
|
||||
end if
|
||||
print "Go " + dir
|
||||
end for
|
||||
print "Sorry, that's " + n + " guesses."
|
||||
print "The hurkle is at " + a + "," + b
|
||||
end function
|
||||
|
||||
while true
|
||||
playOneGame
|
||||
print
|
||||
print "Let's play again, hurkle is hiding."
|
||||
print
|
||||
end while
|
||||
@@ -7,13 +7,15 @@ 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 kinema.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "kinema"
|
||||
run
|
||||
|
||||
```
|
||||
3. "Try-It!" page on the web:
|
||||
Go to https://miniscript.org/tryit/, clear the default program from the source code editor, paste in the contents of kinema.ms, and click the "Run Script" button.
|
||||
|
||||
19
00_Alternate_Languages/53_King/MiniScript/README.md
Normal file
19
00_Alternate_Languages/53_King/MiniScript/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
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 king.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "king"
|
||||
run
|
||||
```
|
||||
403
00_Alternate_Languages/53_King/MiniScript/king.ms
Normal file
403
00_Alternate_Languages/53_King/MiniScript/king.ms
Normal file
@@ -0,0 +1,403 @@
|
||||
print " "*34 + "KING"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
|
||||
yearsRequired = 8
|
||||
rallods = floor(60000+(1000*rnd)-(1000*rnd))
|
||||
countrymen = floor(500+(10*rnd)-(10*rnd))
|
||||
landArea = 2000
|
||||
foreignWorkers = 0
|
||||
sellableLandExplained = false
|
||||
tourism = 0
|
||||
year = 0
|
||||
|
||||
zs = input("Do you want instructions? ").lower
|
||||
if zs == "again" then
|
||||
while true
|
||||
year = input("How many years had you been in office when interrupted? ").val
|
||||
if 0 <= year < yearsRequired then break
|
||||
print " Come on, your term in office is only " + yearsRequired + " years."
|
||||
end while
|
||||
rallods = input("How much did you have in the treasury? ").val
|
||||
countrymen = input("How many countrymen? ").val
|
||||
foreignWorkers = input("How many foreign workers? ").val
|
||||
while true
|
||||
landArea = input("How many square miles of land? ").val
|
||||
if 1000 <= landArea <= 2000 then break
|
||||
print " Come on, you started with 1000 sq. miles of farm land"
|
||||
print " and 1000 sq. miles of forest land."
|
||||
end while
|
||||
else if not zs or zs[0] != "n" then
|
||||
print; print; print
|
||||
print "Congratulations! You've just been elected premier of Setats"
|
||||
print "Detinu, a small communist island 30 by 70 miles long. Your"
|
||||
print "job is to decide upon the contry's budget and distribute"
|
||||
print "money to your countrymen from the communal treasury."
|
||||
print "The money system is rallods, and each person needs 100"
|
||||
print "rallods per year to survive. Your country's income comes"
|
||||
print "from farm produce and tourists visiting your magnificent"
|
||||
print "forests, hunting, fishing, etc. Half your land is farm land"
|
||||
print "which also has an excellent mineral content and may be sold"
|
||||
print "to foreign industry (strip mining) who import and support"
|
||||
print "their own workers. Crops cost between 10 and 15 rallods per"
|
||||
print "square mile to plant."
|
||||
print "Your goal is to complete your " + yearsRequired + " year term of office."
|
||||
print "Good luck!"
|
||||
end if
|
||||
|
||||
print
|
||||
|
||||
|
||||
// Bonus little feature when running in Mini Micro: display a status bar with
|
||||
// key game stats at the top of the screen.
|
||||
updateStatusBar = function
|
||||
if version.hostName != "Mini Micro" then return
|
||||
display(2).mode = displayMode.text; td = display(2)
|
||||
s = " Rallods: " + (rallods + " "*8)[:8]
|
||||
s += " Land: " + (landArea + " "*6)[:6]
|
||||
s += " Countrymen: " + (countrymen + " "*6)[:6]
|
||||
s += " Foreigners: " + (foreignWorkers + " "*5)[:5]
|
||||
td.color = color.black; td.backColor = text.color
|
||||
td.row = 25; td.column = 0; td.print s
|
||||
end function
|
||||
|
||||
min0 = function(x)
|
||||
if x < 0 then return 0 else return x
|
||||
end function
|
||||
floorMin0 = function(x)
|
||||
return min0(floor(x))
|
||||
end function
|
||||
stop = function
|
||||
updateStatusBar
|
||||
print; print; exit
|
||||
end function
|
||||
|
||||
while true
|
||||
landPrice = floor(10*rnd+95)
|
||||
plantingArea = 0
|
||||
pollutionControl = 0
|
||||
deaths = 0
|
||||
|
||||
print
|
||||
print "You now have " + rallods + " rallods in the treasury."
|
||||
print floor(countrymen) + " countrymen, ", ""
|
||||
costToPlant = floor(((rnd/2)*10+10))
|
||||
if foreignWorkers != 0 then
|
||||
print floor(foreignWorkers) + " foreign workers, ", ""
|
||||
end if
|
||||
print "and " + floor(landArea) + " sq. miles of land."
|
||||
print "This year industry will buy land for " + landPrice, ""
|
||||
print " rallods per square mile."
|
||||
print "Land currently costs " + costToPlant + " rallods per square mile to plant."
|
||||
print
|
||||
|
||||
updateStatusBar
|
||||
while true
|
||||
sellToIndustry = input("How many square miles do you wish to sell to industry? ").val
|
||||
if sellToIndustry < 0 then continue
|
||||
if sellToIndustry <= landArea-1000 then break
|
||||
print "*** Think again. You only have " + (landArea-1000) + " square miles of farm land."
|
||||
if not sellableLandExplained then
|
||||
print;print "(Foreign industry will only buy farm land because"
|
||||
print "forest land is uneconomical to strip mine due to trees,"
|
||||
print "thicker top soil, etc.)"
|
||||
sellableLandExplained = true
|
||||
end if
|
||||
end while
|
||||
landArea = floor(landArea-sellToIndustry)
|
||||
rallods = floor(rallods+(sellToIndustry*landPrice))
|
||||
|
||||
updateStatusBar
|
||||
while true
|
||||
welfare = input("How many rallods will you distribute among your countrymen? ").val
|
||||
if welfare < 0 then continue
|
||||
if welfare <= rallods then break
|
||||
print " Think again. You've only " + rallods + " rallods in the treasury"
|
||||
end while
|
||||
rallods = floor(rallods-welfare)
|
||||
|
||||
updateStatusBar
|
||||
while rallods > 0
|
||||
plantingArea = input("How many square miles do you wish to plant? ").val
|
||||
if plantingArea < 0 then continue
|
||||
if plantingArea > countrymen*2 then
|
||||
print " Sorry, but each countryman can only plant 2 sq. miles."
|
||||
continue
|
||||
end if
|
||||
if plantingArea > landArea-1000 then
|
||||
print " Sorry, but you've only " + (landArea-1000) + " sq. miles of farm land."
|
||||
continue
|
||||
end if
|
||||
plantingCost = floor(plantingArea * costToPlant)
|
||||
if plantingCost <= rallods then break
|
||||
print " Think again. You've only " + rallods + " rallods left in the treasury."
|
||||
end while
|
||||
rallods -= plantingCost
|
||||
|
||||
updateStatusBar
|
||||
while rallods > 0
|
||||
pollutionControl = input("How many rallods do you wish to spend on pollution control? ").val
|
||||
if pollutionControl < 0 then continue
|
||||
if pollutionControl <= rallods then break
|
||||
print " Think again. You only have " + rallods + " rallods remaining."
|
||||
end while
|
||||
|
||||
if sellToIndustry == 0 and welfare == 0 and plantingArea == 0 and pollutionControl == 0 then
|
||||
print
|
||||
print "Goodbye."
|
||||
print "(If you wish to continue this game at a later date, answer"
|
||||
print "'again' when asked if you want instructions at the start"
|
||||
print "of the game.)"
|
||||
exit
|
||||
end if
|
||||
|
||||
print
|
||||
print
|
||||
|
||||
rallods = floor(rallods-pollutionControl)
|
||||
updateStatusBar
|
||||
|
||||
original_rallods = rallods
|
||||
|
||||
starvationDeaths = floorMin0(countrymen - welfare/100)
|
||||
if starvationDeaths then
|
||||
if welfare/100 < 50 then
|
||||
print
|
||||
print
|
||||
print "Over one third of the popultation has died since you"
|
||||
print "were elected to office. The people (remaining)"
|
||||
print "hate your guts."
|
||||
if rnd > .5 then
|
||||
print "You have been thrown out of office and are now"
|
||||
print "residing in prison."
|
||||
else
|
||||
print "You have been assassinated."
|
||||
end if
|
||||
countrymen -= starvationDeaths
|
||||
stop
|
||||
end if
|
||||
print starvationDeaths + " countrymen died of starvation"
|
||||
end if
|
||||
|
||||
pollutionDeaths = floorMin0(rnd*(2000-landArea))
|
||||
if pollutionControl >= 25 then
|
||||
pollutionDeaths = floor(pollutionDeaths/(pollutionControl/25))
|
||||
end if
|
||||
if pollutionDeaths > 0 then
|
||||
print pollutionDeaths + " countrymen died of carbon-monoxide and dust inhalation"
|
||||
end if
|
||||
|
||||
deaths = starvationDeaths + pollutionDeaths
|
||||
if deaths then
|
||||
print " You were forced to spend " + floor(deaths*9), ""
|
||||
print " rallods on funeral expenses"
|
||||
rallods -= deaths * 9
|
||||
end if
|
||||
|
||||
if rallods < 0 then
|
||||
print " Insufficient reserves to cover cost - land was sold"
|
||||
landArea = floorMin0(landArea+(rallods/landPrice))
|
||||
rallods = 0
|
||||
end if
|
||||
|
||||
countrymen = min0(countrymen - deaths)
|
||||
|
||||
if sellToIndustry then
|
||||
newForeigners = floor(sellToIndustry+(rnd*10)-(rnd*20))
|
||||
if foreignWorkers == 0 then newForeigners += 20
|
||||
foreignWorkers += newForeigners
|
||||
print newForeigners + " workers came to the country and ", ""
|
||||
end if
|
||||
|
||||
immigration = floor(((welfare/100-countrymen)/10)+(pollutionControl/25)-((2000-landArea)/50)-(pollutionDeaths/2))
|
||||
print abs(immigration) + " countrymen ", ""
|
||||
if immigration < 0 then print "came to", "" else print "left", ""
|
||||
print " the island."
|
||||
countrymen = floorMin0(countrymen + immigration)
|
||||
|
||||
cropLoss = floor(((2000-landArea)*((rnd+1.5)/2)))
|
||||
if cropLoss > plantingArea then cropLoss = plantingArea
|
||||
if foreignWorkers > 0 then print "Of " + floor(plantingArea) + " sq. miles planted,", ""
|
||||
print " you harvested " + floor(plantingArea-cropLoss) + " sq. miles of crops."
|
||||
if cropLoss then
|
||||
print " (Due to air and water pollution from foreign industry.)"
|
||||
end if
|
||||
agriculturalIncome = floor((plantingArea-cropLoss)*(landPrice/2))
|
||||
print "Making " + agriculturalIncome + " rallods."
|
||||
rallods += agriculturalIncome
|
||||
|
||||
v1 = floor(((countrymen-immigration)*22)+(rnd*500))
|
||||
v2 = floor((2000-landArea)*15)
|
||||
prevTourism = tourism
|
||||
tourism = abs(floor(v1-v2))
|
||||
print " You made " + tourism + " rallods from tourist trade."
|
||||
if v2 > 2 and tourism < prevTourism then
|
||||
print " Decrease because ", ""
|
||||
g1 = 10*rnd
|
||||
if g1 <= 2 then
|
||||
print "fish population has dwindled due to water pollution."
|
||||
else if g1 <= 4 then
|
||||
print "air pollution is killing game bird population."
|
||||
else if g1 <= 6 then
|
||||
print "mineral baths are being ruined by water pollution."
|
||||
else if g1 <= 8 then
|
||||
print "unpleasant smog is discouraging sun bathers."
|
||||
else
|
||||
print "hotels are looking shabby due to smog grit."
|
||||
end if
|
||||
end if
|
||||
rallods += tourism
|
||||
updateStatusBar
|
||||
|
||||
if deaths > 200 then
|
||||
print
|
||||
print
|
||||
print deaths + "countrymen died in one year!!!!!"
|
||||
print "due to this extreme mismanagement, you have not only"
|
||||
print "been impeached and thrown out of office, but you"
|
||||
m6 = floor(rnd*10)
|
||||
if m6 <= 3 then 1670
|
||||
if m6 <= 6 then 1680
|
||||
if m6 <= 10 then 1690
|
||||
print "also had your left eye gouged out!"
|
||||
goto 1590
|
||||
print "have also gained a very bad reputation."
|
||||
goto 1590
|
||||
print "have also been declared national fink."
|
||||
stop
|
||||
else if countrymen < 343 then
|
||||
print
|
||||
print
|
||||
print "Over one third of the popultation has died since you"
|
||||
print "were elected to office. The people (remaining)"
|
||||
print "hate your guts."
|
||||
if rnd > .5 then
|
||||
print "You have been thrown out of office and are now"
|
||||
print "residing in prison."
|
||||
else
|
||||
print "You have been assassinated."
|
||||
end if
|
||||
stop
|
||||
else if (original_rallods/100) > 5 and deaths - pollutionDeaths >= 2 then
|
||||
print
|
||||
print "Money was left over in the treasury which you did"
|
||||
print "not spend. As a result, some of your countrymen died"
|
||||
print "of starvation. The public is enraged and you have"
|
||||
print "been forced to either resign or commit suicide."
|
||||
print "The choice is yours."
|
||||
print "If you choose the latter, please turn off your computer"
|
||||
print "before proceeding."
|
||||
stop
|
||||
else if foreignWorkers > countrymen then
|
||||
print
|
||||
print
|
||||
print "The number of foreign workers has exceeded the number"
|
||||
print "of countrymen. As a minority, they have revolted and"
|
||||
print "taken over the country."
|
||||
if rnd > .5 then
|
||||
print "You have been thrown out of office and are now"
|
||||
print "residing in prison."
|
||||
else
|
||||
print "You have been assassinated."
|
||||
end if
|
||||
stop
|
||||
else if year == yearsRequired-1 then
|
||||
print
|
||||
print
|
||||
print "Congratulations!!!!!!!!!!!!!!!!!!"
|
||||
print "You have succesfully completed your " + yearsRequired + " year term"
|
||||
print "of office. You were, of course, extremely lucky, but"
|
||||
print "nevertheless, it's quite an achievement. Goodbye and good"
|
||||
print "luck - you'll probably need it if you're the type that"
|
||||
print "plays this game."
|
||||
stop
|
||||
end if
|
||||
|
||||
updateStatusBar
|
||||
wait
|
||||
year += 1
|
||||
end while
|
||||
|
||||
//print
|
||||
//print
|
||||
//print "the number of foreign workers has exceeded the number"
|
||||
//print "of countrymen. as a minority, they have revolted and"
|
||||
//print "taken over the country."
|
||||
//if rnd<=.5 then 1580
|
||||
//print "you have been thrown out of office and are now"
|
||||
//print "residing in prison."
|
||||
//goto 1590
|
||||
//print "you have been assassinated."
|
||||
//print
|
||||
//print
|
||||
//exit
|
||||
//print
|
||||
//print
|
||||
//print deaths + "countrymen died in one year!!!!!"
|
||||
//print "due to this extreme mismanagement, you have not only"
|
||||
//print "been impeached and thrown out of office, but you"
|
||||
//m6 = floor(rnd*10)
|
||||
//if m6 <= 3 then 1670
|
||||
//if m6 <= 6 then 1680
|
||||
//if m6 <= 10 then 1690
|
||||
//print "also had your left eye gouged out!"
|
||||
//goto 1590
|
||||
//print "have also gained a very bad reputation."
|
||||
//goto 1590
|
||||
//print "have also been declared national fink."
|
||||
//goto 1590
|
||||
//
|
||||
//print
|
||||
//print
|
||||
//print "over one third of the popultation has died since you"
|
||||
//print "were elected to office. the people (remaining)"
|
||||
//print "hate your guts."
|
||||
//goto 1570
|
||||
//if deaths-pollutionDeaths < 2 then 1515
|
||||
//print
|
||||
//print "money was left over in the treasury which you did"
|
||||
//print "not spend. as a result, some of your countrymen died"
|
||||
//print "of starvation. the public is enraged and you have"
|
||||
//print "been forced to either resign or commit suicide."
|
||||
//print "the choice is yours."
|
||||
//print "if you choose the latter, please turn off your computer"
|
||||
//print "before proceeding."
|
||||
//goto 1590
|
||||
//print
|
||||
//print
|
||||
//print "congratulations!!!!!!!!!!!!!!!!!!"
|
||||
//print "you have succesfully completed your" + yearsRequired + "year term"
|
||||
//print "of office. you were, of course, extremely lucky, but"
|
||||
//print "nevertheless, it's quite an achievement. goodbye and good"
|
||||
//print "luck - you'll probably need it if you're the type that"
|
||||
//print "plays this game."
|
||||
//goto 1590
|
||||
//
|
||||
//print "how many years had you been in office when interrupted";
|
||||
//input year
|
||||
//if year < 0 then 1590
|
||||
//if year < 8 then 1969
|
||||
//print " come on, your term in office is only" + yearsRequired + "years."
|
||||
//goto 1960
|
||||
//print "how much did you have in the treasury";
|
||||
//input rallods
|
||||
//if rallods < 0 then 1590
|
||||
//print "how many countrymen";
|
||||
//input countrymen
|
||||
//if countrymen < 0 then 1590
|
||||
//print "how many workers";
|
||||
//input foreignWorkers
|
||||
//if foreignWorkers < 0 then 1590
|
||||
//print "how many square miles of land";
|
||||
//input landArea
|
||||
//if landArea < 0 then 1590
|
||||
//if landArea > 2000 then 1996
|
||||
//if landArea > 1000 then 100
|
||||
//print " come on, you started with 1000 sq. miles of farm land"
|
||||
//print " and 10,000 sq. miles of forest land."
|
||||
//goto 1990
|
||||
//
|
||||
//year = year+1
|
||||
//deaths = 0
|
||||
//goto 100
|
||||
//end
|
||||
@@ -8,7 +8,7 @@
|
||||
11 IF Z$="AGAIN" THEN 1960
|
||||
12 PRINT:PRINT:PRINT
|
||||
20 PRINT "CONGRATULATIONS! YOU'VE JUST BEEN ELECTED PREMIER OF SETATS"
|
||||
22 PRINT "DETINU, RALLODS SMALL COMMUNIST ISLAND 30 BY 70 MILES LONG. YOUR"
|
||||
22 PRINT "DETINU, A SMALL COMMUNIST ISLAND 30 BY 70 MILES LONG. YOUR"
|
||||
24 PRINT "JOB IS TO DECIDE UPON THE CONTRY'S BUDGET AND DISTRIBUTE"
|
||||
26 PRINT "MONEY TO YOUR COUNTRYMEN FROM THE COMMUNAL TREASURY."
|
||||
28 PRINT "THE MONEY SYSTEM IS RALLODS, AND EACH PERSON NEEDS 100"
|
||||
@@ -219,7 +219,7 @@ REM I think tourism calculations are actually wrong in the original code!
|
||||
1505 IF COUNTRYMEN<343 THEN 1700
|
||||
1510 IF (ORIGINAL_RALLODS/100)>5 THEN 1800
|
||||
1515 IF FOREIGN_WORKERS>COUNTRYMEN THEN 1550
|
||||
1520 IF YEARS_REQUIRED-1=X5 THEN 1900
|
||||
1520 IF YEARS_REQUIRED-1=YEAR THEN 1900
|
||||
1545 GOTO 2000
|
||||
1550 PRINT
|
||||
1552 PRINT
|
||||
@@ -277,9 +277,9 @@ REM I think tourism calculations are actually wrong in the original code!
|
||||
1950 GOTO 1590
|
||||
|
||||
1960 PRINT "HOW MANY YEARS HAD YOU BEEN IN OFFICE WHEN INTERRUPTED";
|
||||
1961 INPUT X5
|
||||
1962 IF X5<0 THEN 1590
|
||||
1963 IF X5<8 THEN 1969
|
||||
1961 INPUT YEAR
|
||||
1962 IF YEAR<0 THEN 1590
|
||||
1963 IF YEAR<8 THEN 1969
|
||||
1965 PRINT " COME ON, YOUR TERM IN OFFICE IS ONLY";YEARS_REQUIRED;"YEARS."
|
||||
1967 GOTO 1960
|
||||
1969 PRINT "HOW MUCH DID YOU HAVE IN THE TREASURY";
|
||||
@@ -300,7 +300,7 @@ REM I think tourism calculations are actually wrong in the original code!
|
||||
1997 PRINT " AND 10,000 SQ. MILES OF FOREST LAND."
|
||||
1998 GOTO 1990
|
||||
|
||||
2000 X5=X5+1
|
||||
2000 YEAR=YEAR+1
|
||||
2020 DEATHS=0
|
||||
2040 GOTO 100
|
||||
2046 END
|
||||
|
||||
@@ -7,13 +7,15 @@ 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 letter.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "letter"
|
||||
run
|
||||
|
||||
```
|
||||
3. "Try-It!" page on the web:
|
||||
Go to https://miniscript.org/tryit/, clear the default program from the source code editor, paste in the contents of letter.ms, and click the "Run Script" button.
|
||||
|
||||
19
00_Alternate_Languages/55_Life/MiniScript/README.md
Normal file
19
00_Alternate_Languages/55_Life/MiniScript/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
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 life.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "life"
|
||||
run
|
||||
```
|
||||
132
00_Alternate_Languages/55_Life/MiniScript/life.ms
Normal file
132
00_Alternate_Languages/55_Life/MiniScript/life.ms
Normal file
@@ -0,0 +1,132 @@
|
||||
print " "*34 + "LIFE"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
import "listUtil" // (needed for list.init2d)
|
||||
|
||||
maxx = 66 // (size adjusted for Mini Micro display)
|
||||
maxy = 23
|
||||
A = list.init2d(maxx+1, maxy+1, 0)
|
||||
|
||||
// Stuff the given pattern into the center of the cell array.
|
||||
// Return the number of live cells.
|
||||
stuffIntoCenter = function(pattern)
|
||||
maxLen = 0
|
||||
for p in pattern
|
||||
if p.len > maxLen then maxLen = p.len
|
||||
end for
|
||||
|
||||
population = 0
|
||||
y = floor(maxy/2 - pattern.len/2)
|
||||
for row in pattern
|
||||
x = floor(maxx/2 - maxLen/2)
|
||||
for c in row
|
||||
if c != " " then
|
||||
A[x][y] = 1
|
||||
population += 1
|
||||
end if
|
||||
x += 1
|
||||
end for
|
||||
y += 1
|
||||
end for
|
||||
return population
|
||||
end function
|
||||
|
||||
// Get the initial pattern from the user
|
||||
initToUserPattern = function
|
||||
print "Enter your pattern (enter DONE when done):"
|
||||
userPattern = []
|
||||
while true
|
||||
p = input("?")
|
||||
if p.upper == "DONE" then break
|
||||
if p and p[0] == "." then p = " " + p[1:]
|
||||
userPattern.push p
|
||||
end while
|
||||
return stuffIntoCenter(userPattern)
|
||||
end function
|
||||
|
||||
// For testing purposes, skip asking the user and just use a hard-coded pattern.
|
||||
initToStandardPattern = function
|
||||
pattern = [
|
||||
" **",
|
||||
" * *",
|
||||
" *"]
|
||||
return stuffIntoCenter(pattern)
|
||||
end function
|
||||
|
||||
// Or, just for fun, initialize to a random pattern of junk in the center.
|
||||
initRandom = function
|
||||
for x in range(ceil(maxx*0.3), floor(maxx*0.7))
|
||||
for y in range(ceil(maxy*0.3), floor(maxy*0.7))
|
||||
A[x][y] = rnd > 0.5
|
||||
end for
|
||||
end for
|
||||
end function
|
||||
|
||||
// Define a function to draw the current game state.
|
||||
// This also changes 2 (dying) to 0 (dead), and 3 (being born) to 1 (alive).
|
||||
drawGameState = function(generation=0, population=0, invalid=false)
|
||||
if version.hostName == "Mini Micro" then text.row = 26 else print
|
||||
print "Generation: " + generation + " Population: " + population +
|
||||
" " + "INVALID!" * invalid
|
||||
for y in range(0, maxy)
|
||||
s = ""
|
||||
for x in range(0, maxx)
|
||||
if A[x][y] == 2 then
|
||||
A[x][y] = 0
|
||||
else if A[x][y] == 3 then
|
||||
A[x][y] = 1
|
||||
end if
|
||||
if A[x][y] then s += "*" else s += " "
|
||||
end for
|
||||
print s
|
||||
end for
|
||||
end function
|
||||
|
||||
// Update the game state, setting cells that should be born to 3 and
|
||||
// cells that should die to 2. Return the number of cells that will
|
||||
// be alive after this update. Also, set globals.invalid if any live
|
||||
// cells are found on the edge of the map.
|
||||
updateGameState = function
|
||||
population = 0
|
||||
for x in range(0, maxx)
|
||||
for y in range(0, maxy)
|
||||
c = A[x][y] == 1 or A[x][y] == 2 // center state
|
||||
n = -c // number of neighbors
|
||||
for nx in range(x-1, x+1)
|
||||
if nx < 0 or nx > maxx then continue
|
||||
for ny in range(y-1, y+1)
|
||||
if ny < 0 or ny > maxy then continue
|
||||
n += A[nx][ny] == 1 or A[nx][ny] == 2
|
||||
end for
|
||||
end for
|
||||
if c and n != 2 and n != 3 then // live cell with < 2 or > 3 neighbors...
|
||||
A[x][y] = 2 // dies
|
||||
else if not c and n == 3 then // dead cell with 3 neighbors...
|
||||
A[x][y] = 3 // comes to life
|
||||
if x == 0 or x == maxx or y == 0 or y == maxy then
|
||||
globals.invalid = true
|
||||
end if
|
||||
end if
|
||||
population += (A[x][y] == 1 or A[x][y] == 3)
|
||||
end for
|
||||
end for
|
||||
return population
|
||||
end function
|
||||
|
||||
|
||||
// Initialize the game state (uncomment one of the following three lines)
|
||||
population = initToUserPattern
|
||||
//population = initToStandardPattern
|
||||
//population = initRandom
|
||||
|
||||
// Main loop
|
||||
if version.hostName == "Mini Micro" then clear
|
||||
invalid = false
|
||||
generation = 0
|
||||
while population > 0
|
||||
drawGameState generation, population, invalid
|
||||
population = updateGameState
|
||||
generation += 1
|
||||
//key.get // <-- Uncomment this to single-step with each keypress!
|
||||
end while
|
||||
drawGameState generation, population, invalid
|
||||
19
00_Alternate_Languages/56_Life_for_Two/MiniScript/README.md
Normal file
19
00_Alternate_Languages/56_Life_for_Two/MiniScript/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
|
||||
|
||||
Conversion to [MiniScript](https://miniscript.org). The only liberty I took with the original design is that, when prompting each player for their turn, I include a reminder of what symbol (* or #) represents their pieces on the board.
|
||||
|
||||
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 lifefortwo.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "lifefortwo"
|
||||
run
|
||||
```
|
||||
129
00_Alternate_Languages/56_Life_for_Two/MiniScript/lifefortwo.ms
Normal file
129
00_Alternate_Languages/56_Life_for_Two/MiniScript/lifefortwo.ms
Normal file
@@ -0,0 +1,129 @@
|
||||
print " "*33 + "LIFE2"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
print " "*10 + "U.B. LIFE GAME"
|
||||
|
||||
// N: counts neighbors and game state, as follows:
|
||||
// 1's digit: player 1 neighbors
|
||||
// 10's digit: player 2 neighbors
|
||||
// 100's digit: player 1 current live cell
|
||||
// 1000's digit: player 2 current live cell
|
||||
N = []
|
||||
for i in range(0,6); N.push [0]*7; end for
|
||||
|
||||
// K: encodes the rule for what cells come to life, based on
|
||||
// the value in N. The first 9 entries mean new life for Player 1;
|
||||
// the second 9 entries mean new life for Player 2.
|
||||
K = [3,102,103,120,130,121,112,111,12,
|
||||
21,30,1020,1030,1011,1021,1003,1002,1012]
|
||||
|
||||
// population: how many live cells each player (1-2) has
|
||||
population = [null, 0, 0]
|
||||
|
||||
// Function to get input coordinates from the player, for any empty space.
|
||||
// Where possible, hide the input so the other player can't see it.
|
||||
getCoords = function
|
||||
while true
|
||||
print "X,Y"
|
||||
inp = input.replace(",", " ").replace(" "," ")
|
||||
if version.hostName == "Mini Micro" then
|
||||
text.row = text.row + 1; print " "*60
|
||||
end if
|
||||
parts = inp.split
|
||||
if parts.len == 2 then
|
||||
x = parts[0].val
|
||||
y = parts[1].val
|
||||
if 0 < x <= 5 and 0 < y <= 5 and N[x][y] == 0 then break
|
||||
end if
|
||||
print "Illegal coords. Retype"
|
||||
end while
|
||||
return [x, y]
|
||||
end function
|
||||
|
||||
// Function to print the board. At the same time, it replaces
|
||||
// any player 1 value (as judged by list K) with 100, and any
|
||||
// player 2 value with 1000. Also update population[] with the
|
||||
// number of pieces of each player.
|
||||
printBoard = function
|
||||
population[1] = 0
|
||||
population[2] = 0
|
||||
for y in range(0, 6)
|
||||
if y == 0 or y == 6 then
|
||||
print " 0 1 2 3 4 5 0"
|
||||
else
|
||||
print " " + y, " "
|
||||
for x in range(1, 5)
|
||||
kIndex = K.indexOf(N[x][y])
|
||||
if kIndex == null then
|
||||
print " ", " "
|
||||
N[x][y] = 0
|
||||
else if kIndex < 9 then
|
||||
print "*", " "
|
||||
N[x][y] = 100
|
||||
population[1] += 1
|
||||
else
|
||||
print "#", " "
|
||||
N[x][y] = 1000
|
||||
population[2] += 1
|
||||
end if
|
||||
end for
|
||||
print y
|
||||
end if
|
||||
end for
|
||||
print
|
||||
end function
|
||||
|
||||
// Function to update the board (N).
|
||||
updateBoard = function
|
||||
for j in range(1,5)
|
||||
for k in range(1,5)
|
||||
if N[j][k] < 100 then continue // not a live cell
|
||||
if N[j][k] > 999 then value = 10 else value = 1
|
||||
for x in range(j-1, j+1)
|
||||
for y in range(k-1, k+1)
|
||||
if x == j and y == k then continue
|
||||
N[x][y] += value
|
||||
//if [x,y] == [2,1] then print "adding " + value + " from " + j+","+k + " to " + x+","+y + ", --> " + N[x][y]
|
||||
end for
|
||||
end for
|
||||
end for
|
||||
end for
|
||||
end function
|
||||
|
||||
|
||||
// Get initial player positions.
|
||||
for player in [1,2]
|
||||
print; print "Player " + player + " - 3 live pieces."
|
||||
if player == 2 then value = 30 else value = 3
|
||||
for k in range(1,3)
|
||||
pos = getCoords
|
||||
N[pos[0]][pos[1]] = value
|
||||
end for
|
||||
end for
|
||||
|
||||
printBoard
|
||||
while true
|
||||
updateBoard
|
||||
printBoard
|
||||
if population[1] == 0 and population[2] == 0 then
|
||||
print "A DRAW"
|
||||
break
|
||||
else if population[1] == 0 then
|
||||
print "PLAYER 2 IS THE WINNER"
|
||||
break
|
||||
else if population[2] == 0 then
|
||||
print "PLAYER 1 IS THE WINNER"
|
||||
break
|
||||
end if
|
||||
|
||||
print; print "Player 1 (*)"
|
||||
p1pos = getCoords
|
||||
print; print "Player 2 (#)"
|
||||
p2pos = getCoords
|
||||
if p1pos == p2pos then
|
||||
print "Same coord. Set to 0"
|
||||
else
|
||||
N[p1pos[0]][p1pos[1]] = 100
|
||||
N[p2pos[0]][p2pos[1]] = 1000
|
||||
end if
|
||||
end while
|
||||
@@ -0,0 +1,22 @@
|
||||
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
|
||||
|
||||
Conversion to [MiniScript](https://miniscript.org).
|
||||
|
||||
Ways to play:
|
||||
|
||||
0. Try-It! Page:
|
||||
Go to https://miniscript.org/tryit/, clear the sample code from the code editor, and paste in the contents of litquiz.ms. Then click the "Run Script" button. Program output (and input) will appear in the green-on-black terminal display to the right of or below the code editor.
|
||||
|
||||
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 litquiz.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "litquiz"
|
||||
run
|
||||
```
|
||||
@@ -0,0 +1,66 @@
|
||||
print " "*24 + "Literature Quiz"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
|
||||
r=0
|
||||
print "Test your knowledge of children's literature."
|
||||
print; print "This is a multiple-choice quiz."
|
||||
print "Type a 1, 2, 3, or 4 after the question mark."
|
||||
print; print "Good luck!";
|
||||
|
||||
print; print
|
||||
print "In pinocchio, what was the name of the cat?"
|
||||
print "1)Tigger, 2)Cicero, 3)Figaro, 4)Fuipetto";
|
||||
a = input("?").val
|
||||
if a!=3 then
|
||||
print "Sorry...Figaro was his name."
|
||||
else
|
||||
print "Very good! Here's another."
|
||||
r += 1
|
||||
end if
|
||||
|
||||
print; print
|
||||
print "From whose garden did Bugs Bunny steal the carrots?"
|
||||
print "1)Mr. Nixon's, 2)Elmer Fudd's, 3)Clem Judd's, 4)Stromboli's";
|
||||
a = input("?").val
|
||||
if a != 2 then
|
||||
print "Too bad...it was elmer fudd's garden."
|
||||
else
|
||||
print "Pretty good!"
|
||||
r += 1
|
||||
end if
|
||||
|
||||
print; print
|
||||
print "In the Wizard of Oz, Dorothy's dog was named"
|
||||
print "1)Cicero, 2)Trixia, 3)King, 4)Toto";
|
||||
a = input("?").val
|
||||
if a != 4 then
|
||||
print "Back to the books,...Toto was his name."
|
||||
else
|
||||
print "Yea! You're a real literature giant."
|
||||
r += 1
|
||||
end if
|
||||
|
||||
print;print
|
||||
print "Who was the fair maiden who ate the poison apple?"
|
||||
print "1)Sleeping Beauty, 2)Cinderella, 3)Snow White, 4)Wendy";
|
||||
a = input("?").val
|
||||
if a != 3 then
|
||||
print "Oh, come on now...it was Snow White."
|
||||
else
|
||||
print "Good memory!"
|
||||
r += 1
|
||||
end if
|
||||
|
||||
print;print
|
||||
if r == 4 then
|
||||
print "Wow! That's super! You really know your nursery"
|
||||
print "Your next quiz will be on 2nd century Chinese"
|
||||
print "literature (ha, ha, ha)"
|
||||
else if r<2 then
|
||||
print "Ugh. That was definitely not too swift. Back to"
|
||||
print "nursery school for you, my friend."
|
||||
else
|
||||
print "Not bad, but you might spend a little more time"
|
||||
print "reading the nursery greats."
|
||||
end if
|
||||
22
00_Alternate_Languages/58_Love/MiniScript/README.md
Normal file
22
00_Alternate_Languages/58_Love/MiniScript/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
|
||||
|
||||
Conversion to [MiniScript](https://miniscript.org).
|
||||
|
||||
Ways to play:
|
||||
|
||||
0. Try-It! Page:
|
||||
Go to https://miniscript.org/tryit/, clear the sample code from the code editor, and paste in the contents of love.ms. Then click the "Run Script" button. Program output (and input) will appear in the green-on-black terminal display to the right of or below the code editor.
|
||||
|
||||
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 love.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "love"
|
||||
run
|
||||
```
|
||||
41
00_Alternate_Languages/58_Love/MiniScript/love.ms
Normal file
41
00_Alternate_Languages/58_Love/MiniScript/love.ms
Normal file
@@ -0,0 +1,41 @@
|
||||
print " "*33 + "LOVE"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
|
||||
print "A tribute to the great american artist, Robert Indiana."
|
||||
print "His greatest work will be reproduced with a message of"
|
||||
print "your choice up to 60 characters. If you can't think of"
|
||||
print "a message, simple type the word 'LOVE'"; print
|
||||
msg = input("Your message, please? ")
|
||||
for i in range(1, 10); print; end for
|
||||
|
||||
repeatedMsg = msg * ceil(60 / msg.len)
|
||||
|
||||
data = []
|
||||
data += [60,1,12,26,9,12,3,8,24,17,8,4,6,23,21,6,4,6,22,12,5,6,5]
|
||||
data += [4,6,21,11,8,6,4,4,6,21,10,10,5,4,4,6,21,9,11,5,4]
|
||||
data += [4,6,21,8,11,6,4,4,6,21,7,11,7,4,4,6,21,6,11,8,4]
|
||||
data += [4,6,19,1,1,5,11,9,4,4,6,19,1,1,5,10,10,4,4,6,18,2,1,6,8,11,4]
|
||||
data += [4,6,17,3,1,7,5,13,4,4,6,15,5,2,23,5,1,29,5,17,8]
|
||||
data += [1,29,9,9,12,1,13,5,40,1,1,13,5,40,1,4,6,13,3,10,6,12,5,1]
|
||||
data += [5,6,11,3,11,6,14,3,1,5,6,11,3,11,6,15,2,1]
|
||||
data += [6,6,9,3,12,6,16,1,1,6,6,9,3,12,6,7,1,10]
|
||||
data += [7,6,7,3,13,6,6,2,10,7,6,7,3,13,14,10,8,6,5,3,14,6,6,2,10]
|
||||
data += [8,6,5,3,14,6,7,1,10,9,6,3,3,15,6,16,1,1]
|
||||
data += [9,6,3,3,15,6,15,2,1,10,6,1,3,16,6,14,3,1,10,10,16,6,12,5,1]
|
||||
data += [11,8,13,27,1,11,8,13,27,1,60]
|
||||
|
||||
for row in range(0, 35)
|
||||
s = []
|
||||
a1 = 0; p = true
|
||||
while a1 < 60
|
||||
a = data.pull
|
||||
a1 += a
|
||||
for i in range(a1-a, a1-1)
|
||||
s.push repeatedMsg[i] * p + " " * (not p)
|
||||
end for
|
||||
p = not p
|
||||
end while
|
||||
print s.join("")
|
||||
wait 0.1 // OPTIONAL; slows printing down so you can see it all
|
||||
end for
|
||||
@@ -0,0 +1,19 @@
|
||||
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
|
||||
|
||||
Conversion to [MiniScript](https://miniscript.org). Note that there are three different programs in this folder, all variations on the "land the LEM on the Moon" idea.
|
||||
|
||||
Ways to play:
|
||||
|
||||
1. Command-Line MiniScript:
|
||||
Download for your system from https://miniscript.org/cmdline/, install, and then run the desired program with a command such as:
|
||||
|
||||
```
|
||||
miniscript lem.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "lem" // (or "lunar" or "rocket")
|
||||
run
|
||||
```
|
||||
324
00_Alternate_Languages/59_Lunar_LEM_Rocket/MiniScript/lem.ms
Normal file
324
00_Alternate_Languages/59_Lunar_LEM_Rocket/MiniScript/lem.ms
Normal file
@@ -0,0 +1,324 @@
|
||||
print " "*34 + "LEM"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
// rockt2 is an interactive game that simulates a lunar
|
||||
// landing is similar to that of the apollo program.
|
||||
// There is absolutely no chance involved
|
||||
|
||||
|
||||
printIntro = function
|
||||
print
|
||||
print " You are on a lunar landing mission. as the pilot of"
|
||||
print "the lunar excursion module, you will be expected to"
|
||||
print "give certain commands to the module navigation system."
|
||||
print "The on-board computer will give a running account"
|
||||
print "of information needed to navigate the ship."
|
||||
print
|
||||
input "(Press Return.)"
|
||||
print
|
||||
print "The attitude angle called for is described as follows."
|
||||
print "+ or -180 degrees is directly away from the moon"
|
||||
print "-90 degrees is on a tangent in the direction of orbit"
|
||||
print "+90 degrees is on a tangent from the direction of orbit"
|
||||
print "0 (zero) degrees is directly toward the moon"
|
||||
print
|
||||
print " "*30 + "-180|+180"
|
||||
print " "*34 + "^"
|
||||
print " "*27 + "-90 < -+- > +90"
|
||||
print " "*34 + "!"
|
||||
print " "*34 + "0"
|
||||
print " "*21 + "<<<< direction of orbit <<<<"
|
||||
print
|
||||
print " "*20 + "------ surface of moon ------"
|
||||
print
|
||||
input
|
||||
print
|
||||
print "All angles between -180 and +180 degrees are accepted."
|
||||
print
|
||||
print "1 fuel unit = 1 sec. at max thrust"
|
||||
print "Any discrepancies are accounted for in the use of fuel"
|
||||
print "for an attitude change."
|
||||
print "Available engine power: 0 (zero) and any value between"
|
||||
print "10 and 100 percent."
|
||||
print
|
||||
print "Negative thrust or time is prohibited."
|
||||
print
|
||||
input
|
||||
end function
|
||||
|
||||
printInOutInfo = function(withExample = true)
|
||||
print
|
||||
print "Input: time interval in seconds ------ (T)"
|
||||
print " percentage of thrust ---------- (P)"
|
||||
print " attitude angle in degrees ----- (A)"
|
||||
print
|
||||
if withExample then
|
||||
print "For example:"
|
||||
print "T,P,A? 10,65,-60"
|
||||
print "To abort the mission at any time, enter 0,0,0"
|
||||
print
|
||||
end if
|
||||
print "Output: total time in elapsed seconds"
|
||||
print " height in " + ms
|
||||
print " distance from landing site in " + ms
|
||||
print " vertical velocity in " + ms + "/second"
|
||||
print " horizontal velocity in " + ms + "/second"
|
||||
print " fuel units remaining"
|
||||
print
|
||||
end function
|
||||
|
||||
initState = function
|
||||
globals.m = 17.95
|
||||
globals.f1 = 5.25
|
||||
globals.n = 7.5
|
||||
globals.r0 = 926
|
||||
globals.v0 = 1.29
|
||||
globals.t = 0
|
||||
globals.h0 = 60
|
||||
globals.r = r0+h0
|
||||
globals.a = -3.425
|
||||
globals.r1 = 0
|
||||
globals.a1 = 8.84361e-04
|
||||
globals.r3 = 0
|
||||
globals.a3 = 0
|
||||
globals.m1 = 7.45
|
||||
globals.m0 = m1
|
||||
globals.b = 750
|
||||
globals.t1 = 0
|
||||
globals.f = 0
|
||||
globals.p = 0
|
||||
globals.n = 1
|
||||
globals.m2 = 0
|
||||
globals.s = 0
|
||||
globals.c = 0
|
||||
end function
|
||||
|
||||
getUnits = function(moreHelp=true)
|
||||
print
|
||||
while true
|
||||
print "Input measurement option number? ", ""
|
||||
if moreHelp then
|
||||
print
|
||||
print "Which system of measurement do you prefer?"
|
||||
print " 1 = metric 0 = english"
|
||||
print "Enter the appropriate number? ", ""
|
||||
end if
|
||||
k = input.val
|
||||
if k == 0 then
|
||||
globals.z = 6080
|
||||
globals.ms = "feet"
|
||||
globals.g3 = .592
|
||||
globals.ns = "n.miles"
|
||||
globals.g5 = z
|
||||
break
|
||||
else if k == 1 then
|
||||
globals.z = 1852.8
|
||||
globals.ms="meters"
|
||||
globals.g3 = 3.6
|
||||
globals.ns=" kilometers"
|
||||
globals.g5 = 1000
|
||||
break
|
||||
end if
|
||||
moreHelp = true
|
||||
end while
|
||||
end function
|
||||
|
||||
startFirstGame = function
|
||||
initState
|
||||
print
|
||||
print "Lunar Landing Simulation"
|
||||
print
|
||||
print "Have you flown an Apollo/LEM mission before", ""
|
||||
while true
|
||||
qs = input(" (yes or no)? ").lower
|
||||
if qs and (qs[0] == "y" or qs[0] == "n") then break
|
||||
print "Just answer the question, please, ", ""
|
||||
end while
|
||||
getUnits (qs[0] == "n")
|
||||
if qs[0] == "n" then printIntro
|
||||
printInOutInfo
|
||||
end function
|
||||
|
||||
startSubsequentGame = function
|
||||
initState
|
||||
print
|
||||
print "OK, do you want the complete instructions or the input -"
|
||||
print "output statements?"
|
||||
while true
|
||||
print "1 = complete instructions"
|
||||
print "2 = input-output statements"
|
||||
print "3 = neither"
|
||||
b1 = input.val
|
||||
if 1 <= b1 <= 3 then break
|
||||
end while
|
||||
if b1 == 1 then printIntro
|
||||
if b1 < 3 then printInOutInfo
|
||||
end function
|
||||
|
||||
getTurnInputs = function
|
||||
while true
|
||||
print
|
||||
inp = input("T,P,A? ").replace(",", " ").replace(" ", " ").split
|
||||
if inp.len != 3 then continue
|
||||
globals.t1 = inp[0].val // NOTE: though we prompt for T, P, A,
|
||||
globals.f = inp[1].val // internally these are t1, f, and p respectively.
|
||||
globals.p = inp[2].val
|
||||
globals.f = f/100
|
||||
if t1 < 0 then
|
||||
print
|
||||
print "This spacecraft is not able to violate the space-";
|
||||
print "time continuum."
|
||||
continue
|
||||
else if t1 == 0 then
|
||||
return // abort mission
|
||||
end if
|
||||
if f < 0 or f > 1.05 or abs(f-.05) < .05 then
|
||||
print
|
||||
print "Impossible thrust value: ", ""
|
||||
if f < 0 then
|
||||
print "negative"
|
||||
else if f < 0.5 then
|
||||
print "too small"
|
||||
else
|
||||
print "too large"
|
||||
end if
|
||||
continue
|
||||
end if
|
||||
if abs(p) > 180 then
|
||||
print
|
||||
print "If you want to spin around, go outside the module"
|
||||
print "for an E.V.A."
|
||||
continue
|
||||
end if
|
||||
return
|
||||
end while
|
||||
end function
|
||||
|
||||
pad = function(num, width=10)
|
||||
anum = abs(num)
|
||||
if anum >= 10000 then
|
||||
s = round(num)
|
||||
else if anum >= 10000 then
|
||||
s = round(num, 1)
|
||||
else if anum > 100 then
|
||||
s = round(num, 2)
|
||||
else
|
||||
s = round(num, 3)
|
||||
end if
|
||||
return (s + " " * width)[:width]
|
||||
end function
|
||||
|
||||
integrate = function
|
||||
n = 20
|
||||
if t1 >= 400 then n = t1/20
|
||||
globals.t1 = t1/n
|
||||
globals.p = p*3.14159/180
|
||||
s = sin(p)
|
||||
c = cos(p)
|
||||
globals.m2 = m0*t1*f/b
|
||||
globals.r3 = -.5*r0*((v0/r)^2)+r*a1*a1
|
||||
globals.a3 = -2*r1*a1/r
|
||||
|
||||
for i in range(1, n)
|
||||
if m1 != 0 then
|
||||
globals.m1 = m1-m2
|
||||
if m1<=0 then
|
||||
globals.f = f*(1+m1/m2)
|
||||
globals.m2 = m1+m2
|
||||
print "You are out of fuel."
|
||||
globals.m1 = 0
|
||||
end if
|
||||
else
|
||||
globals.f = 0
|
||||
globals.m2 = 0
|
||||
end if
|
||||
globals.m = m-.5*m2
|
||||
globals.r4 = r3
|
||||
globals.r3 = -.5*r0*((v0/r)^2)+r*a1*a1
|
||||
globals.r2 = (3*r3-r4)/2+.00526*f1*f*c/m
|
||||
globals.a4 = a3
|
||||
globals.a3 = -2*r1*a1/r
|
||||
globals.a2 = (3*a3-a4)/2+.0056*f1*f*s/(m*r)
|
||||
globals.x = r1*t1+.5*r2*t1*t1
|
||||
globals.r = r+x
|
||||
globals.h0 = h0+x
|
||||
globals.r1 = r1+r2*t1
|
||||
globals.a = a+a1*t1+.5*a2*t1*t1
|
||||
globals.a1 = a1+a2*t1
|
||||
globals.m = m-.5*m2
|
||||
globals.t = t+t1
|
||||
if h0<3.287828e-04 then break
|
||||
end for
|
||||
|
||||
globals.h = h0*z
|
||||
globals.h1 = r1*z
|
||||
globals.d = r0*a*z
|
||||
globals.d1 = r*a1*z
|
||||
globals.t2 = m1*b/m0
|
||||
|
||||
print " " + [pad(t, 10), pad(h, 10), pad(d, 10), pad(h1, 10), pad(d1, 10), pad(t2, 10)].join
|
||||
end function
|
||||
|
||||
// Do one turn of the game. Return true if game still in progress,
|
||||
// or false when game is over (aborted, crashed, or landed).
|
||||
doOneTurn = function
|
||||
if m1 == 0 then
|
||||
// out of fuel!
|
||||
globals.t1 = 20
|
||||
globals.f = 0
|
||||
globals.p = 0
|
||||
else
|
||||
getTurnInputs
|
||||
end if
|
||||
if t1 == 0 then
|
||||
print "Mission abended"
|
||||
return false
|
||||
end if
|
||||
integrate
|
||||
|
||||
if h0 < 3.287828e-04 then
|
||||
if r1 < -8.21957e-04 or abs(r*a1) > 4.93174e-04 or h0 < -3.287828e-04 then
|
||||
print
|
||||
print "Crash !!!!!!!!!!!!!!!!"
|
||||
print "Your impact created a crater " + abs(h) + " " + ms + " deep."
|
||||
x1 = sqr(d1*d1+h1*h1)*g3
|
||||
print "At contact you were traveling " + x1 + " " + ns + "/hr"
|
||||
else if abs(d)>10*z then
|
||||
print "You are down safely - "
|
||||
print
|
||||
print "But missed the landing site by" + abs(d/g5) + " " + ns + "."
|
||||
else
|
||||
print
|
||||
print "Tranquility Base here -- the Eagle has landed."
|
||||
print "Congratulations -- there was no spacecraft damage."
|
||||
print "You may now proceed with surface exploration."
|
||||
end if
|
||||
return false
|
||||
end if
|
||||
|
||||
if r0*a>164.474 then
|
||||
print
|
||||
print "You have been lost in space with no hope of recovery."
|
||||
return false
|
||||
end if
|
||||
return true
|
||||
end function
|
||||
|
||||
startFirstGame
|
||||
while true
|
||||
t1 = 0; f = 0; p = 0
|
||||
integrate
|
||||
while doOneTurn
|
||||
end while
|
||||
print
|
||||
while true
|
||||
qs = input("Do you want to try it again (yes/no)? ").lower
|
||||
if qs and (qs[0] == "y" or qs[0] == "n") then break
|
||||
end while
|
||||
if qs[0] == "n" then
|
||||
print
|
||||
print "Too bad, the space program hates to lose experienced"
|
||||
print "astronauts."
|
||||
break
|
||||
end if
|
||||
startSubsequentGame
|
||||
end while
|
||||
114
00_Alternate_Languages/59_Lunar_LEM_Rocket/MiniScript/lunar.ms
Normal file
114
00_Alternate_Languages/59_Lunar_LEM_Rocket/MiniScript/lunar.ms
Normal file
@@ -0,0 +1,114 @@
|
||||
print " "*33 + "Lunar"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
print "This is a computer simulation of an Apollo lunar"
|
||||
print "landing capsule."; print; print
|
||||
print "The on-board computer has failed (it was made by"
|
||||
print "Xerox) so you have to land the capsule manually."
|
||||
|
||||
printCols = function(fields, delimiter=null)
|
||||
if delimiter == null then delimiter = text.delimiter
|
||||
line = ""
|
||||
for s in fields
|
||||
line += (s + " "*12)[:12]
|
||||
end for
|
||||
print line, delimiter
|
||||
end function
|
||||
|
||||
doOneGame = function
|
||||
print; print "Set burn rate of retro rockets to any value between"
|
||||
print "0 (free fall) and 200 (maximum burn) pounds per second."
|
||||
print "Set new burn rate every 10 seconds."; print
|
||||
print "Capsule weight 32,500 lbs; fuel weight 16,500 lbs."
|
||||
print; print; print; print "Good luck"
|
||||
l = 0
|
||||
|
||||
print
|
||||
printCols ["sec","mi + ft","mph","lb fuel","burn rate"]
|
||||
print
|
||||
a=120; v = 1; m=33000; n=16500; g=1e-03; z = 1.8
|
||||
|
||||
formulaSet1 = function // (subroutine 330)
|
||||
outer.l += s
|
||||
outer.t -= s
|
||||
outer.m -= s * k
|
||||
outer.a = i
|
||||
outer.v = j
|
||||
end function
|
||||
|
||||
formulaSet2 = function // (subroutine 420)
|
||||
outer.q = s * k / m
|
||||
outer.j = v + g*s + z*(-q-q*q/2-q^3/3-q^4/4-q^5/5)
|
||||
outer.i = a - g*s*s/2 - v*s+z*s*(q/2+q^2/6+q^3/12+q^4/20+q^5/30)
|
||||
end function
|
||||
|
||||
formulaSet3 = function // (loop 340-360)
|
||||
while s >= 5e-3
|
||||
outer.d = v + sqrt(v * v + 2 * a * (g - z * k / m))
|
||||
outer.s = 2 * a / d
|
||||
formulaSet2
|
||||
formulaSet1
|
||||
end while
|
||||
end function
|
||||
|
||||
while true
|
||||
printCols [l, floor(a) + " " + floor(5280*(a-floor(a))), 3600*v, m-n], ""
|
||||
k = input.val
|
||||
t=10
|
||||
shouldExit = false
|
||||
|
||||
while true
|
||||
if m-n < 1e-03 then break
|
||||
if t < 1e-03 then break
|
||||
s = t; if m < n+s*k then s = (m-n)/k
|
||||
formulaSet2
|
||||
if i <= 0 then
|
||||
formulaSet3
|
||||
shouldExit = true
|
||||
break
|
||||
end if
|
||||
if v > 0 and j < 0 then
|
||||
while v > 0 and j <= 0
|
||||
w = (1 - m*g/(z*k))/2
|
||||
s = m*v / (z*k*(w + sqrt(w*w + v/z))) + 0.05
|
||||
formulaSet2
|
||||
if i <= 0 then
|
||||
formulaSet3
|
||||
shouldExit = true
|
||||
break
|
||||
end if
|
||||
formulaSet1
|
||||
end while
|
||||
if shouldExit then break
|
||||
continue
|
||||
end if
|
||||
formulaSet1
|
||||
end while
|
||||
if shouldExit then break
|
||||
if m-n < 1e-03 then
|
||||
print "Fuel out at " + round(l) + " seconds"
|
||||
s = (-v+sqrt(v*v+2*a*g))/g
|
||||
v = v+g*s; l = l+s
|
||||
break
|
||||
end if
|
||||
end while
|
||||
|
||||
w = 3600*v
|
||||
print "On moon at " + l + " seconds - impact velocity " + round(w,1) + " mph"
|
||||
if w <= 1.2 then
|
||||
print "Perfect landing!"
|
||||
else if w <= 10 then
|
||||
print "Good landing (could be better)"
|
||||
else if w <= 60 then
|
||||
print "Craft damage... you're stranded here until a rescue"
|
||||
print "party arrives. Hope you have enough oxygen!"
|
||||
else
|
||||
print "Sorry there were no survivors. You blew it!"
|
||||
print "In fact, you blasted a new lunar crater " + round(w*.227,1) + " feet deep!"
|
||||
end if
|
||||
end function
|
||||
|
||||
while true
|
||||
doOneGame
|
||||
print; print; print; print "Try again??"
|
||||
end while
|
||||
101
00_Alternate_Languages/59_Lunar_LEM_Rocket/MiniScript/rocket.ms
Normal file
101
00_Alternate_Languages/59_Lunar_LEM_Rocket/MiniScript/rocket.ms
Normal file
@@ -0,0 +1,101 @@
|
||||
if version.hostName == "Mini Micro" then clear
|
||||
print " "*30 + "Rocket"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
print "Lunar Landing Simulation"
|
||||
print "----- ------- ----------"; print
|
||||
yn = input("Do you want instructions (yes or no)? ").lower
|
||||
if not yn or yn[0] != "n" then
|
||||
print
|
||||
print "You are landing on the moon and and have taken over manual"
|
||||
print "control 1000 feet above a good landing spot. You have a down-"
|
||||
print "ward velocity of 50 feet/sec. 150 units of fuel remain."
|
||||
print
|
||||
print "Here are the rules that govern your Apollo space-craft"
|
||||
print "(Press Return after each one):"; print
|
||||
print "(1) After each second the height, velocity, and remaining fuel"
|
||||
print " will be reported via Digby your on-board computer."
|
||||
input
|
||||
print "(2) After the report a '?' will appear. Enter the number"
|
||||
print " of units of fuel you wish to burn during the next"
|
||||
print " second. Each unit of fuel will slow your descent by"
|
||||
print " 1 foot/sec."
|
||||
input
|
||||
print "(3) The maximum thrust of your engine is 30 feet/sec/sec"
|
||||
print " or 30 units of fuel per second."
|
||||
input
|
||||
print "(4) When you contact the lunar surface, your descent engine"
|
||||
print " will automatically shut down and you will be given a"
|
||||
print " report of your landing speed and remaining fuel."
|
||||
input
|
||||
print "(5) If you run out of fuel the '?' will no longer appear"
|
||||
print " but your second by second report will continue until"
|
||||
print " you contact the lunar surface."; print
|
||||
input
|
||||
end if
|
||||
|
||||
pad = function(s, width=10)
|
||||
return (s + " "*width)[:width]
|
||||
end function
|
||||
|
||||
// Bonus little feature when running in Mini Micro: display a header bar
|
||||
// always at the top of the screen.
|
||||
drawHeaders = function
|
||||
display(2).mode = displayMode.text; td = display(2)
|
||||
td.color = text.color; td.backColor = color.black
|
||||
td.row = 25; td.column = 0
|
||||
td.print "sec feet speed fuel plot of distance" + " "*21
|
||||
end function
|
||||
|
||||
while true
|
||||
print "Beginning landing procedure.........."; print
|
||||
print "G O O D L U C K ! ! !"
|
||||
print; print
|
||||
print "sec feet speed fuel plot of distance"
|
||||
drawHeaders
|
||||
print
|
||||
t=0; h=1000; v=50; fuel=150
|
||||
while true
|
||||
print pad(t,5) + pad(h,7) + pad(v, 10) + pad(fuel,8) + "|" + " "*floor(h/30) + "*"
|
||||
if fuel <= 0 then
|
||||
burn = 0
|
||||
wait 0.5 // (slight pause for drama and legibility)
|
||||
else
|
||||
burn = input("?").val
|
||||
if burn < 0 then burn = 0
|
||||
if burn > 30 then burn=30
|
||||
if burn > fuel then
|
||||
burn = fuel
|
||||
print "**** out of fuel ****"
|
||||
end if
|
||||
end if
|
||||
v1 = v - burn + 5
|
||||
fuel -= burn
|
||||
h -= .5*(v+v1)
|
||||
if h <= 0 then break
|
||||
t += 1
|
||||
v = v1
|
||||
end while
|
||||
print "***** CONTACT *****"
|
||||
h = h+ .5*(v1+v)
|
||||
if burn == 5 then
|
||||
d = h/v
|
||||
else
|
||||
d = (-v+sqrt(v*v+h*(10-2*burn)))/(5-burn)
|
||||
end if
|
||||
v1 = v + (5-burn)*d
|
||||
print "Touchdown at " + (t+d) + " seconds."
|
||||
print "Landing velocity = " + round(v1,1) + " feet/sec."
|
||||
print fuel + " units of fuel remaining."
|
||||
if v1 == 0 then
|
||||
print "Congratulations! a perfect landing!!"
|
||||
print "Your license will be renewed.......later."
|
||||
else if abs(v1) >= 2 then
|
||||
print "***** Sorry, but you blew it!!!!"
|
||||
print "Appropriate condolences will be sent to your next of kin."
|
||||
end if
|
||||
print; print; print
|
||||
yn = input("Another mission? ").lower
|
||||
if not yn or yn[0] != "y" then break
|
||||
end while
|
||||
print; print "Control out."; print
|
||||
17
00_Alternate_Languages/60_Mastermind/MiniScript/README.md
Normal file
17
00_Alternate_Languages/60_Mastermind/MiniScript/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
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 mastermind.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
```
|
||||
load "mastermind"
|
||||
run
|
||||
```
|
||||
260
00_Alternate_Languages/60_Mastermind/MiniScript/mastermind.ms
Normal file
260
00_Alternate_Languages/60_Mastermind/MiniScript/mastermind.ms
Normal file
@@ -0,0 +1,260 @@
|
||||
//
|
||||
// MASTERMIND II
|
||||
// STEVE NORTH
|
||||
// CREATIVE COMPUTING
|
||||
// PO BOX 789-M MORRISTOWN NEW JERSEY 07960
|
||||
//
|
||||
// Converted to MiniScript by Joe Strout (Sep 2023)
|
||||
|
||||
// Advance the given combination to the next possible combination.
|
||||
// Note that (unlike the BASIC program) our values are 0-based, not 1-based.
|
||||
incrementCombo = function(combo)
|
||||
idx = 0
|
||||
while true
|
||||
combo[idx] += 1
|
||||
if combo[idx] < colorCount then return
|
||||
combo[idx] = 0
|
||||
idx += 1
|
||||
end while
|
||||
end function
|
||||
|
||||
// Convert a numeric combination like [2, 0, 1] into a color string like "RBW".
|
||||
comboToColorString = function(combo)
|
||||
result = ""
|
||||
for q in combo
|
||||
result += colorCodes[q]
|
||||
end for
|
||||
return result
|
||||
end function
|
||||
|
||||
// Get a random color code like "RBW".
|
||||
getRandomCode = function
|
||||
// We do this by starting with a numeric combo of all 0's (first color),
|
||||
// and then stepping through subsequent combos a random number of times.
|
||||
combo = [0] * posCount
|
||||
steps = floor(possibilities * rnd)
|
||||
while steps
|
||||
incrementCombo combo
|
||||
steps -= 1
|
||||
end while
|
||||
return comboToColorString(combo)
|
||||
end function
|
||||
|
||||
// Return [blackPins, whitePins] for the given guess and actual code.
|
||||
// blackPins is how many guess entries are the correct color AND position;
|
||||
// whitePins is how many guess entries have the right color, but wrong position.
|
||||
// This works with either color strings or numeric combos.
|
||||
calcResult = function(guess, actual)
|
||||
if guess isa string then guess = guess.split("") else guess = guess[:]
|
||||
if actual isa string then actual = actual.split("") else actual = actual[:]
|
||||
black = 0; white = 0
|
||||
for i in guess.indexes
|
||||
if guess[i] == actual[i] then
|
||||
black += 1
|
||||
actual[i] = null
|
||||
else
|
||||
for j in actual.indexes
|
||||
if guess[i] == actual[j] and guess[j] != actual[j] then
|
||||
white += 1
|
||||
actual[j] = null
|
||||
break
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
guess[i] = null
|
||||
end for
|
||||
return [black, white]
|
||||
end function
|
||||
|
||||
// Pad a string with spaces, to the given width.
|
||||
pad = function(s, width=12)
|
||||
return (s + " "*width)[:width]
|
||||
end function
|
||||
|
||||
// Print the history of guesses and results.
|
||||
printBoard = function
|
||||
print
|
||||
print "BOARD"
|
||||
print "Move Guess Black White"
|
||||
for i in guessHistory.indexes
|
||||
print pad(i+1, 9) + pad(guessHistory[i], 15) +
|
||||
pad(guessResult[i][0], 10) + guessResult[i][1]
|
||||
end for
|
||||
print
|
||||
end function
|
||||
|
||||
// Quit the game (after reporting the computer's secret code).
|
||||
quit = function(computerCode)
|
||||
print "Quitter! My combination was: " + computerCode
|
||||
print
|
||||
print "Good bye"
|
||||
exit
|
||||
end function
|
||||
|
||||
// Prompt the user for a guess (e.g. "RBW").
|
||||
// Also handle "BOARD" and "QUIT" commands.
|
||||
inputGuess = function(guessNum, secretCode)
|
||||
while true
|
||||
guess = input("Move #" + guessNum + " Guess? ").upper
|
||||
if guess == "BOARD" then
|
||||
printBoard
|
||||
else if guess == "QUIT" then
|
||||
quit secretCode
|
||||
else if guess.len != posCount then
|
||||
print "Bad number of positions."
|
||||
else
|
||||
ok = true
|
||||
for c in guess
|
||||
if colorCodes.indexOf(c) == null then
|
||||
print "'" + c + "' is unrecognized."
|
||||
ok = false
|
||||
break
|
||||
end if
|
||||
end for
|
||||
if ok then return guess
|
||||
end if
|
||||
end while
|
||||
end function
|
||||
|
||||
// Play one half-round where the computer picks a code,
|
||||
// and the human tries to guess it.
|
||||
doHumanGuesses = function
|
||||
print "Guess my combination."
|
||||
print
|
||||
secretCode = getRandomCode
|
||||
//print "My secret combo is: " + secretCode // (for debugging purposes)
|
||||
|
||||
globals.guessHistory = [] // list of guesses, e.g. "RBW"
|
||||
globals.guessResult = [] // result of each guess, as [BlackPins, WhitePins]
|
||||
|
||||
for guessNum in range(1, 10)
|
||||
guess = inputGuess(guessNum, secretCode)
|
||||
result = calcResult(guess, secretCode)
|
||||
if result[0] == posCount then
|
||||
print "You guessed it in " + guessNum + " moves!"
|
||||
break
|
||||
end if
|
||||
// Tell human results
|
||||
print "You have " + result[0] + " blacks and " + result[1] + " whites."
|
||||
// Save all this stuff for board printout later
|
||||
guessHistory.push guess
|
||||
guessResult.push result
|
||||
end for
|
||||
if guess != secretCode then
|
||||
print "You ran out of moves! That's all you get!"
|
||||
print "The actual combination was: " + secretCode
|
||||
end if
|
||||
globals.humanScore += guessNum
|
||||
end function
|
||||
|
||||
// Play one half-round where the human picks a code,
|
||||
// and the computer tries to guess it.
|
||||
// Return true if this goes OK, and false if we need a do-over.
|
||||
doComputerGuesses = function
|
||||
print "Now I guess. Think of a combination."
|
||||
input "Hit Return when ready:"
|
||||
|
||||
// Make a list of possible combination *numbers*, from 0 to possibilities-1.
|
||||
// We'll remove entries from this list as we eliminate them with our guesses.
|
||||
possible = range(0, possibilities-1)
|
||||
|
||||
gotIt = false
|
||||
for guessNum in range(1, 10)
|
||||
if not possible then
|
||||
print "You have given me inconsistent information."
|
||||
print "Try again, and this time please be more careful."
|
||||
return false
|
||||
end if
|
||||
guessIdx = possible[rnd * possible.len]
|
||||
guessCombo = [0] * posCount
|
||||
if guessIdx > 0 then
|
||||
for x in range(0, guessIdx-1)
|
||||
incrementCombo guessCombo
|
||||
end for
|
||||
end if
|
||||
|
||||
print "My guess is: " + comboToColorString(guessCombo)
|
||||
|
||||
while true
|
||||
s = input(" Blacks, Whites? ").replace(",", " ").replace(" ", " ").split
|
||||
if s.len == 2 then break
|
||||
end while
|
||||
actualResult = [s[0].val, s[1].val]
|
||||
|
||||
if actualResult[0] == posCount then
|
||||
print "I got it in " + guessNum + " moves!"
|
||||
gotIt = true
|
||||
break
|
||||
end if
|
||||
|
||||
// Now zip through all possibilities, and if it's still in our
|
||||
// possible list but doesn't match the given result, remove it.
|
||||
combo = [0] * posCount
|
||||
for x in range(0, possibilities-1)
|
||||
if x > 0 then incrementCombo combo
|
||||
idx = possible.indexOf(x)
|
||||
if idx == null then continue // (already eliminated)
|
||||
result = calcResult(combo, guessCombo)
|
||||
if result != actualResult then
|
||||
//print "Eliminating #" + x + ", " + comboToColorString(combo)
|
||||
possible.remove idx
|
||||
end if
|
||||
end for
|
||||
end for
|
||||
|
||||
if not gotIt then
|
||||
print "I used up all my moves!"
|
||||
print "I guess my CPU is just having an off day."
|
||||
end if
|
||||
globals.computerScore += guessNum
|
||||
return true
|
||||
end function
|
||||
|
||||
// Show the score (with the given header).
|
||||
showScore = function(header="Score")
|
||||
print header + ":"
|
||||
print " COMPUTER " + computerScore
|
||||
print " HUMAN " + humanScore
|
||||
print
|
||||
end function
|
||||
|
||||
// Initialization of global variables
|
||||
colorCodes = "BWRGOYPT"
|
||||
colorNames = "Black,White,Red,Green,Orange,Yellow,Purple,Tan".split(",")
|
||||
computerScore = 0
|
||||
humanScore = 0
|
||||
|
||||
// Main program
|
||||
print " "*30 + "Mastermind"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
while true
|
||||
colorCount = input("Number of colors? ").val
|
||||
if 0 < colorCount <= 8 then break
|
||||
print "No more than 8, please!"
|
||||
end while
|
||||
posCount = input("Number of positions? ").val
|
||||
roundCount = input("Number of rounds? ").val
|
||||
possibilities = colorCount ^ posCount
|
||||
print "Total possibilities = " + possibilities
|
||||
|
||||
print; print
|
||||
print "Color Letter"
|
||||
print "===== ======"
|
||||
for x in range(0, colorCount-1)
|
||||
print pad(colorNames[x], 9) + colorCodes[x]
|
||||
end for
|
||||
print
|
||||
|
||||
for round in range(1, roundCount)
|
||||
print
|
||||
print "Round number " + round + " ----"
|
||||
print
|
||||
doHumanGuesses
|
||||
showScore
|
||||
while not doComputerGuesses; end while
|
||||
showScore
|
||||
end for
|
||||
|
||||
print "GAME OVER"
|
||||
showScore "Final score"
|
||||
21
00_Alternate_Languages/61_Math_Dice/MiniScript/README.md
Normal file
21
00_Alternate_Languages/61_Math_Dice/MiniScript/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
|
||||
|
||||
Conversion to [MiniScript](https://miniscript.org).
|
||||
|
||||
Ways to play:
|
||||
|
||||
0. Try-It! Page:
|
||||
Go to https://miniscript.org/tryit/, clear the sample code from the code editor, and paste in the contents of mathdice.ms. Then click the "Run Script" button. Program output (and input) will appear in the green-on-black terminal display to the right of or below the code editor.
|
||||
|
||||
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 mathdice.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
```
|
||||
load "mathdice"
|
||||
run
|
||||
```
|
||||
58
00_Alternate_Languages/61_Math_Dice/MiniScript/mathdice.ms
Normal file
58
00_Alternate_Languages/61_Math_Dice/MiniScript/mathdice.ms
Normal file
@@ -0,0 +1,58 @@
|
||||
print " "*31 + "Math Dice"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
print "This program generates successive pictures of two dice."
|
||||
print "When two dice and an equal sign followed by a question"
|
||||
print "mark have been printed, type your answer and the return key."
|
||||
print "To conclude the lesson, type Control-C as your answer."
|
||||
print
|
||||
|
||||
printDie = function(d)
|
||||
print
|
||||
print " -----"
|
||||
if d == 1 then
|
||||
print "| |"
|
||||
else if d == 2 or d == 3 then
|
||||
print "| * |"
|
||||
else
|
||||
print "| * * |"
|
||||
end if
|
||||
if d == 2 or d == 4 then
|
||||
print "| |"
|
||||
else if d == 6 then
|
||||
print "| * * |"
|
||||
else
|
||||
print "| * |"
|
||||
end if
|
||||
if d == 1 then
|
||||
print "| |"
|
||||
else if d == 2 or d == 3 then
|
||||
print "| * |"
|
||||
else
|
||||
print "| * * |"
|
||||
end if
|
||||
print " -----"
|
||||
print
|
||||
end function
|
||||
|
||||
while true
|
||||
d1 = floor(6 * rnd + 1)
|
||||
printDie d1
|
||||
print " +"
|
||||
d2 = floor(6 * rnd + 1)
|
||||
printDie d2
|
||||
total = d1 + d2
|
||||
answer = input(" =? ").val
|
||||
if answer != total then
|
||||
print "No, count the spots and give another answer."
|
||||
answer = input(" =? ").val
|
||||
end if
|
||||
if answer == total then
|
||||
print "Right!"
|
||||
else
|
||||
print "No, the answer is " + total
|
||||
end if
|
||||
print
|
||||
print "The dice roll again..."
|
||||
end while
|
||||
|
||||
21
00_Alternate_Languages/62_Mugwump/MiniScript/README.md
Normal file
21
00_Alternate_Languages/62_Mugwump/MiniScript/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
|
||||
|
||||
Conversion to [MiniScript](https://miniscript.org).
|
||||
|
||||
Ways to play:
|
||||
|
||||
0. Try-It! Page:
|
||||
Go to https://miniscript.org/tryit/, clear the sample code from the code editor, and paste in the contents of mathdice.ms. Then click the "Run Script" button. Program output (and input) will appear in the green-on-black terminal display to the right of or below the code editor.
|
||||
|
||||
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 mathdice.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
```
|
||||
load "mathdice"
|
||||
run
|
||||
```
|
||||
65
00_Alternate_Languages/62_Mugwump/MiniScript/mugwump.ms
Normal file
65
00_Alternate_Languages/62_Mugwump/MiniScript/mugwump.ms
Normal file
@@ -0,0 +1,65 @@
|
||||
print " "*33 + "Mugwump"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
// Courtesy People's Computer Company
|
||||
print "The object of this game is to find four mugwumps"
|
||||
print "hidden on a 10 by 10 grid. Homebase is position 0,0."
|
||||
print "Any guess you make must be two numbers with each"
|
||||
print "number between 0 and 9, inclusive. First number"
|
||||
print "is distance to right of homebase and second number"
|
||||
print "is distance above homebase."
|
||||
print
|
||||
print "You get 10 tries. After each try, I will tell"
|
||||
print "you how far you are from each mugwump."
|
||||
print
|
||||
|
||||
playOneGame = function
|
||||
mugwump = {} // key: number 1-4; value: [x,y] position
|
||||
for i in range(1, 4)
|
||||
mugwump[i] = [floor(10*rnd), floor(10*rnd)]
|
||||
end for
|
||||
|
||||
found = 0
|
||||
for turn in range(1, 10)
|
||||
print
|
||||
print
|
||||
while true
|
||||
inp = input("Turn no. " + turn + " -- what is your guess? ")
|
||||
inp = inp.replace(",", " ").replace(" ", " ").split
|
||||
if inp.len == 2 then break
|
||||
end while
|
||||
x = inp[0].val; y = inp[1].val
|
||||
for i in range(1, 4)
|
||||
pos = mugwump[i]
|
||||
if pos == null then continue // (already found)
|
||||
if pos == [x,y] then
|
||||
print "You have found mugwump " + i
|
||||
mugwump[i] = null
|
||||
found += 1
|
||||
else
|
||||
d = sqrt( (pos[0] - x)^2 + (pos[1] - y)^2 )
|
||||
print "You are " + round(d, 1) + " units from mugwump " + i
|
||||
end if
|
||||
end for
|
||||
if found == 4 then
|
||||
print
|
||||
print "You got them all in " + turn + " turns!"
|
||||
return
|
||||
end if
|
||||
end for
|
||||
print
|
||||
print "Sorry, that's 10 tries. Here is where they're hiding:"
|
||||
for i in range(1, 4)
|
||||
pos = mugwump[i]
|
||||
if pos == null then continue
|
||||
print "Mugwump " + i + " is at (" + pos[0] + "," + pos[1] + ")"
|
||||
end for
|
||||
end function
|
||||
|
||||
// Main loop
|
||||
while true
|
||||
playOneGame
|
||||
print
|
||||
print "That was fun! Let's play again......."
|
||||
print "Four more mugwumps are now in hiding."
|
||||
end while
|
||||
21
00_Alternate_Languages/63_Name/MiniScript/README.md
Normal file
21
00_Alternate_Languages/63_Name/MiniScript/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
|
||||
|
||||
Conversion to [MiniScript](https://miniscript.org).
|
||||
|
||||
Ways to play:
|
||||
|
||||
0. Try-It! Page:
|
||||
Go to https://miniscript.org/tryit/, clear the sample code from the code editor, and paste in the contents of name.ms. Then click the "Run Script" button. Program output (and input) will appear in the green-on-black terminal display to the right of or below the code editor.
|
||||
|
||||
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 name.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
```
|
||||
load "name"
|
||||
run
|
||||
```
|
||||
25
00_Alternate_Languages/63_Name/MiniScript/name.ms
Normal file
25
00_Alternate_Languages/63_Name/MiniScript/name.ms
Normal file
@@ -0,0 +1,25 @@
|
||||
print " "*34 + "Name"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
print "Hello."; print "My name is Creative Computer."
|
||||
name = input("What's your name (first and last)? ")
|
||||
|
||||
s = ""
|
||||
for i in range(name.len - 1)
|
||||
s += name[i]
|
||||
end for
|
||||
print; print "Thank you, " + s + "."
|
||||
print "Oops! I guess I got it backwards. A smart"
|
||||
print "computer like me shouldn't make a mistake like that!"; print
|
||||
print "But i just noticed your letters are out of order."
|
||||
s = name.split("").sort.join("")
|
||||
print "Let's put them in order like this: " + s
|
||||
yn = input("Don't you like that better? ").lower
|
||||
print
|
||||
if yn and yn[0] == "y" then
|
||||
print "I knew you'd agree!!"
|
||||
else
|
||||
print "I'm sorry you don't like it that way."
|
||||
end if
|
||||
print; print "I really enjoyed meeting you " + name + "."
|
||||
print "Have a nice day!"
|
||||
@@ -7,13 +7,15 @@ 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 nicomachus.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "nicomachus"
|
||||
run
|
||||
|
||||
```
|
||||
3. "Try-It!" page on the web:
|
||||
Go to https://miniscript.org/tryit/, clear the default program from the source code editor, paste in the contents of nicomachus.ms, and click the "Run Script" button.
|
||||
|
||||
18
00_Alternate_Languages/65_Nim/MiniScript/README.md
Normal file
18
00_Alternate_Languages/65_Nim/MiniScript/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
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 nim.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
```
|
||||
load "nim"
|
||||
run
|
||||
```
|
||||
194
00_Alternate_Languages/65_Nim/MiniScript/nim.ms
Normal file
194
00_Alternate_Languages/65_Nim/MiniScript/nim.ms
Normal file
@@ -0,0 +1,194 @@
|
||||
print " "*33 + "Nim"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
|
||||
askYesNo = function(prompt)
|
||||
while true
|
||||
answer = input(prompt + "? ").lower
|
||||
if answer and answer[0] == "y" then return "yes"
|
||||
if answer and answer[0] == "n" then return "no"
|
||||
print "Please answer yes or no."
|
||||
end while
|
||||
end function
|
||||
|
||||
print "This is the game of Nim."
|
||||
if askYesNo("Do you want instructions") == "yes" then
|
||||
print "The game is played with a number of piles of objects."
|
||||
print "Any number of objects are removed from one pile by you and"
|
||||
print "the machine alternately. On your turn, you may take"
|
||||
print "all the objects that remain in any pile, but you must"
|
||||
print "take at least one object, and you may take objects from"
|
||||
print "only one pile on a single turn. You must specify whether"
|
||||
print "winning is defined as taking or not taking the last object,"
|
||||
print "the number of piles in the game, and how many objects are"
|
||||
print "originally in each pile. Each pile may contain a"
|
||||
print "different number of objects."
|
||||
print "The machine will show its move by listing each pile and the"
|
||||
print "number of objects remaining in the piles after each of its"
|
||||
print "moves."
|
||||
end if
|
||||
|
||||
allEmpty = function(piles)
|
||||
for i in range(1, piles.len-1)
|
||||
if piles[i] then return false
|
||||
end for
|
||||
return true
|
||||
end function
|
||||
|
||||
// Do the computer's turn; return true if game over, false otherwise.
|
||||
doComputerTurn = function(pile, winCondition)
|
||||
n = pile.len - 1
|
||||
d = [0,0,0]
|
||||
b = [null]
|
||||
for i in range(1, n)
|
||||
b.push [0]*11
|
||||
end for
|
||||
|
||||
if winCondition == 2 then
|
||||
c = 0
|
||||
broke = false
|
||||
for i in range(1, n)
|
||||
if pile[i] == 0 then continue
|
||||
c += 1
|
||||
if c == 3 then; broke = true; break; end if
|
||||
d[c] = i
|
||||
end for
|
||||
if not broke then
|
||||
if c == 2 and (pile[d[1]] == 1 or pile[d[2]] == 1) then
|
||||
print "Machine wins"
|
||||
return true
|
||||
end if
|
||||
if pile[d[1]] > 1 then
|
||||
print "Machine wins"
|
||||
return true
|
||||
end if
|
||||
print "Machine loses"
|
||||
return true
|
||||
end if
|
||||
c = 0
|
||||
broke = false
|
||||
for i in range(1, n)
|
||||
if pile[i] > 1 then; broke = true; break; end if
|
||||
if pile[i] == 0 then continue
|
||||
c += 1
|
||||
end for
|
||||
if not broke and c/2 != floor(c/2) then
|
||||
print "Machine loses"
|
||||
return true
|
||||
end if
|
||||
end if
|
||||
|
||||
for i in range(1, n)
|
||||
e = pile[i]
|
||||
for j in range(0, 10)
|
||||
f = e/2
|
||||
b[i][j] = 2*(f-floor(f))
|
||||
e = floor(f)
|
||||
end for
|
||||
end for
|
||||
broke = false
|
||||
for j in range(10, 0)
|
||||
c = 0
|
||||
h = 0
|
||||
for i in range(1, n)
|
||||
if b[i][j] == 0 then continue
|
||||
c += 1
|
||||
if pile[i] <= h then continue
|
||||
h = pile[i]
|
||||
g = i
|
||||
end for
|
||||
if c/2 != floor(c/2) then; broke = true; break; end if
|
||||
end for
|
||||
if not broke then
|
||||
while true
|
||||
e = floor(n*rnd+1)
|
||||
if pile[e] != 0 then break
|
||||
end while
|
||||
f = floor(pile[e]*rnd+1)
|
||||
pile[e] -= f
|
||||
else
|
||||
pile[g] = 0
|
||||
for j in range(0, 10)
|
||||
b[g][j] = 0
|
||||
c=0
|
||||
for i in range(1,n)
|
||||
if b[i][j] == 0 then continue
|
||||
c += 1
|
||||
end for
|
||||
pile[g] += 2*(c/2-floor(c/2))*2^j
|
||||
end for
|
||||
if winCondition != 1 then
|
||||
c = 0
|
||||
broke = false
|
||||
for i in range(1, n)
|
||||
if pile[i]>1 then; broke = true; break; end if
|
||||
if pile[i] == 0 then continue
|
||||
c += 1
|
||||
end for
|
||||
if not broke and c/2 == floor(c/2) then pile[g]= 1 - pile[g]
|
||||
end if
|
||||
end if
|
||||
|
||||
print "Pile Size"
|
||||
for i in range(1, n)
|
||||
print i + " " + pile[i]
|
||||
end for
|
||||
if winCondition == 1 and allEmpty(pile) then
|
||||
print "Machine wins"
|
||||
return true
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
// Do the human player's turn; return true if game over, false otherwise.
|
||||
doPlayerTurn = function(pile, winCondition)
|
||||
n = pile.len - 1
|
||||
while true
|
||||
inp = input("Your move - pile, number to be removed? ")
|
||||
inp = inp.replace(",", " ").replace(" ", " ").split
|
||||
if inp.len != 2 then continue
|
||||
x = inp[0].val; y = inp[1].val
|
||||
if x == floor(x) and y == floor(y) and 1 <= x <= n and 1 <= y <= pile[x] then break
|
||||
end while
|
||||
|
||||
pile[x] -= y
|
||||
if allEmpty(pile) then
|
||||
if winCondition == 1 then print "Machine loses" else print "Machine wins"
|
||||
return true
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
playOneGame = function
|
||||
print
|
||||
while true
|
||||
w = input("Enter win option - 1 to take last, 2 to avoid last? ").val
|
||||
if w == 1 or w == 2 then break
|
||||
end while
|
||||
while true
|
||||
n = input("Enter number of piles? ").val
|
||||
if n == floor(n) and 1 <= n <= 100 then break
|
||||
end while
|
||||
|
||||
print "Enter pile sizes"
|
||||
pile = [null] + [0]*n // (null at element 0 to make our array 1-based)
|
||||
for i in range(1, n)
|
||||
while true
|
||||
pile[i] = input(i + "? ").val
|
||||
if pile[i] == floor(pile[i]) and 1 <= pile[i] <= 2000 then break
|
||||
end while
|
||||
end for
|
||||
|
||||
if askYesNo("Do you want to move first") == "yes" then
|
||||
if doPlayerTurn(pile, w) then return
|
||||
end if
|
||||
while true
|
||||
if doComputerTurn(pile, w) then return
|
||||
if doPlayerTurn(pile, w) then return
|
||||
end while
|
||||
end function
|
||||
|
||||
while true
|
||||
playOneGame
|
||||
if askYesNo("Do you want to play another game") == "no" then break
|
||||
end while
|
||||
@@ -7,13 +7,15 @@ 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 number.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "number"
|
||||
run
|
||||
|
||||
```
|
||||
3. "Try-It!" page on the web:
|
||||
Go to https://miniscript.org/tryit/, clear the default program from the source code editor, paste in the contents of number.ms, and click the "Run Script" button.
|
||||
|
||||
18
00_Alternate_Languages/67_One_Check/MiniScript/README.md
Normal file
18
00_Alternate_Languages/67_One_Check/MiniScript/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
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 onecheck.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
```
|
||||
load "onecheck"
|
||||
run
|
||||
```
|
||||
101
00_Alternate_Languages/67_One_Check/MiniScript/onecheck.ms
Normal file
101
00_Alternate_Languages/67_One_Check/MiniScript/onecheck.ms
Normal file
@@ -0,0 +1,101 @@
|
||||
print "Solitaire Checker Puzzle by David Ahl"
|
||||
print
|
||||
print "48 checkers are placed on the 2 outside spaces of a"
|
||||
print "standard 64-square checkerboard. The object is to"
|
||||
print "remove as many checkers as possible by diagonal jumps"
|
||||
print "(as in standard checkers). Use the numbered board to"
|
||||
print "indicate the square you wish to jump from and to. On"
|
||||
print "the board printed out on each turn '1' indicates a"
|
||||
print "checker and '0' an empty square. When you have no"
|
||||
print "possible jumps remaining, input a '0' in response to"
|
||||
print "question 'Jump from?'"
|
||||
print
|
||||
input "(Press Return.)"
|
||||
print
|
||||
|
||||
pad4 = function(n)
|
||||
return (" " + n)[-4:]
|
||||
end function
|
||||
|
||||
printBoard = function
|
||||
// Idea: This program could be greatly improved by printing the board
|
||||
// as the index numbers (1-64), indicating which of those positions
|
||||
// contain checkers via color or punctuation, e.g. "(42)" vs " 42 ".
|
||||
// This would make it much easier for the user to figure out what
|
||||
// numbers correspond to the positions they have in mind.
|
||||
print
|
||||
for j in range(1, 57, 8)
|
||||
print " " + board[j:j+8].join(" ")
|
||||
end for
|
||||
end function
|
||||
|
||||
initBoard = function
|
||||
globals.board = [null] + [1] * 64 // treat this as 1-based array
|
||||
for j in range(19, 43, 8)
|
||||
for i in range(j, j+3)
|
||||
board[i] = 0
|
||||
end for
|
||||
end for
|
||||
end function
|
||||
|
||||
isLegal = function(from, to)
|
||||
if board[from] == 0 then return false
|
||||
if board[to] == 1 then return false
|
||||
if board[(to+from)/2] == 0 then return false
|
||||
fromRow = floor((from-1) / 8) // row in range 0-7
|
||||
fromCol = from - fromRow*8 // column in range 1-8
|
||||
toRow = floor((to-1) / 8)
|
||||
toCol = to - toRow*8
|
||||
if fromRow > 7 or toRow > 7 or fromCol > 8 or toCol > 8 then return false
|
||||
if abs(fromRow-toRow) != 2 or abs(fromCol-toCol) != 2 then return false
|
||||
return true
|
||||
end function
|
||||
|
||||
askYesNo = function(prompt)
|
||||
while true
|
||||
answer = input(prompt + "? ").lower
|
||||
if answer and answer[0] == "y" then return "yes"
|
||||
if answer and answer[0] == "n" then return "no"
|
||||
print "Please answer 'yes' or 'no'."
|
||||
end while
|
||||
end function
|
||||
|
||||
print "Here is the numerical board:"
|
||||
print
|
||||
for j in range(1, 57, 8)
|
||||
print pad4(j) + pad4(j+1) + pad4(j+2) + pad4(j+3) +
|
||||
pad4(j+4) + pad4(j+5) + pad4(j+6) + pad4(j+7)
|
||||
end for
|
||||
|
||||
while true
|
||||
initBoard
|
||||
print
|
||||
print "And here is the opening position of the checkers."
|
||||
printBoard
|
||||
jumps = 0
|
||||
while true
|
||||
fromPos = input("Jump from? ").val
|
||||
if fromPos == 0 then break
|
||||
toPos = input("To? ").val
|
||||
print
|
||||
if not isLegal(fromPos, toPos) then
|
||||
print "Illegal move. Try again..."
|
||||
continue
|
||||
end if
|
||||
board[fromPos] = 0
|
||||
board[toPos] = 1
|
||||
board[(toPos+fromPos)/2] = 0
|
||||
jumps += 1
|
||||
printBoard
|
||||
end while
|
||||
// End game summary
|
||||
sum = board[1:].sum
|
||||
print "You made " + jumps + " jumps and had " + sum + " pieces"
|
||||
print "remaining on the board."
|
||||
print
|
||||
if askYesNo("Try again") == "no" then break
|
||||
end while
|
||||
print
|
||||
print "O.K. Hope you had fun!!"
|
||||
|
||||
|
||||
18
00_Alternate_Languages/68_Orbit/MiniScript/README.md
Normal file
18
00_Alternate_Languages/68_Orbit/MiniScript/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
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 orbit.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
```
|
||||
load "orbit"
|
||||
run
|
||||
```
|
||||
95
00_Alternate_Languages/68_Orbit/MiniScript/orbit.ms
Normal file
95
00_Alternate_Languages/68_Orbit/MiniScript/orbit.ms
Normal file
@@ -0,0 +1,95 @@
|
||||
print " "*33 + "Orbit"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
print "Somewhere above your planet is a Romulan ship."
|
||||
print
|
||||
print "The ship is in a constant polar orbit. Its"
|
||||
print "distance from the center of your planet is from"
|
||||
print "10,000 to 30,000 miles and at its present velocity can"
|
||||
print "circle your planet once every 12 to 36 hours."
|
||||
print
|
||||
print "Unfortunately, they are using a cloaking device so"
|
||||
print "you are unable to see them, but with a special"
|
||||
print "instrument you can tell how near their ship your"
|
||||
print "photon bomb exploded. You have seven hours until they"
|
||||
print "have built up sufficient power in order to escape"
|
||||
print "your planet's gravity."
|
||||
print
|
||||
print "Your planet has enough power to fire one bomb an hour."
|
||||
print
|
||||
print "At the beginning of each hour you will be asked to give an"
|
||||
print "angle (between 0 and 360) and a distance in units of"
|
||||
print "100 miles (between 100 and 300), after which your bomb's"
|
||||
print "distance from the enemy ship will be given."
|
||||
print
|
||||
print "An explosion within 5,000 miles of the romulan ship"
|
||||
print "will destroy it."
|
||||
print; input "(Press Return.)"
|
||||
print
|
||||
print "Below is a diagram to help you visualize your plight."
|
||||
print
|
||||
print
|
||||
print " 90"
|
||||
print " 0000000000000"
|
||||
print " 0000000000000000000"
|
||||
print " 000000 000000"
|
||||
print " 00000 00000"
|
||||
print " 00000 xxxxxxxxxxx 00000"
|
||||
print " 00000 xxxxxxxxxxxxx 00000"
|
||||
print " 0000 xxxxxxxxxxxxxxx 0000"
|
||||
print " 0000 xxxxxxxxxxxxxxxxx 0000"
|
||||
print " 0000 xxxxxxxxxxxxxxxxxxx 0000"
|
||||
print "180<== 00000 xxxxxxxxxxxxxxxxxxx 00000 ==>0"
|
||||
print " 0000 xxxxxxxxxxxxxxxxxxx 0000"
|
||||
print " 0000 xxxxxxxxxxxxxxxxx 0000"
|
||||
print " 0000 xxxxxxxxxxxxxxx 0000"
|
||||
print " 00000 xxxxxxxxxxxxx 00000"
|
||||
print " 00000 xxxxxxxxxxx 00000"
|
||||
print " 00000 00000"
|
||||
print " 000000 000000"
|
||||
print " 0000000000000000000"
|
||||
print " 0000000000000"
|
||||
print " 270"
|
||||
print
|
||||
print "x - your planet"
|
||||
print "o - the orbit of the romulan ship"
|
||||
print; input "(Press Return.)"
|
||||
print
|
||||
print "On the above diagram, the romulan ship is circling"
|
||||
print "counterclockwise around your planet. Don't forget that"
|
||||
print "without sufficient power the romulan ship's altitude"
|
||||
print "and orbital rate will remain constant."
|
||||
print
|
||||
print "Good luck. The federation is counting on you."
|
||||
|
||||
while true
|
||||
a=floor(360*rnd)
|
||||
d=floor(200*rnd + 200)
|
||||
r=floor(20*rnd + 10)
|
||||
for h in range(1,7)
|
||||
print
|
||||
print
|
||||
print "This is hour " + h + ", at what angle do you wish to send"
|
||||
a1 = input("your photon bomb? ").val
|
||||
d1 = input("How far out do you wish to detonate it? ").val
|
||||
print
|
||||
print
|
||||
a += r
|
||||
if a >= 360 then a -= 360
|
||||
t = abs(a-a1)
|
||||
if t >= 180 then t = 360 - t
|
||||
c = sqrt(d*d + d1*d1 - 2*d*d1*cos(t*pi/180))
|
||||
print "Your photon bomb exploded " + round(c) + " * 10^2 miles from the"
|
||||
print "Romulan ship."
|
||||
if c<=50 then break
|
||||
end for
|
||||
if c <= 50 then
|
||||
print "You have succesfully completed your mission."
|
||||
else
|
||||
print "You have allowed the Romulans to escape."
|
||||
end if
|
||||
print "Another romulan ship has gone into orbit."
|
||||
yn = input("Do you wish to try to destroy it? ").lower + " "
|
||||
if yn[0] != "y" then break
|
||||
end while
|
||||
print "good bye."
|
||||
16
00_Alternate_Languages/73_Reverse/MiniScript/README.md
Normal file
16
00_Alternate_Languages/73_Reverse/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 reverse.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
load "reverse"
|
||||
run
|
||||
71
00_Alternate_Languages/73_Reverse/MiniScript/reverse.ms
Normal file
71
00_Alternate_Languages/73_Reverse/MiniScript/reverse.ms
Normal file
@@ -0,0 +1,71 @@
|
||||
num = 9
|
||||
|
||||
reverse = function(i)
|
||||
if i == null then return i
|
||||
ret = []
|
||||
for item in i
|
||||
ret.insert(0,item)
|
||||
end for
|
||||
return ret
|
||||
end function
|
||||
|
||||
showRules = function
|
||||
print
|
||||
print "This is the game of 'Reverse'. To win, all you have"
|
||||
print "to do is arrange a list of numbers (1 through " + num + ")"
|
||||
print "in numerical order from left to right. To move, you"
|
||||
print "tell me how many numbers (counting from the left) to"
|
||||
print "reverse. For example, if the current list is:"
|
||||
print; print "2 3 4 5 1 6 7 8 9"
|
||||
print; print "and you reverse 4, the result will be:"
|
||||
print; print "5 4 3 2 1 6 7 8 9"
|
||||
print; print "Now if reverse 5, you win!"
|
||||
print; print "1 2 3 4 5 6 7 8 9"
|
||||
print
|
||||
print "No doubt you will like this game, but"
|
||||
print "if you want to quit, reverse 0 (zero)."
|
||||
print
|
||||
return
|
||||
end function
|
||||
|
||||
printState = function
|
||||
print;print digits.join(" "); print
|
||||
end function
|
||||
|
||||
print " " * 32 + "REVERSE"
|
||||
print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||
print; print; print
|
||||
print "Reverse -- a game of skill"
|
||||
print
|
||||
|
||||
ans = input("Do you want the rules? ")
|
||||
if ans != null and ans[0].lower == "y" then showRules
|
||||
|
||||
while 1
|
||||
turns = 0
|
||||
digits = range(1, num)
|
||||
digits.shuffle
|
||||
print;print "Here we go ... the list is:"
|
||||
while 1
|
||||
printState
|
||||
amt = input("How many shall I reverse? ").val
|
||||
if amt == null or amt == 0 then break
|
||||
|
||||
if amt > num then
|
||||
print "OOPS! Too many! I can reverse at most " + num
|
||||
else
|
||||
turns += 1
|
||||
digits = reverse(digits[:amt]) + digits[amt:]
|
||||
end if
|
||||
if digits == range(1,num) then
|
||||
printState
|
||||
print "You won it in " + turns + " moves!!"
|
||||
break
|
||||
end if
|
||||
end while
|
||||
print
|
||||
ans = input("Try again (YES or NO)? ")
|
||||
print
|
||||
if ans == null or ans[0].lower == "n" then break
|
||||
end while
|
||||
print "O.K. Hope you had fun!!"
|
||||
@@ -7,10 +7,13 @@ 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 sinewave.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "sinewave"
|
||||
run
|
||||
```
|
||||
16
00_Alternate_Languages/82_Stars/MiniScript/README.md
Normal file
16
00_Alternate_Languages/82_Stars/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 stars.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
load "stars"
|
||||
run
|
||||
48
00_Alternate_Languages/82_Stars/MiniScript/stars.ms
Normal file
48
00_Alternate_Languages/82_Stars/MiniScript/stars.ms
Normal file
@@ -0,0 +1,48 @@
|
||||
kMaxNum = 100
|
||||
kTries = 7
|
||||
|
||||
instructions = function
|
||||
print "I am thinking of a whole number from 1 to " + kMaxNum
|
||||
print "Try to guess my number. After you guess, I"
|
||||
print "will output one or more stars (*). The more"
|
||||
print "stars I type, the closer you are to my number."
|
||||
print "One star (*) means far away, seven stars (*******)"
|
||||
print "means really close! You get " + kTries + " guesses."
|
||||
print
|
||||
end function
|
||||
|
||||
print " " * 34 + "STARS"
|
||||
print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||
print; print; print
|
||||
|
||||
ans = input("Do you want instructions? ").lower
|
||||
if ans[0] == "y" then
|
||||
instructions
|
||||
end if
|
||||
|
||||
while 1
|
||||
print
|
||||
print "OK, I am thinking of a number, start guessing."
|
||||
starNum = floor(rnd * kMaxNum) + 1
|
||||
try = 0
|
||||
while try < kTries
|
||||
print
|
||||
guess = input("Your guess: ").val
|
||||
|
||||
if guess == starNum then
|
||||
break
|
||||
else
|
||||
d = abs(guess - starNum)
|
||||
print "*" * (7 - floor(log(d,2)))
|
||||
end if
|
||||
try += 1
|
||||
end while
|
||||
|
||||
if try < kTries then
|
||||
print "*" * 59
|
||||
print "You got it in " + (try + 1) + " guesses! Let's play again."
|
||||
else
|
||||
print "Sorry, that's " + try + " guesses. The number was " + starNum
|
||||
end if
|
||||
print
|
||||
end while
|
||||
17
00_Alternate_Languages/85_Synonym/MiniScript/README.md
Normal file
17
00_Alternate_Languages/85_Synonym/MiniScript/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
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 synonym.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
```
|
||||
load "synonym"
|
||||
run
|
||||
```
|
||||
47
00_Alternate_Languages/85_Synonym/MiniScript/synonym.ms
Normal file
47
00_Alternate_Languages/85_Synonym/MiniScript/synonym.ms
Normal file
@@ -0,0 +1,47 @@
|
||||
words = [["first", "start", "beginning", "onset", "initial"],
|
||||
["similar", "alike", "same", "like", "resembling"],
|
||||
["model", "pattern", "prototype", "standard", "criterion"],
|
||||
["small", "insignificant", "little", "tiny", "minute"],
|
||||
["stop", "halt", "stay", "arrest", "check", "standstill"],
|
||||
["house", "dwelling", "residence", "domicile", "lodging", "habitation"],
|
||||
["pit", "hole", "hollow", "well", "gulf", "chasm", "abyss"],
|
||||
["push", "shove", "thrust", "prod","poke","butt", "press"],
|
||||
["red", "rouge", "scarlet", "crimson", "flame", "ruby"],
|
||||
["pain", "suffering", "hurt", "misery", "distress", "ache", "discomfort"]]
|
||||
|
||||
words.shuffle
|
||||
|
||||
responses = ["Right","Correct","Fine","Good!","Check"]
|
||||
|
||||
print " " * 33 + "SYNONYM"
|
||||
print " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||
print; print; print
|
||||
print "A synonym of a word means another word in the English"
|
||||
print "language which has the same or very nearly the same meaning."
|
||||
print "I choose a word -- you type a synonym."
|
||||
print "If you can't think a synonym, type the word 'HELP'"
|
||||
print "and I will tell you a synonym."
|
||||
print
|
||||
|
||||
for synonyms in words
|
||||
word = synonyms[0]
|
||||
synonyms = synonyms[1:]
|
||||
responses.shuffle
|
||||
|
||||
print
|
||||
while 1
|
||||
guess = input(" What is a synonym of " + word + "? ").lower
|
||||
if guess == "help" then
|
||||
synonyms.shuffle
|
||||
print "**** A synonym of " + word + " is " + synonyms[0] + "."
|
||||
print
|
||||
else if guess == word or synonyms.indexOf(guess) == null then
|
||||
print " Try again."
|
||||
else
|
||||
print responses[0]
|
||||
break
|
||||
end if
|
||||
end while
|
||||
end for
|
||||
print
|
||||
print "Synonym drill completed."
|
||||
17
00_Alternate_Languages/86_Target/MiniScript/README.md
Normal file
17
00_Alternate_Languages/86_Target/MiniScript/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
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 target.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
```
|
||||
load "target"
|
||||
run
|
||||
```
|
||||
114
00_Alternate_Languages/86_Target/MiniScript/target.ms
Normal file
114
00_Alternate_Languages/86_Target/MiniScript/target.ms
Normal file
@@ -0,0 +1,114 @@
|
||||
degToRad = function(n)
|
||||
return n * pi / 180
|
||||
end function
|
||||
|
||||
radToDeg = function(n)
|
||||
return n * 180 / pi
|
||||
end function
|
||||
|
||||
roundDown = function(n, r)
|
||||
return floor(n / r) * r
|
||||
end function
|
||||
|
||||
getCoord = function(distance, radX, radZ)
|
||||
xc = sin(radZ)*cos(radX)*distance
|
||||
yc = sin(radZ)*sin(radX)*distance
|
||||
zc = cos(radZ)*distance
|
||||
return [xc,yc,zc]
|
||||
end function
|
||||
|
||||
distanceBetween = function (d1,d2)
|
||||
return ((d1[0]-d2[0])^2 + (d1[1]-d2[1])^2 + (d1[2]-d2[2])^2)^.5
|
||||
end function
|
||||
|
||||
coordStr = function(coords)
|
||||
return "X = " + round(coords[0]) +
|
||||
" Y = " + round(coords[1]) + " Z = " + round(coords[2])
|
||||
end function
|
||||
|
||||
print " " * 33 + "TARGET"
|
||||
print " " * 15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
|
||||
print "You are the weapons officer on the Starship Enterprise"
|
||||
print "and this is a test to see how accurae a shot you"
|
||||
print "are in a 3-dimensional range. You will be told"
|
||||
print "the radian offset for the X and Z axes, the location"
|
||||
print "of the target in 3-dimensional rectangular coordinates,"
|
||||
print "the approximate number of degrees from the X and Z"
|
||||
print "axes, and the approximate distance to the target."
|
||||
print "You will then proceed to shoot at the target until it is"
|
||||
print "destroyed!"
|
||||
print; print
|
||||
print "Good luck!"
|
||||
roundToList = [20,10,2,1]
|
||||
ready = true
|
||||
while ready
|
||||
turns = -1
|
||||
radX = rnd * 2 * pi
|
||||
radZ = rnd * 2 * pi
|
||||
print "Radians from X axis = " + radX + " from Z axis = " + radZ
|
||||
|
||||
distance = 100000 * rnd * rnd
|
||||
coords = getCoord(distance, radX, radZ)
|
||||
|
||||
print "Target sighted: Approx Coordinates: " + coordStr(coords)
|
||||
|
||||
gameRunning = true
|
||||
while gameRunning
|
||||
turns += 1
|
||||
if turns >=4 then
|
||||
estDistance = distance
|
||||
else
|
||||
estDistance = roundDown(distance, roundToList[turns])
|
||||
end if
|
||||
|
||||
print " Estimated Distance: " + estDistance
|
||||
print
|
||||
tx = input("Input angle deviation from X in degrees: ").val
|
||||
tz = input("Input angle deviation from Z in degrees: ").val
|
||||
tdist = input("Input distance: ").val
|
||||
print
|
||||
if tdist < 20 then
|
||||
print "You blew yourself up!!"
|
||||
gameRunning = false
|
||||
else
|
||||
tx = degToRad(tx)
|
||||
tz = degToRad(tz)
|
||||
|
||||
print "Radians from X-axis = " + tx + " from Z-axis = " + tz
|
||||
targeted = getCoord(tdist, tx,tz)
|
||||
distBet = distanceBetween(coords, targeted)
|
||||
if distBet > 20 then
|
||||
dx = targeted[0] - coords[0]
|
||||
dy = targeted[1] - coords[1]
|
||||
dz = targeted[2] - coords[2]
|
||||
xMsg = {false: "Shot in front of target ", true: "Shot behind target "}
|
||||
print xMsg[dx<0] + dx + " kilometers."
|
||||
yMsg = {false: "Shot to left of target ", true: "Shot to right of target "}
|
||||
print yMsg[dy<0] + dy + " kilometers."
|
||||
zMsg = {false: "Shot above target ", true: "Shot below target "}
|
||||
print zMsg[dz<0] + dz + " kilometers."
|
||||
|
||||
print "Approx position of explosion: " + coordStr(targeted)
|
||||
print " Distance from target = " + distBet
|
||||
print
|
||||
print
|
||||
|
||||
else
|
||||
print
|
||||
print " * * * HIT * * * Target is non-functional"
|
||||
print
|
||||
print "Distance of explosion from target was " + distBet + "kilometers."
|
||||
print
|
||||
print "Mission accomplished in " + (turns+1) + " shots."
|
||||
print
|
||||
gameRunning = false
|
||||
end if
|
||||
end if
|
||||
end while
|
||||
print
|
||||
ans = input("Ready for next target? ").lower
|
||||
ready = ans and ans[0].lower == "y"
|
||||
print
|
||||
end while
|
||||
@@ -7,10 +7,13 @@ 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 number.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "number"
|
||||
run
|
||||
```
|
||||
16
00_Alternate_Languages/90_Tower/MiniScript/README.md
Normal file
16
00_Alternate_Languages/90_Tower/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 tower.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
load "tower"
|
||||
run
|
||||
202
00_Alternate_Languages/90_Tower/MiniScript/tower.ms
Normal file
202
00_Alternate_Languages/90_Tower/MiniScript/tower.ms
Normal file
@@ -0,0 +1,202 @@
|
||||
kInvalidDisk = 100
|
||||
kNotTopDisk = 200
|
||||
kNotTower = 300
|
||||
kGameOver = 300
|
||||
|
||||
Tower = {"disks": []}
|
||||
Tower.init = function
|
||||
noob = new Tower
|
||||
noob.disks = []
|
||||
return noob
|
||||
end function
|
||||
|
||||
Tower.height = function
|
||||
return self.disks.len
|
||||
end function
|
||||
|
||||
Tower.top = function
|
||||
if self.height == 0 then return 100
|
||||
return self.disks[-1]
|
||||
end function
|
||||
|
||||
Game = {}
|
||||
Game.towers = []
|
||||
Game.numOfDisks = 0
|
||||
Game.rangeOfDisks = []
|
||||
Game.selectedDisk = 0
|
||||
Game.selectedDiskOn = 0
|
||||
Game.selectedTower = 0
|
||||
Game.inputErrors = 0
|
||||
Game.turns = 0
|
||||
|
||||
Game.display = function
|
||||
print
|
||||
for r in range(7,1)
|
||||
rowstr = ""
|
||||
for tower in self.towers
|
||||
if r > tower.height then
|
||||
rowstr += " " * 12 + "#" + " " * 7
|
||||
else
|
||||
spaces = (15 - tower.disks[r-1])/2
|
||||
disks = " " * 4 + tower.disks[r-1]
|
||||
rowstr += disks[-5:] + " " * spaces
|
||||
rowstr += "#" * tower.disks[r-1]
|
||||
rowstr += " " * spaces
|
||||
end if
|
||||
rowstr += " "
|
||||
end for
|
||||
print rowstr
|
||||
end for
|
||||
rowstr = (" " * 5 + "=" * 15 + " ") * 3
|
||||
print rowstr
|
||||
print
|
||||
end function
|
||||
|
||||
Game.init = function(num)
|
||||
if num < 1 or num > 7 then
|
||||
self.inputErrors += 1
|
||||
return false
|
||||
end if
|
||||
Game.towers = []
|
||||
for i in range(0,2)
|
||||
Game.towers.push(Tower.init)
|
||||
end for
|
||||
|
||||
first = self.towers[0]
|
||||
first.disks = range(15, 17 - num * 2, -2)
|
||||
self.numOfDisks = num
|
||||
self.rangeOfDisks = range(17 -num * 2, 15, 2)
|
||||
|
||||
// This game doesn't like to be bothered
|
||||
// and keeps track of how many incorrect inputs
|
||||
// are made before it stops the game
|
||||
self.inputErrors = 0
|
||||
self.turns = 0
|
||||
return true
|
||||
end function
|
||||
|
||||
Game.diskStatus = function
|
||||
n = self.selectedDisk
|
||||
if self.rangeOfDisks.indexOf(n) == null then
|
||||
self.inputErrors +=1
|
||||
return kInvalidDisk
|
||||
end if
|
||||
self.inputErrors = 0
|
||||
for i in range(0, self.towers.len - 1)
|
||||
if self.towers[i].top == n then
|
||||
self.selectedDiskOn = i
|
||||
self.inputErrors = 0
|
||||
return i
|
||||
end if
|
||||
end for
|
||||
return kNotTopDisk
|
||||
end function
|
||||
|
||||
Game.pickDisk = function
|
||||
self.selectedDisk = input("Which disk would you like to move? ").val
|
||||
return self.diskStatus
|
||||
end function
|
||||
|
||||
Game.pickTower = function
|
||||
self.selectedTower = input("Place disk on which needle? ").val - 1
|
||||
if not(0<= self.selectedTower and self.selectedTower <= 2) then
|
||||
self.inputErrors += 1
|
||||
return kNotTower
|
||||
end if
|
||||
return self.selectedTower
|
||||
end function
|
||||
|
||||
Game.doneWithYou = function
|
||||
return self.inputErrors >= 2
|
||||
end function
|
||||
|
||||
Game.isFinish = function
|
||||
return self.towers[0].disks.len == 0 and self.towers[1].disks.len == 0
|
||||
end function
|
||||
|
||||
Game.move = function
|
||||
print "Take turn # " + (self.turns + 1)
|
||||
status = -1
|
||||
self.inputErrors = 0
|
||||
while 1
|
||||
status = self.pickDisk
|
||||
if 0 <= status and status <= 2 then break
|
||||
if status == kInvalidDisk and self.doneWithYou then
|
||||
print "Stop wasting my time. Go bother someone else."
|
||||
exit
|
||||
else if status == kInvalidDisk then
|
||||
msg = "Illegal entry ... you may only type "
|
||||
msg += self.rangeOfDisks[0:-1].join(",") + " "
|
||||
if self.rangeOfDisks.len > 1 then
|
||||
msg += "or "
|
||||
end if
|
||||
msg += "15"
|
||||
print msg
|
||||
else if status == kNotTopDisk then
|
||||
print "That disk is below another. Make another choice."
|
||||
end if
|
||||
end while
|
||||
|
||||
self.inputErrors = 0
|
||||
while 1
|
||||
status = self.pickTower
|
||||
if 0 <= status and status <= 2 then break
|
||||
if status == kNotTower and self.doneWithYou then
|
||||
print "I tried to warn you. But you wouldn't listen."
|
||||
print "Bye bye, big shot."
|
||||
exit
|
||||
else if status == kNotTower then
|
||||
print "I'll assume you hit the wrong key this time. But watch it,"
|
||||
print "I only allow one mistake."
|
||||
end if
|
||||
end while
|
||||
|
||||
if self.selectedDisk > self.towers[self.selectedTower].top then
|
||||
print "You can't place a larger disk on a top of a smaller one,"
|
||||
print "it may crush it!"
|
||||
else
|
||||
n=self.towers[self.selectedDiskOn].disks.pop
|
||||
self.towers[self.selectedTower].disks.push(n)
|
||||
self.turns += 1
|
||||
self.inputErrors = 0
|
||||
end if
|
||||
end function
|
||||
|
||||
|
||||
print " " * 33 + "TOWERS"
|
||||
print " " * 15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print
|
||||
print "You must transfer the disks from the left to the right"
|
||||
print "tower, one at a time, never putting a larger disk on a"
|
||||
print "smaller disk."
|
||||
print
|
||||
|
||||
ans = "Y"
|
||||
while ans[0].upper == "Y"
|
||||
while 1
|
||||
disks = input("How many disks do you want to move (7 is MAX)? ").val
|
||||
status = Game.init(disks)
|
||||
if status == false and Game.doneWithYou then
|
||||
print "All right, wise guy, if you can't play the game right, I'll"
|
||||
print "take my puzzle and go home. So long."
|
||||
exit
|
||||
else if not status then
|
||||
print "Sorry, but I can't do that job for you"
|
||||
else
|
||||
break
|
||||
end if
|
||||
end while
|
||||
|
||||
while not Game.isFinish
|
||||
Game.display
|
||||
|
||||
Game.move
|
||||
end while
|
||||
Game.display
|
||||
print "Congratulations!"
|
||||
print "You performed the task in " + Game.turns + " moves."
|
||||
print
|
||||
ans = input("Play again (Yes or No)? ") + " "
|
||||
end while
|
||||
print
|
||||
print "Thanks for the game!"
|
||||
@@ -7,13 +7,15 @@ 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 train.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "train"
|
||||
run
|
||||
|
||||
```
|
||||
3. "Try-It!" page on the web:
|
||||
Go to https://miniscript.org/tryit/, clear the default program from the source code editor, paste in the contents of train.ms, and click the "Run Script" button.
|
||||
|
||||
@@ -7,10 +7,13 @@ 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 trap.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 MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
```
|
||||
load "trap"
|
||||
run
|
||||
```
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user