Commit 11d28737 authored by Mikko Lainio's avatar Mikko Lainio 🇺🇦
Browse files

updated for static displacement

parent e9edc9a8
......@@ -578,7 +578,7 @@ PrefabInstance:
- target: {fileID: 7586982899639718716, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.37
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7586982899639718716, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
......@@ -638,7 +638,7 @@ PrefabInstance:
- target: {fileID: 7586982899723068933, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: 0.870594
value: 0.500594
objectReference: {fileID: 0}
- target: {fileID: 7586982899723068933, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
......@@ -678,12 +678,12 @@ PrefabInstance:
- target: {fileID: 7586982898715876936, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.66399974
value: -0.63528013
objectReference: {fileID: 0}
- target: {fileID: 7586982898715876936, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: 0.8047865
value: 0.86692363
objectReference: {fileID: 0}
- target: {fileID: 7586982898838293552, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
......@@ -703,7 +703,12 @@ PrefabInstance:
- target: {fileID: 7586982899058965772, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.0000007487184
value: -0.00000084230817
objectReference: {fileID: 0}
- target: {fileID: 7586982899058965772, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: -1.1156338
objectReference: {fileID: 0}
- target: {fileID: 7586982899776466657, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
......@@ -718,7 +723,42 @@ PrefabInstance:
- target: {fileID: 7586982898522875283, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.0000010349562
value: 0.0000018111733
objectReference: {fileID: 0}
- target: {fileID: 7586982898522875283, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: -1.1921695
objectReference: {fileID: 0}
- target: {fileID: 6812257162856672943, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.54123896
objectReference: {fileID: 0}
- target: {fileID: 6812257162856672943, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: 0.86876816
objectReference: {fileID: 0}
- target: {fileID: 6356500260159871328, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.00000042115408
objectReference: {fileID: 0}
- target: {fileID: 6356500260159871328, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: -1.1156337
objectReference: {fileID: 0}
- target: {fileID: 3414693047837031351, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.0000010349562
objectReference: {fileID: 0}
- target: {fileID: 3414693047837031351, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: -1.1921701
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3653bf778ef537c4cabd156f2f246dfd, type: 3}
......@@ -1820,7 +1860,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e7e6eeaf347f5d84592c063c68f5a535, type: 3}
m_Name:
m_EditorClassIdentifier:
UpdateFrequency: 0.02
m_updateFrequency: 60
m_timeStepText: {fileID: 476367180}
m_scoreText: {fileID: 798756960}
m_growthText: {fileID: 267811705}
......@@ -1863,6 +1903,8 @@ MonoBehaviour:
m_plotRenderer: {fileID: 797969627}
m_plotAccuracy: 1
m_plotVisualizeMode: 0
m_noise: -0.25
m_randomizeNoise: 0
TimeSteps: 1000
--- !u!1 &797969625
GameObject:
......@@ -2328,7 +2370,7 @@ PrefabInstance:
- target: {fileID: 7586982899639718716, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.3699999
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7586982899639718716, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
......@@ -2388,7 +2430,7 @@ PrefabInstance:
- target: {fileID: 7586982899723068933, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: 0.8705939
value: 0.500594
objectReference: {fileID: 0}
- target: {fileID: 7586982899723068933, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
......@@ -2428,12 +2470,12 @@ PrefabInstance:
- target: {fileID: 7586982898715876936, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.66399974
value: -0.63528013
objectReference: {fileID: 0}
- target: {fileID: 7586982898715876936, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: 0.8047865
value: 0.86692363
objectReference: {fileID: 0}
- target: {fileID: 7586982898838293552, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
......@@ -2453,7 +2495,12 @@ PrefabInstance:
- target: {fileID: 7586982899058965772, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.0000007487184
value: 0.0000005615388
objectReference: {fileID: 0}
- target: {fileID: 7586982899058965772, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: -1.1156334
objectReference: {fileID: 0}
- target: {fileID: 7586982899776466657, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
......@@ -2468,7 +2515,42 @@ PrefabInstance:
- target: {fileID: 7586982898522875283, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.0000010349562
value: -0.00000012936952
objectReference: {fileID: 0}
- target: {fileID: 7586982898522875283, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: -1.1921701
objectReference: {fileID: 0}
- target: {fileID: 6812257162856672943, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.5412385
objectReference: {fileID: 0}
- target: {fileID: 6812257162856672943, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: 0.86876816
objectReference: {fileID: 0}
- target: {fileID: 6356500260159871328, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.00000042115408
objectReference: {fileID: 0}
- target: {fileID: 6356500260159871328, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: -1.1156337
objectReference: {fileID: 0}
- target: {fileID: 3414693047837031351, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.00000090558666
objectReference: {fileID: 0}
- target: {fileID: 3414693047837031351, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: -1.1921703
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3653bf778ef537c4cabd156f2f246dfd, type: 3}
......@@ -3194,7 +3276,7 @@ PrefabInstance:
- target: {fileID: 7586982899639718716, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.3699999
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7586982899639718716, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
......@@ -3254,13 +3336,18 @@ PrefabInstance:
- target: {fileID: 7586982899723068933, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: 0.8705939
value: 0.500594
objectReference: {fileID: 0}
- target: {fileID: 7586982899723068933, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7586982899723068933, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_AutoConfigureConnectedAnchor
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7586982898145474856, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
......@@ -3294,12 +3381,12 @@ PrefabInstance:
- target: {fileID: 7586982898715876936, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.6639999
value: -0.63527995
objectReference: {fileID: 0}
- target: {fileID: 7586982898715876936, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: 0.8047865
value: 0.86692363
objectReference: {fileID: 0}
- target: {fileID: 7586982898838293552, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
......@@ -3334,7 +3421,12 @@ PrefabInstance:
- target: {fileID: 7586982899058965772, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.0000001871796
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7586982899058965772, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: -1.1156336
objectReference: {fileID: 0}
- target: {fileID: 7586982899776466657, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
......@@ -3349,7 +3441,42 @@ PrefabInstance:
- target: {fileID: 7586982898522875283, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.00000025873905
value: 0.0000003881086
objectReference: {fileID: 0}
- target: {fileID: 7586982898522875283, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: -1.1921701
objectReference: {fileID: 0}
- target: {fileID: 6812257162856672943, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0.5412389
objectReference: {fileID: 0}
- target: {fileID: 6812257162856672943, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: 0.86876816
objectReference: {fileID: 0}
- target: {fileID: 6356500260159871328, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: -0.0000000935898
objectReference: {fileID: 0}
- target: {fileID: 6356500260159871328, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: -1.1156336
objectReference: {fileID: 0}
- target: {fileID: 3414693047837031351, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3414693047837031351, guid: 3653bf778ef537c4cabd156f2f246dfd,
type: 3}
propertyPath: m_ConnectedAnchor.y
value: -1.1921703
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3653bf778ef537c4cabd156f2f246dfd, type: 3}
......@@ -47,7 +47,9 @@ public class QuantumDemoManager : MonoBehaviour
[SerializeField] private LineRenderer m_plotRenderer;
[SerializeField] private PlotAccuracy m_plotAccuracy = PlotAccuracy.Max;
[SerializeField] private VisualizeMode m_plotVisualizeMode;
[SerializeField] private float m_noise = 0f;
[Range(-0.25f, 0.25f)]
[SerializeField] private double m_noise = 0;
[SerializeField] private bool m_randomizeNoise = false;
public enum VisualizeMode
{
......@@ -88,7 +90,7 @@ public class QuantumDemoManager : MonoBehaviour
// Start is called before the first frame update
void Start()
{
InitEnv();
// InitEnv();
FinalScoreObject.SetActive(false);
StartTextObject.SetActive(true);
m_left.enabled = false;
......@@ -141,18 +143,40 @@ public class QuantumDemoManager : MonoBehaviour
m_state = State.Started;
FinalScoreObject.SetActive(false);
StartTextObject.SetActive(false);
Double noise = m_noise;
if (m_randomizeNoise)
{
noise = UnityEngine.Random.value * m_noise;
}
InitEnv(noise);
StartCoroutine(GameCoroutine());
SetRagdollsKinematic(true);
m_left.enabled = true;
m_mid.enabled = true;
m_right.enabled = true;
m_visualizeHintText.gameObject.SetActive(true);
}
private void SetRagdollsKinematic(bool kinematic)
{
m_left.GetComponent<Rigidbody>().isKinematic = kinematic;
m_mid.GetComponent<Rigidbody>().isKinematic = kinematic;
m_right.GetComponent<Rigidbody>().isKinematic = kinematic;
}
private void InitEnv()
private void InitEnv(double displacement)
{
// To be safe, add a using (Py.Gil()) block every time you interact with any python wrapper class like StirapEnv
using (Python.Runtime.Py.GIL())
{
m_env = m_noise > 0 ? new StirapEnv(TimeSteps+1, m_noise) : new StirapEnv(TimeSteps+1);
m_env = new StirapEnv(TimeSteps, displacement);
Debug.Log("Noise: "+m_env.Noise);
}
}
......@@ -197,10 +221,13 @@ public class QuantumDemoManager : MonoBehaviour
m_endScoreText.text = "Final Score: <color=#fff>" + m_score.ToString("F0");
StartTextObject.SetActive(true);
m_env.Reset();
SetRagdollsKinematic(false);
m_left.enabled = false;
m_mid.enabled = false;
m_right.enabled = false;
m_growthRight.Clear();
m_visualizeHintText.gameObject.SetActive(false);
}
/// <summary>
......
......@@ -65,8 +65,8 @@ public class StirapEnv
/// Constructor with noise parameter
/// </summary>
/// <param name="timeSteps"></param>
/// <param name="noise">max randomness for the function</param>
public StirapEnv(int timeSteps, float noise)
/// <param name="noise">displacement (noise) for the function. between -0.25 and 0.25</param>
public StirapEnv(int timeSteps, double noise)
{
m_stirap = PythonManager.Instance.StirapEnv.StirapEnv(false, new PyInt(timeSteps), new PyFloat(noise));
}
......@@ -95,12 +95,17 @@ public class StirapEnv
}
/// <summary>
/// Max TimeSteps used by the simulation. Create new instance to change time steps after initialization.
/// </summary>
public int TimeSteps
{
get { return new PyInt(m_stirap.timesteps).ToInt32(); }
private set { m_stirap.timesteps = new PyInt(value); }
get { return (int) m_stirap.timesteps; }
}
/// <summary>
/// </summary>
public double Noise
{
get { return (double) m_stirap.initial_displacement; }
}
}
......
fileFormatVersion: 2
guid: 4d8b7d74dcebce74391e4864c818ae77
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment