mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-17 15:32:18 -08:00
Update readmes
This commit is contained in:
@@ -16,3 +16,27 @@ http://www.vintage-basic.net/games.html
|
||||
#### Porting Notes
|
||||
|
||||
(please note any difficulties or challenges in porting here)
|
||||
|
||||
##### Randomization Logic
|
||||
|
||||
The BASIC code uses an interesting technique for choosing the random coordinates for the mines. The first coordinate is
|
||||
chosen like this:
|
||||
|
||||
```basic
|
||||
380 LET A=INT(3*(RND(X)))
|
||||
390 IF A<>0 THEN 410
|
||||
400 LET A=3
|
||||
```
|
||||
|
||||
where line 410 is the start of a similar block of code for the next coordinate. The behaviour of `RND(X)` depends on the
|
||||
value of `X`. If `X` is greater than zero then it returns a random value between 0 and 1. If `X` is zero it returns the
|
||||
last random value generated, or 0 if no value has yet been generated.
|
||||
|
||||
If `X` is 1, therefore, the first line above set `A` to 0, 1, or 2. The next 2 lines replace a 0 with a 3. The
|
||||
replacement values varies for the different coordinates with the result that the random selection is biased towards a
|
||||
specific set of points. If `X` is 0, the `RND` calls all return 0, so the coordinates are the known. It appears that
|
||||
this technique was probably used to allow testing the game with a well-known set of locations for the mines. However, in
|
||||
the code as it comes to us, the value of `X` is never set and is thus 0, so the mine locations are never randomized.
|
||||
|
||||
The C# port implements the biased randomized mine locations, as seems to be the original intent, but includes a
|
||||
command-line switch to enable the deterministic execution as well.
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
||||
|
||||
Conversion to [Microsoft C#](https://docs.microsoft.com/en-us/dotnet/csharp/)
|
||||
|
||||
#### Execution
|
||||
|
||||
As noted in the main Readme file, the randomization code in the BASIC program has a switch (the variable `X`) that
|
||||
allows the game to be run in a deterministic (non-random) mode.
|
||||
|
||||
Running the C# port without command-line parameters will play the game with random mine locations.
|
||||
|
||||
Running the port with a `-d` command-line switch will run the game with non-random mine locations.
|
||||
|
||||
Reference in New Issue
Block a user