Commit 7cf525b9 by adbaga

mines

parent 7f3afe5d
......@@ -3,14 +3,9 @@
<component name="ChangeListManager">
<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$/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.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.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/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" />
......@@ -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.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/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.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" />
......@@ -124,7 +117,8 @@
<workItem from="1570828559519" duration="1080000" />
<workItem from="1570969640551" duration="4588000" />
<workItem from="1571052402368" duration="4070000" />
<workItem from="1571651125428" duration="6192000" />
<workItem from="1571651125428" duration="10380000" />
<workItem from="1571827801729" duration="4988000" />
</task>
<task id="LOCAL-00001" summary="yes">
<created>1570973690674</created>
......@@ -147,7 +141,14 @@
<option name="project" value="LOCAL" />
<updated>1570999581348</updated>
</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 />
</component>
<component name="TypeScriptGeneratedFilesManager">
......@@ -170,10 +171,10 @@
</component>
<component name="VcsManagerConfiguration">
<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="commit 3" />
<option name="LAST_COMMIT_MESSAGE" value="commit 3" />
<MESSAGE value="yes" />
<option name="LAST_COMMIT_MESSAGE" value="yes" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
......
......@@ -51,128 +51,70 @@ namespace Engine
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();
int[,] mineLoc = new int[height,width];
do
{
int minePosY = random.Next(height);
int minePosX = random.Next(width);
int[,] mineLoc = new int[minePosY,minePosX];
mineCount++;
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];
}
while (mineCount <= numOfMines) ;
/* for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
do
{
Console.Write(string.Format("{0}\t", mineLoc[minePosY, minePosX]));
}
int minePosX = random.Next(width);
int minePosY = random.Next(height);
// Make sure we haven't already set this position
if (mineLoc[minePosX, minePosY] != 1)
{
mineLoc[minePosX, minePosY] = 1;
mineCount++;
}
} while (mineCount <= numOfMines);
*/
_minesSet = !_minesSet;
var done = true;
do{
Console.WriteLine($"There are {numOfMines} mines ");
}
/*public class ReceiveInput
{
Console.WriteLine("Board height (Min. 8): ");
Console.WriteLine(">");
var checkHeight = Console.ReadLine();
int height = 0;
if (!int.TryParse(checkHeight, out height))
{
Console.WriteLine("Not an integer");
}
else
{
height = Convert.ToInt32(checkHeight);
}
var checkWidth = Console.ReadLine();
int width = 0;
if (!int.TryParse(checkWidth, out width))
{
Console.WriteLine("Not an integer");
}
else
{
width = Convert.ToInt32(checkWidth);
}
//var width = Convert.ToInt32(ReadLine());
var doIt = false;
Console.WriteLine("Check the tile");
Console.WriteLine("Y location:");
int playerMoveY = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("X location:");
int playerMoveX = Convert.ToInt32(Console.ReadLine());
do
{
int[,] checkMines = new int[playerMoveY,playerMoveX];
if (height < 8 || width < 8)
if (checkMines == mineLoc)
{
Console.WriteLine("Too small. Minimal is 8x8");
break;
}
done = false;
else if(height > 30 || width > 30)
{
Console.WriteLine("Too big. Maximum size is 30x30");
break;
}
} while (done = true);
} while (doIt = false);
var game = new BoardDim(height, width);
return mineLoc;
//previously game
var done = false;
}
*/
public void checkTile(int posY, int posX)
{
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
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(">");
......@@ -92,7 +86,7 @@ namespace IDoMinesweeper
int height = 0;
if (!int.TryParse(checkHeight, out height))
{
Console.WriteLine("Not an integer");
WriteLine("Not an integer");
}
else
......@@ -148,32 +142,26 @@ namespace IDoMinesweeper
} 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);
GameUI.PrintBoard(game);
game.MinesSetter(height, width);
Console.WriteLine();
var done = false;
/*var done = false;
do{
Clear();
GameUI.PrintBoard(game);
game.MinesSetter(height, width);
Console.WriteLine("Check the tile");
......@@ -188,17 +176,20 @@ namespace IDoMinesweeper
//done = userYint == 0 && userXint == 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 "GAME OVER!!";
return "";
}
......
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