Now able to create png to see larger population easely
This commit is contained in:
@@ -60,8 +60,10 @@ namespace SharpPropagation
|
|||||||
|
|
||||||
public void Generate()
|
public void Generate()
|
||||||
{
|
{
|
||||||
|
//Parallel.For(0, Dimensions.Width, x =>
|
||||||
for (int x = 0; x < Dimensions.Width; x++)
|
for (int x = 0; x < Dimensions.Width; x++)
|
||||||
{
|
{
|
||||||
|
//Parallel.For(0, Dimensions.Height, y =>
|
||||||
for (int y = 0; y < Dimensions.Height; y++)
|
for (int y = 0; y < Dimensions.Height; y++)
|
||||||
{
|
{
|
||||||
//The ratios will not be exact, for example someone who wants 100% infected 100% immune and 100% dead, he will have 100% dead because they are overwriting each others
|
//The ratios will not be exact, for example someone who wants 100% infected 100% immune and 100% dead, he will have 100% dead because they are overwriting each others
|
||||||
@@ -96,8 +98,8 @@ namespace SharpPropagation
|
|||||||
Humans[x, y] = new Human(new Point(x, y), Human.State.Normal);
|
Humans[x, y] = new Human(new Point(x, y), Human.State.Normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}//);
|
||||||
}
|
}//);
|
||||||
}
|
}
|
||||||
public int[] Propagate()
|
public int[] Propagate()
|
||||||
{
|
{
|
||||||
@@ -108,7 +110,7 @@ namespace SharpPropagation
|
|||||||
//Parallel.For(0, Dimensions.Width,x =>
|
//Parallel.For(0, Dimensions.Width,x =>
|
||||||
for (int x = 0; x < Dimensions.Width; x++)
|
for (int x = 0; x < Dimensions.Width; x++)
|
||||||
{
|
{
|
||||||
//Parallel.For(0, Dimensions.Width,y =>
|
//Parallel.For(0, Dimensions.Height,y =>
|
||||||
for (int y = 0; y < Dimensions.Height; y++)
|
for (int y = 0; y < Dimensions.Height; y++)
|
||||||
{
|
{
|
||||||
switch (Humans[x, y].PresentState)
|
switch (Humans[x, y].PresentState)
|
||||||
@@ -158,7 +160,6 @@ namespace SharpPropagation
|
|||||||
/// ###
|
/// ###
|
||||||
|
|
||||||
List<Point> potentialInfections = new List<Point>();
|
List<Point> potentialInfections = new List<Point>();
|
||||||
//potentialInfections.Add(Humans[person.Position.X,person.Position.Y]);
|
|
||||||
|
|
||||||
potentialInfections.Add(new Point(person.X - 1, person.Y - 1)); //Top Left
|
potentialInfections.Add(new Point(person.X - 1, person.Y - 1)); //Top Left
|
||||||
potentialInfections.Add(new Point(person.X, person.Y - 1)); //Top
|
potentialInfections.Add(new Point(person.X, person.Y - 1)); //Top
|
||||||
@@ -256,6 +257,39 @@ namespace SharpPropagation
|
|||||||
{
|
{
|
||||||
return rnd.Next(0, CORRECTED_PERCENTAGE) < rate;
|
return rnd.Next(0, CORRECTED_PERCENTAGE) < rate;
|
||||||
}
|
}
|
||||||
|
public void DisplayPng(string name)
|
||||||
|
{
|
||||||
|
Bitmap bitmap = new Bitmap(Dimensions.Width,Dimensions.Height);
|
||||||
|
Color color = new Color();
|
||||||
|
using (Graphics g = Graphics.FromImage(bitmap))
|
||||||
|
{
|
||||||
|
//Parallel.For(0, Dimensions.Width, x =>
|
||||||
|
for (int x = 0; x < Dimensions.Width; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < Dimensions.Height; y++)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (Humans[x, y].PresentState)
|
||||||
|
{
|
||||||
|
case Human.State.Normal:
|
||||||
|
color = Color.Green;
|
||||||
|
break;
|
||||||
|
case Human.State.Infected:
|
||||||
|
color = Color.Red;
|
||||||
|
break;
|
||||||
|
case Human.State.Immune:
|
||||||
|
color = Color.Blue;
|
||||||
|
break;
|
||||||
|
case Human.State.Dead:
|
||||||
|
color = Color.Black;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bitmap.SetPixel(x, y, color);
|
||||||
|
}
|
||||||
|
}//);
|
||||||
|
}
|
||||||
|
bitmap.Save(name + ".png",System.Drawing.Imaging.ImageFormat.Png);
|
||||||
|
}
|
||||||
public void Display()
|
public void Display()
|
||||||
{
|
{
|
||||||
//int[] stats = GetStats();
|
//int[] stats = GetStats();
|
||||||
@@ -266,9 +300,12 @@ namespace SharpPropagation
|
|||||||
if (Plague != null)
|
if (Plague != null)
|
||||||
Console.WriteLine(Plague);
|
Console.WriteLine(Plague);
|
||||||
Console.Write("\n");
|
Console.Write("\n");
|
||||||
|
|
||||||
|
//Parallel.For(0, Dimensions.Width, x =>
|
||||||
for (int x = 0; x < Dimensions.Width; x++)
|
for (int x = 0; x < Dimensions.Width; x++)
|
||||||
{
|
{
|
||||||
Console.Write("\n");
|
Console.Write("\n");
|
||||||
|
//Parallel.For(0, Dimensions.height, y =>
|
||||||
for (int y = 0; y < Dimensions.Height; y++)
|
for (int y = 0; y < Dimensions.Height; y++)
|
||||||
{
|
{
|
||||||
switch (Humans[x, y].PresentState)
|
switch (Humans[x, y].PresentState)
|
||||||
@@ -297,8 +334,8 @@ namespace SharpPropagation
|
|||||||
Console.Write(sprite);
|
Console.Write(sprite);
|
||||||
//We reset to the default
|
//We reset to the default
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
}
|
}//);
|
||||||
}
|
}//);
|
||||||
Console.Write(Environment.NewLine);
|
Console.Write(Environment.NewLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ namespace SharpPropagation
|
|||||||
Size populationSize = new Size(1000,1000);
|
Size populationSize = new Size(1000,1000);
|
||||||
Population peoples = new Population(populationSize,random,10,10,5);
|
Population peoples = new Population(populationSize,random,10,10,5);
|
||||||
peoples.SetDisease(new Disease(random,20,10,5,"Chick Chicken"));
|
peoples.SetDisease(new Disease(random,20,10,5,"Chick Chicken"));
|
||||||
|
string ImagesLocation = "Test/";
|
||||||
//peoples.Display();
|
//peoples.Display();
|
||||||
|
|
||||||
Console.WriteLine($"Propagation started with {populationSize.Width} x {populationSize.Height} humans ({populationSize.Width*populationSize.Height})");
|
Console.WriteLine($"Propagation started with {populationSize.Width} x {populationSize.Height} humans ({populationSize.Width*populationSize.Height})");
|
||||||
int[] stats;
|
int[] stats;
|
||||||
int steps = 0;
|
int steps = 0;
|
||||||
@@ -31,6 +33,7 @@ namespace SharpPropagation
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
peoples.DisplayPng(ImagesLocation+"Test_"+steps);
|
||||||
}
|
}
|
||||||
//peoples.Display();
|
//peoples.Display();
|
||||||
Console.WriteLine($"Propagation finished in {steps}");
|
Console.WriteLine($"Propagation finished in {steps}");
|
||||||
|
|||||||
Reference in New Issue
Block a user