QPong / QPong-Unity

QPong rewritten in Unity
26 stars 6 forks source link

GetStatevector failed in Mac build #57

Closed HuangJunye closed 5 years ago

HuangJunye commented 5 years ago

The apparent lag in the Mac build is not due to slow communication, but due to failure of showing paddle by starting GetStatevetor() coroutine in (from Line 58 in CircuitGridClient.cs):

    private void GetStateVector(string gateString)
    {
        string urlString = API_URL + API_VERSION + Endpoint.get_statevector;
        StartCoroutine(PostRequest(urlString, circuitDimensionString, gateString, (results) => {

            // Deserialize stateVector from JSON
            // TODO: come up with a better way to abstract this out
            var obj = JsonConvert.DeserializeObject<RootObject>(results);
            Complex[] stateVector = new Complex[stateNumber];
            double[] stateProbability = new double[stateNumber];
            for (int i = 0; i < stateNumber; i++)
            {
                stateVector[i] = new Complex(obj.__ndarray__[i].__complex__[0], obj.__ndarray__[i].__complex__[1]);
                stateProbability[i] = Complex.Pow(stateVector[i], 2).Magnitude;
                paddleArray[i].GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, (float)stateProbability[i]);
            }
           // Debug.Log("State Probability: [" + string.Join(", ", stateProbability) + "]");
        }));
    }

I guess the problem is caused by the way I pass complex number from python server to the game. Do you have any idea how to fix this issue?

HuangJunye commented 5 years ago

@filemaster Can you have a look at this issue? Check the feature/changeResolution branch. I will send you a build I made.

filemaster commented 5 years ago

It is fixed in the PR #58