Esempio n. 1
0
    /// <summary>
    /// Read action inputs from vectorAction
    /// Action space has size 2
    /// vectorAction[0] = rotate
    /// vectorAction[1] = move
    /// </summary>
    /// <param name="vectorAction">The chosen actions</param>
    public override void OnActionReceived(float[] vectorAction)
    {
        int currentAction = Mathf.RoundToInt(vectorAction[0]);

        if (!MaskedActions.Contains(currentAction))
        {
            // horizontal (x) position & rotation
            // 40 possible values
            int rotate   = Mathf.RoundToInt(currentAction % TetrisSettings.NumRotations);
            int position = Mathf.FloorToInt(currentAction / TetrisSettings.NumRotations);

            tetrisGame.CreateBlock(position, TetrisSettings.Rotations[rotate]);
        }
        else
        {
            tetrisGame.GameOver();
        }
    }