Created Mine Map and ReactivePlanner

This commit is contained in:
2020-12-15 18:19:07 -07:00
parent 45eca3b572
commit 4edcef4664
24 changed files with 309 additions and 84 deletions

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
namespace ConsoleApp.Maps
{
public class MineMap : IMineMap
{
private int _mineCount;
private int _x;
private int _y;
public bool[,] Map { get; }
public MineMap(int x, int y, double minePercentage)
{
_x = x;
_y = y;
_mineCount = x*y*((int)minePercentage/100);
Map = new bool[x, y];
Map.Fill2DArray(false);
PlaceMines();
}
private void PlaceMines()
{
var rand = new Random();
for (int i = 0; i < _mineCount; i++)
{
var x = rand.Next(_x);
var y = rand.Next(_y);
Map[x, y] = true;
}
}
}
}