Skip to content

Commit

Permalink
Merge pull request #13 from Agwen12/added-parameters-to-config
Browse files Browse the repository at this point in the history
Added parameters to config
  • Loading branch information
proman3419 authored May 11, 2022
2 parents 13189af + 0278e62 commit dd7038e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
17 changes: 15 additions & 2 deletions Fungi growth simulation/Assets/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@

public class Config : MonoBehaviour
{
public static float changeDirectionProbability = 0.2f;
public static int randomSeed = 2137;
public static float ChangeDirectionProbability = 0.04f;
public static float BranchingFactor = 0.02f;
public static int RandomSeed = 2137;

// Start is called before the first frame update
void Start()
{
Application.targetFrameRate = 10;
}

// Update is called once per frame
void Update()
{

}
}
2 changes: 1 addition & 1 deletion Fungi growth simulation/Assets/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public class Helper
{
public static Random Rnd = new Random(Config.randomSeed);
public static Random Rnd = new Random(Config.RandomSeed);

// https://stackoverflow.com/questions/218060/random-gaussian-variables
public static float SampleFromNormalDistribution(double mean, double stdDev)
Expand Down
4 changes: 2 additions & 2 deletions Fungi growth simulation/Assets/Mushroom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void Update()
Vector3 currPosition = GameObject.transform.position;
Vector3 direction = currPosition - parentPosition;

if (Helper.Rnd.NextDouble() < 0.03f)
if (Helper.Rnd.NextDouble() < Config.BranchingFactor)
{ //Branch
Vector3[] branchDirections = DirectionMethods.GetBranchDirection(Direction);
Vector3 childPosition1 = currPosition + branchDirections[0].normalized;
Expand All @@ -53,7 +53,7 @@ void Update()
//Standart growth
float angle = Helper.SampleFromNormalDistribution(56, 17);
// Decide if we change direction
if (Helper.Rnd.NextDouble() < 0.04f)
if (Helper.Rnd.NextDouble() < Config.ChangeDirectionProbability)
Direction = DirectionMethods.GetRandomPossibleDirection(Direction);
Quaternion rotation = Quaternion.AngleAxis(angle, DirectionMethods.ToVector3(Direction));

Expand Down

0 comments on commit dd7038e

Please sign in to comment.