Commit 7cf525b9 by adbaga

mines

parent 7f3afe5d
...@@ -3,14 +3,9 @@ ...@@ -3,14 +3,9 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="a128ca0c-796d-4da2-8db0-062a4837d105" name="Default Changelist" comment=""> <list default="true" id="a128ca0c-796d-4da2-8db0-062a4837d105" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.IDoMinesweeper/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.IDoMinesweeper/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/.idea.IDoMinesweeper/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.IDoMinesweeper/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ConsoleUserInt/GameUI.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleUserInt/GameUI.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ConsoleUserInt/bin/Debug/netcoreapp3.0/ConsoleUserInt.dll" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleUserInt/bin/Debug/netcoreapp3.0/ConsoleUserInt.dll" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ConsoleUserInt/bin/Debug/netcoreapp3.0/ConsoleUserInt.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleUserInt/bin/Debug/netcoreapp3.0/ConsoleUserInt.pdb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ConsoleUserInt/bin/Debug/netcoreapp3.0/Game.dll" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleUserInt/bin/Debug/netcoreapp3.0/Game.dll" afterDir="false" /> <change beforePath="$PROJECT_DIR$/ConsoleUserInt/bin/Debug/netcoreapp3.0/Game.dll" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleUserInt/bin/Debug/netcoreapp3.0/Game.dll" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ConsoleUserInt/bin/Debug/netcoreapp3.0/Game.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleUserInt/bin/Debug/netcoreapp3.0/Game.pdb" afterDir="false" /> <change beforePath="$PROJECT_DIR$/ConsoleUserInt/bin/Debug/netcoreapp3.0/Game.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleUserInt/bin/Debug/netcoreapp3.0/Game.pdb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ConsoleUserInt/obj/Debug/netcoreapp3.0/ConsoleUserInt.csprojAssemblyReference.cache" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleUserInt/obj/Debug/netcoreapp3.0/ConsoleUserInt.csprojAssemblyReference.cache" afterDir="false" /> <change beforePath="$PROJECT_DIR$/ConsoleUserInt/obj/Debug/netcoreapp3.0/ConsoleUserInt.csprojAssemblyReference.cache" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleUserInt/obj/Debug/netcoreapp3.0/ConsoleUserInt.csprojAssemblyReference.cache" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ConsoleUserInt/obj/Debug/netcoreapp3.0/ConsoleUserInt.dll" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleUserInt/obj/Debug/netcoreapp3.0/ConsoleUserInt.dll" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ConsoleUserInt/obj/Debug/netcoreapp3.0/ConsoleUserInt.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/ConsoleUserInt/obj/Debug/netcoreapp3.0/ConsoleUserInt.pdb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/Engine.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Engine.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Game/Engine.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Engine.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/bin/Debug/netcoreapp3.0/Game.dll" beforeDir="false" afterPath="$PROJECT_DIR$/Game/bin/Debug/netcoreapp3.0/Game.dll" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Game/bin/Debug/netcoreapp3.0/Game.dll" beforeDir="false" afterPath="$PROJECT_DIR$/Game/bin/Debug/netcoreapp3.0/Game.dll" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/bin/Debug/netcoreapp3.0/Game.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/Game/bin/Debug/netcoreapp3.0/Game.pdb" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Game/bin/Debug/netcoreapp3.0/Game.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/Game/bin/Debug/netcoreapp3.0/Game.pdb" afterDir="false" />
...@@ -18,8 +13,6 @@ ...@@ -18,8 +13,6 @@
<change beforePath="$PROJECT_DIR$/Game/obj/Debug/netcoreapp3.0/Game.dll" beforeDir="false" afterPath="$PROJECT_DIR$/Game/obj/Debug/netcoreapp3.0/Game.dll" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Game/obj/Debug/netcoreapp3.0/Game.dll" beforeDir="false" afterPath="$PROJECT_DIR$/Game/obj/Debug/netcoreapp3.0/Game.dll" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Game/obj/Debug/netcoreapp3.0/Game.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/Game/obj/Debug/netcoreapp3.0/Game.pdb" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Game/obj/Debug/netcoreapp3.0/Game.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/Game/obj/Debug/netcoreapp3.0/Game.pdb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/IDoMinesweeper/Program.cs" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/Program.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/IDoMinesweeper/Program.cs" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/Program.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/ConsoleUserInt.dll" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/ConsoleUserInt.dll" afterDir="false" />
<change beforePath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/ConsoleUserInt.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/ConsoleUserInt.pdb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/Game.dll" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/Game.dll" afterDir="false" /> <change beforePath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/Game.dll" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/Game.dll" afterDir="false" />
<change beforePath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/Game.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/Game.pdb" afterDir="false" /> <change beforePath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/Game.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/Game.pdb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/IDoMinesweeper.dll" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/IDoMinesweeper.dll" afterDir="false" /> <change beforePath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/IDoMinesweeper.dll" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/IDoMinesweeper.dll" afterDir="false" />
...@@ -124,7 +117,8 @@ ...@@ -124,7 +117,8 @@
<workItem from="1570828559519" duration="1080000" /> <workItem from="1570828559519" duration="1080000" />
<workItem from="1570969640551" duration="4588000" /> <workItem from="1570969640551" duration="4588000" />
<workItem from="1571052402368" duration="4070000" /> <workItem from="1571052402368" duration="4070000" />
<workItem from="1571651125428" duration="6192000" /> <workItem from="1571651125428" duration="10380000" />
<workItem from="1571827801729" duration="4988000" />
</task> </task>
<task id="LOCAL-00001" summary="yes"> <task id="LOCAL-00001" summary="yes">
<created>1570973690674</created> <created>1570973690674</created>
...@@ -147,7 +141,14 @@ ...@@ -147,7 +141,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1570999581348</updated> <updated>1570999581348</updated>
</task> </task>
<option name="localTasksCounter" value="4" /> <task id="LOCAL-00004" summary="yes">
<created>1571657780059</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1571657780059</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
...@@ -170,10 +171,10 @@ ...@@ -170,10 +171,10 @@
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<option name="LOCAL_CHANGES_DETAILS_PREVIEW_SHOWN" value="true" /> <option name="LOCAL_CHANGES_DETAILS_PREVIEW_SHOWN" value="true" />
<MESSAGE value="yes" />
<MESSAGE value="Adding validation input: Doesn't accept non int and set maximum size of the board" /> <MESSAGE value="Adding validation input: Doesn't accept non int and set maximum size of the board" />
<MESSAGE value="commit 3" /> <MESSAGE value="commit 3" />
<option name="LAST_COMMIT_MESSAGE" value="commit 3" /> <MESSAGE value="yes" />
<option name="LAST_COMMIT_MESSAGE" value="yes" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
......
...@@ -46,133 +46,75 @@ namespace Engine ...@@ -46,133 +46,75 @@ namespace Engine
return result; return result;
} }
public void MinesSetter(int height, int width) //to generate mines randomly
//private static Random random = new Random();
public int[,] MinesSetter(int height, int width)
{ {
int mineCount = 0;
int numOfMines = (height*width) / 8;
Random random = new Random(); Random random = new Random();
int[,] mineLoc = new int[height,width];
int mineCount = 0;
int numOfMines = height * width / 3;
Console.WriteLine($"There are {numOfMines} mines");
Console.WriteLine($"The size is {height} x {width}");
var results = new int[width, height];
do do
{ {
int minePosY = random.Next(height);
int minePosX = random.Next(width); int minePosX = random.Next(width);
int minePosY = random.Next(height);
int[,] mineLoc = new int[minePosY,minePosX]; // Make sure we haven't already set this position
if (mineLoc[minePosX, minePosY] != 1)
mineCount++;
}
while (mineCount <= numOfMines) ;
/* for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{ {
Console.Write(string.Format("{0}\t", mineLoc[minePosY, minePosX])); mineLoc[minePosX, minePosY] = 1;
mineCount++;
} }
} while (mineCount <= numOfMines);
}
*/
_minesSet = !_minesSet;
Console.WriteLine($"There are {numOfMines} mines ");
}
/*public class ReceiveInput
{
Console.WriteLine("Board height (Min. 8): "); var done = true;
Console.WriteLine(">"); do{
var checkHeight = Console.ReadLine();
int height = 0;
if (!int.TryParse(checkHeight, out height))
{
Console.WriteLine("Not an integer");
}
else
{
Console.WriteLine("Check the tile");
height = Convert.ToInt32(checkHeight); Console.WriteLine("Y location:");
} int playerMoveY = Convert.ToInt32(Console.ReadLine());
var checkWidth = Console.ReadLine(); Console.WriteLine("X location:");
int width = 0; int playerMoveX = Convert.ToInt32(Console.ReadLine());
if (!int.TryParse(checkWidth, out width))
{
Console.WriteLine("Not an integer");
}
else
{
width = Convert.ToInt32(checkWidth);
}
//var width = Convert.ToInt32(ReadLine());
var doIt = false;
do
{
if (height < 8 || width < 8) int[,] checkMines = new int[playerMoveY,playerMoveX];
{
Console.WriteLine("Too small. Minimal is 8x8");
break;
}
else if(height > 30 || width > 30)
if (checkMines == mineLoc)
{ {
Console.WriteLine("Too big. Maximum size is 30x30"); done = false;
break;
}
} while (doIt = false);
var game = new BoardDim(height, width);
//previously game
var done = false; }
}
*/
} while (done = true);
public void checkTile(int posY, int posX) return mineLoc;
{
var done = -1;
do
{
//(Board[posY, posX] != CellState.Mine);
} while (done < 0);
//so, now I need to make this check tile to compare the user input and stored array
} }
} }
......
...@@ -79,12 +79,6 @@ namespace IDoMinesweeper ...@@ -79,12 +79,6 @@ namespace IDoMinesweeper
static string TestGame() static string TestGame()
{ {
// do do-while and if it's correct it'll be done. Otherwise, it's gonna keep asking for input''''
//var customizeBoard = new Engine.ReceiveInput(); would be used for
//future improvement to check and
//validate input
WriteLine("Board height (Min. 8): "); WriteLine("Board height (Min. 8): ");
WriteLine(">"); WriteLine(">");
...@@ -92,7 +86,7 @@ namespace IDoMinesweeper ...@@ -92,7 +86,7 @@ namespace IDoMinesweeper
int height = 0; int height = 0;
if (!int.TryParse(checkHeight, out height)) if (!int.TryParse(checkHeight, out height))
{ {
Console.WriteLine("Not an integer"); WriteLine("Not an integer");
} }
else else
...@@ -148,33 +142,27 @@ namespace IDoMinesweeper ...@@ -148,33 +142,27 @@ namespace IDoMinesweeper
} while (doIt = false); } while (doIt = false);
//still need improvement. If I put string, it'll say not only "not int"
//but also "Too small" which is weird
//and do while doesn't work as my expectation yet
//I guess it's time to start making better architecture''
var game = new BoardDim(height, width); var game = new BoardDim(height, width);
GameUI.PrintBoard(game);
game.MinesSetter(height, width);
Console.WriteLine();
var done = false;
do{
Clear();
GameUI.PrintBoard(game);
game.MinesSetter(height, width);
/*var done = false;
do{
Clear();
Console.WriteLine("Check the tile"); Console.WriteLine("Check the tile");
Console.WriteLine("Y location:"); Console.WriteLine("Y location:");
...@@ -188,17 +176,20 @@ namespace IDoMinesweeper ...@@ -188,17 +176,20 @@ namespace IDoMinesweeper
//done = userYint == 0 && userXint == 0; //done = userYint == 0 && userXint == 0;
//done when it gets one mine at least. it'll turn the value from -1 to 0 //done when it gets one mine at least. it'll turn the value from -1 to 0
done = true;
} while (!done); } while (true);
*/
Console.WriteLine("GameOver");
return "";
return "GAME OVER!!";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment