Started implementing working game strategies.

Signed-off-by: RosimInc <rosim_inc@hotmail.com>
This commit is contained in:
RosimInc 2015-08-16 19:23:42 -04:00
parent 2095a71739
commit fd2aea25c1
4 changed files with 118 additions and 31 deletions

View File

@ -1340,79 +1340,79 @@ Prefab:
objectReference: {fileID: 1197925315} objectReference: {fileID: 1197925315}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.awarenessChange.friendRatio.x propertyPath: strategy.awarenessChange.friendRatio.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.awarenessChange.friendRatio.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.awarenessChange.friendRatio.z
value: .200000003 value: .200000003
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.awarenessChange.friendRatio.y
value: .800000012
objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.awarenessChange.friendRatio.z
value: 1.5
objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.awarenessChange.lastDeath.x propertyPath: strategy.awarenessChange.lastDeath.x
value: 1 value: .600000024
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.deathNoticing.popularity.x propertyPath: strategy.deathNoticing.popularity.x
value: .100000001 value: .75
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.deathNoticing.importance.x propertyPath: strategy.deathNoticing.importance.x
value: .100000001 value: .75
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.deathNoticing.numFriends.x propertyPath: strategy.deathNoticing.numFriends.x
value: .100000001 value: .75
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.deathNoticing.awareness.x propertyPath: strategy.deathNoticing.awareness.x
value: .100000001 value: .75
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.chanceToPost.popularity.x propertyPath: strategy.chanceToPost.popularity.x
value: .100000001 value: .699999988
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.chanceToPost.importance.x propertyPath: strategy.chanceToPost.importance.x
value: .100000001 value: .699999988
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.chanceToPost.frequency.x propertyPath: strategy.chanceToPost.frequency.x
value: .100000001 value: .699999988
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.awarenessChange.lastDeath.y propertyPath: strategy.awarenessChange.lastDeath.y
value: 0 value: .400000006
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.deathNoticing.popularity.y propertyPath: strategy.deathNoticing.popularity.y
value: .899999976 value: .25
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.deathNoticing.importance.y propertyPath: strategy.deathNoticing.importance.y
value: .899999976 value: .25
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.deathNoticing.numFriends.y propertyPath: strategy.deathNoticing.numFriends.y
value: .899999976 value: .25
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.deathNoticing.awareness.y propertyPath: strategy.deathNoticing.awareness.y
value: .899999976 value: .25
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.chanceToPost.popularity.y propertyPath: strategy.chanceToPost.popularity.y
value: .899999976 value: .300000012
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.chanceToPost.importance.y propertyPath: strategy.chanceToPost.importance.y
value: .899999976 value: .300000012
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.chanceToPost.frequency.y propertyPath: strategy.chanceToPost.frequency.y
value: .899999976 value: .300000012
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.awarenessChange.lastDeath.z propertyPath: strategy.awarenessChange.lastDeath.z
@ -1458,6 +1458,14 @@ Prefab:
propertyPath: levelOptions.FriendshipLikeliness propertyPath: levelOptions.FriendshipLikeliness
value: .600000024 value: .600000024
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.awarenessChange.modifier
value: .300000012
objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: strategy.awarenessChange.maxDeathDuration
value: 20160
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} m_ParentPrefab: {fileID: 100100000, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
m_IsPrefabParent: 0 m_IsPrefabParent: 0

View File

@ -14,6 +14,7 @@ namespace DeathBook.Model
public Vector3 friendRatio = new Vector3(); public Vector3 friendRatio = new Vector3();
public Vector3 lastDeath = new Vector3(); public Vector3 lastDeath = new Vector3();
public float maxDeathDuration = 24 * 60 * 7; public float maxDeathDuration = 24 * 60 * 7;
public float modifier = 0.1f;
} }
[System.Serializable] [System.Serializable]
@ -23,6 +24,7 @@ namespace DeathBook.Model
public Vector3 importance = new Vector3(); public Vector3 importance = new Vector3();
public Vector3 numFriends = new Vector3(); public Vector3 numFriends = new Vector3();
public Vector3 awareness = new Vector3(); public Vector3 awareness = new Vector3();
public float modifier = 0.1f;
} }
[System.Serializable] [System.Serializable]
@ -31,6 +33,7 @@ namespace DeathBook.Model
public Vector3 popularity = new Vector3(); public Vector3 popularity = new Vector3();
public Vector3 importance = new Vector3(); public Vector3 importance = new Vector3();
public Vector3 frequency = new Vector3(); public Vector3 frequency = new Vector3();
public float modifier = 0.1f;
} }
@ -40,14 +43,14 @@ namespace DeathBook.Model
public float GetAwarenessChange(int numDeadFriends, int numAliveFriends, int sinceLastDeath) public float GetAwarenessChange(int numDeadFriends, int numAliveFriends, int sinceLastDeath)
{ {
float friendsRatioInd = numAliveFriends == 0 ? 1 : GetValue(Mathf.Min(numDeadFriends / numAliveFriends, 1), awarenessChange.friendRatio); float friendsRatioInd = numAliveFriends == 0 ? 1 : GetValue(Mathf.Min(numDeadFriends * 1f / numAliveFriends, 1f), awarenessChange.friendRatio);
float max = awarenessChange.maxDeathDuration; float max = awarenessChange.maxDeathDuration;
float lastDeathInd = GetValue(1 - Mathf.Min(sinceLastDeath, max) / max, awarenessChange.lastDeath); float lastDeathInd = GetValue(1 - Mathf.Min(sinceLastDeath, max) / max, awarenessChange.lastDeath);
//Debug.Log(lastDeathInd + " " + friendsRatioInd); Debug.Log(friendsRatioInd + " -- " + lastDeathInd);
return Mathf.Clamp(friendsRatioInd * lastDeathInd, 0, 1); return Mathf.Clamp(friendsRatioInd * lastDeathInd, 0, 1) * awarenessChange.modifier;
} }
public float GetDeathNoticing(float friendPopularity, float friendshipImportance, int numAliveFriends, float awareness) public float GetDeathNoticing(float friendPopularity, float friendshipImportance, int numAliveFriends, float awareness)
@ -56,12 +59,11 @@ namespace DeathBook.Model
float importanceInd = GetValue(friendshipImportance, deathNoticing.importance); float importanceInd = GetValue(friendshipImportance, deathNoticing.importance);
//TODO Should be inverse and there should be an expected number of friends float aliveFriendsInd = GetValue(Mathf.Min(numAliveFriends * 0.1f, 1), deathNoticing.numFriends);
float aliveFriendsInd = GetValue(numAliveFriends, deathNoticing.numFriends);
float awarenessInd = GetValue(awareness, deathNoticing.awareness); float awarenessInd = GetValue(awareness, deathNoticing.awareness);
return Mathf.Clamp(popularityInd * importanceInd * aliveFriendsInd * awarenessInd, 0, 1); return Mathf.Clamp(popularityInd * importanceInd * aliveFriendsInd * awarenessInd, 0, 1) * deathNoticing.modifier;
} }
public float GetChanceToPost(float friendPopularity, float friendshipImportance) public float GetChanceToPost(float friendPopularity, float friendshipImportance)
@ -70,7 +72,7 @@ namespace DeathBook.Model
float importanceInd = GetValue(1 - friendshipImportance, deathNoticing.importance); float importanceInd = GetValue(1 - friendshipImportance, deathNoticing.importance);
return Mathf.Clamp(popularityInd * importanceInd, 0, 1); return Mathf.Clamp(popularityInd * importanceInd, 0, 1) * chanceToPost.modifier;
} }
public float GetChanceToRead() public float GetChanceToRead()

