mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 07:29:02 -08:00
Add command-line switch
This commit is contained in:
@@ -5,4 +5,6 @@ global using static Cube.Resources.Resource;
|
||||
|
||||
using Cube;
|
||||
|
||||
new Game(new ConsoleIO(), new RandomNumberGenerator()).Play();
|
||||
IRandom random = args.Contains("--non-random") ? new ZerosGenerator() : new RandomNumberGenerator();
|
||||
|
||||
new Game(new ConsoleIO(), random).Play();
|
||||
|
||||
@@ -9,4 +9,4 @@ 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.
|
||||
Running the port with a `--non-random` command-line switch will run the game with non-random mine locations.
|
||||
|
||||
10
30_Cube/csharp/ZerosGenerator.cs
Normal file
10
30_Cube/csharp/ZerosGenerator.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Cube;
|
||||
|
||||
internal class ZerosGenerator : IRandom
|
||||
{
|
||||
public float NextFloat() => 0;
|
||||
|
||||
public float PreviousFloat() => 0;
|
||||
|
||||
public void Reseed(int seed) { }
|
||||
}
|
||||
Reference in New Issue
Block a user