Fixed the generation algorithm

Some points were ignored, and probabilities were wrong.

Signed-off-by: RosimInc <rosim_inc@hotmail.com>
This commit is contained in:
RosimInc 2015-08-13 15:35:12 -04:00
parent bbf3de222f
commit 91fc0710de
2 changed files with 11 additions and 8 deletions

View File

@ -197,7 +197,7 @@ MeshRenderer:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 736567784}
m_Enabled: 1
m_Enabled: 0
m_CastShadows: 1
m_ReceiveShadows: 1
m_Materials:
@ -259,9 +259,9 @@ MonoBehaviour:
m_EditorClassIdentifier:
LinkObj: {fileID: 11495142, guid: fab430cecad80ad4391987a06b550cb7, type: 2}
PersonObj: {fileID: 11406500, guid: 646dd6566f9e1374caa3af8ad37c43d3, type: 2}
NumPeople: 100
NumPeople: 200
AvgNumFriends: 10
FriendshipLikeliness: .300000012
FriendshipLikeliness: 1
SphereRadius: 7
rotationSpeed: .699999988
torqueForce: .100000001
@ -311,7 +311,7 @@ Light:
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Type: 0
m_Resolution: -1
m_Strength: 1
m_Bias: .0500000007

View File

@ -73,7 +73,7 @@ namespace DeathBook.Model
missing = avgConnections - p1.numFriends; // TODO Add randomness
if (missing <= 0)
break;
continue;
list.Clear();
@ -93,13 +93,16 @@ namespace DeathBook.Model
float prob = Mathf.Lerp(probability, 1, missing / list.Count);
foreach (DistanceNode node in list)
{
if (node.dist < smallest.dist && Random.value < prob)
if (node.dist < smallest.dist)
smallest = node;
}
//TODO Code/use a heap instead
friendships.Add(CreateFriendship(p1, smallest.p));
missing--;
if (Random.value < prob)
{
friendships.Add(CreateFriendship(p1, smallest.p));
missing--;
}
list.Remove(smallest);
}
}