65
Assets/Tests/RulesTest.cs Normal file
View File

@ -0,0 +1,65 @@
using UnityEngine;
using System.Collections;
using DeathBook.Model;
public class RulesTest : MonoBehaviour {
public GameStrategy strategy = new GameStrategy();
public ChangeAwarenessTest awareness = new ChangeAwarenessTest();
public NoticeDeathTest noticeDeath = new NoticeDeathTest();
public static GameStrategy str = null;
[System.Serializable]
public class ChangeAwarenessTest
{
public int numDeadFriends;
public int numAliveFriends;
public int sinceLastDeath;
public bool test = false;
public float result = 0f;
public void Update()
{
if (!test)
return;
test = false;
result = RulesTest.str.GetAwarenessChange(numDeadFriends, numAliveFriends, sinceLastDeath);
}
}
[System.Serializable]
public class NoticeDeathTest
{
public float popularity;
public float importance;
public int numAliveFriends;
public float awareness;
public bool test = false;
public float result = 0f;
public void Update()
{
if (!test)
return;
test = false;
result = RulesTest.str.GetDeathNoticing(popularity, importance, numAliveFriends, awareness);
}
}
// Use this for initialization
void Start () {
str = strategy;
}
// Update is called once per frame
void Update () {
awareness.Update();
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: debe9fb44675c3e49ba7e4c511a91076
timeCreated: 1439754262
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: