Beispiel #1
0
    public override void CollectObservations()
    {
        //bird y
        AddVectorObs(gameObject.transform.position.y / height);

        //bird velocity y
        AddVectorObs(Mathf.Clamp(rb2d.velocity.y, -height, height) / height);

        Vector3 Pipe_top_Pos;

        Pipe_top_Pos = pipes.GetNextPipe().localPosition;

        Debug.Log(Pipe_top_Pos.y);

        /*
         * //bird Pipe_top_bottom
         * AddVectorObs( (Pipe_top_Pos.y - 1.6f) / height );
         * //bird Pipe_bot_top
         * AddVectorObs( (Pipe_top_Pos.y - 2.8f) / height );
         */

        AddVectorObs((Pipe_top_Pos.y - 2.2f) / height);

        //bird and pipe distance
        //AddVectorObs( Pipe_top_Pos.x / height ) ;

        //flap
        AddVectorObs(flap ? 1f : -1f);
    }
Beispiel #2
0
    public override void CollectObservations()
    {
        AddVectorObs(gameObject.transform.localPosition.y / height);
        AddVectorObs(Mathf.Clamp(myBody.velocity.y, -height, height) / height);
        Vector3 pipePos = pipes.GetNextPipe().localPosition;

        AddVectorObs((pipePos.y - pipeSpace) / height);
        AddVectorObs((pipePos.y + pipeSpace) / height);
        AddVectorObs(screenPressed ? 1f : -1f);
    }
Beispiel #3
0
    public List <double> CollectObservations()
    {
        Vector3 pipePos = pipes.GetNextPipe().localPosition;

        Debug.DrawLine(new Vector3(pipePos.x, pipePos.y + pipeSpace, pipePos.z), new Vector3(pipePos.x + 1, pipePos.y + pipeSpace, pipePos.z), Color.red, 0.1f, false);
        Debug.DrawLine(myBody.transform.position, new Vector3(pipePos.x - 0.26f, pipePos.y, pipePos.z), Color.black, 0.1f, false);

        List <double> myStates = new List <double>();
        // myStates.Add(gameObject.transform.localPosition.y );
        float playerY = gameObject.transform.localPosition.y;

        myStates.Add(myBody.velocity.y);
        // Debug.Log(string.Format("x = {0} top y {1} and bottom y {2}, ", pipePos.x, (pipePos.y - pipeSpace), (pipePos.y + pipeSpace)));
        // string str = string.Format("velocity.y = {0}, MathfClamp is {1} and final result is {2}",myBody.velocity.y, Mathf.Clamp(myBody.velocity.y, -height, height), Mathf.Clamp(myBody.velocity.y, -height, height) / height);
        // Debug.Log(str);
        myStates.Add((pipePos.y - pipeSpace) - playerY);
        myStates.Add((pipePos.y + pipeSpace) - playerY);
        myStates.Add((pipePos.x - 0.26f));
        // myStates.Add(screenPressed ? 1f : -1);
        // myStates.Add(topBorder.transform.position.y - transform.position.y - 0.5f);
        // myStates.Add(transform.position.y + bottomBorder.transform.position.y + 0.5f);
        return(myStates);
    }