diff --git a/Assets/Scripts/Models/LevelGenerator.cs b/Assets/Scripts/Models/LevelGenerator.cs index 6e8ffb3..584540e 100644 --- a/Assets/Scripts/Models/LevelGenerator.cs +++ b/Assets/Scripts/Models/LevelGenerator.cs @@ -10,6 +10,9 @@ namespace DeathBook.Model private float probability; private float radius; + private const float minConnTime = 3; + private const float maxConnTime = 20; + public Level GenerateLevel(int numPeople, int avgFriends, float probability, float radius) { this.numPeople = numPeople; @@ -48,7 +51,8 @@ namespace DeathBook.Model x = Mathf.Cos(longitude) * r; y = Mathf.Sin(longitude) * r; - p = new Person(i, x, y, z); + p = CreatePerson(i, x, y, z); + people.Add(p); z -= dz; @@ -123,6 +127,17 @@ namespace DeathBook.Model p2.AddFriendship(f); return f; } + + private Person CreatePerson(int id, float x, float y, float z) + { + Vector3 pos = new Vector3(x, y, z); + //Vector2 times = + + //Person p = new Person(id, pos,); + Person p = new Person(id); + + return p; + } } internal class DistanceNode diff --git a/Assets/Scripts/Models/Person.cs b/Assets/Scripts/Models/Person.cs index 2afc59b..27c1866 100644 --- a/Assets/Scripts/Models/Person.cs +++ b/Assets/Scripts/Models/Person.cs @@ -9,22 +9,21 @@ namespace DeathBook.Model private string name; private List friendList = new List(); public Vector3 initialPosition; + public float connectionTime; + public float disconnectionTime; + public float awarenessLevel; + public bool alive; + public bool connected; + public int numFriends; - private int timeBetweenPosts; // f = 1/T; - private int connectionTime; - private int disconnectionTime; - private int awarenessLevel; - private bool alive; + public int timeBetweenPosts; // f = 1/T; + public float importance; // Size of the quad private int happiness; - private bool connected; - //private Node node; - - public Person(int id, float x, float y, float z) + public Person(int id) { this.id = id; - initialPosition = new Vector3(x, y, z); } public void AddFriendship(Friendship f) diff --git a/Assets/Scripts/Models/Utils.cs b/Assets/Scripts/Models/Utils.cs new file mode 100644 index 0000000..08f33ca --- /dev/null +++ b/Assets/Scripts/Models/Utils.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace DeathBook.Model +{ + public class Utils + { + public static void Test() + { + float mean = 50; + float range = 50; + int numSteps = 2; + + int numTries = 100; + + for (int i = 0; i < numTries; i++) + { + Debug.Log(GetRandomValue(mean, range, numSteps)); + } + } + + public static float GetRandomValue(float mean, float range, int numSteps) + { + float sum = 0; + for (int i = 0; i < numSteps; i++) + { + sum += Random.value; + } + return (sum / numSteps * 2 - 1) * range + mean; + } + } +} diff --git a/Assets/Scripts/Models/Utils.cs.meta b/Assets/Scripts/Models/Utils.cs.meta new file mode 100644 index 0000000..18e99e8 --- /dev/null +++ b/Assets/Scripts/Models/Utils.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 710c7285af897124a8e7e5c5ecf05109 +timeCreated: 1439506723 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Tests/SRTest.cs b/Assets/Tests/SRTest.cs new file mode 100644 index 0000000..820640d --- /dev/null +++ b/Assets/Tests/SRTest.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using System.Collections; +using DeathBook.Model; + +public class SRTest : MonoBehaviour { + + // Use this for initialization + void Start () { + Utils.Test(); + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/Assets/Tests/SRTest.cs.meta b/Assets/Tests/SRTest.cs.meta new file mode 100644 index 0000000..75d7474 --- /dev/null +++ b/Assets/Tests/SRTest.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43fe8f02e31afb5499ff01247a389c14 +timeCreated: 1439506745 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: