コード例 #1
0
        private void GetInput()
        {
            _actions[0] = keys.keyNothing;
            if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                _actions[0] = keys.keyLeft;
            }
            if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                _actions[0] = keys.keyRight;
            }

            _actions[1] = keys.keyNothing;
            if (Input.GetKeyDown(KeyCode.Z))
            {
                _actions[1] = keys.keyLeft;
            }
            if (Input.GetKeyDown(KeyCode.X))
            {
                _actions[1] = keys.keyRight;
            }

            _actions[2] = keys.keyNothing;
            if (Input.GetKeyDown(KeyCode.Space))
            {
                _actions[2] = keys.keyHardDrop;
            }

            HorizontalInputReceived.Invoke((int)_actions[0]);
            RotationInputReceived.Invoke((int)_actions[1]);
            ActionInputReceived.Invoke((int)_actions[2]);
        }
コード例 #2
0
ファイル: TetrisAgent.cs プロジェクト: janegamedev/Tetris-RL
        public override void OnActionReceived(float[] vectorAction)
        {
            HorizontalInputReceived.Invoke((int)vectorAction[0]);
            RotationInputReceived.Invoke((int)vectorAction[1]);
            ActionInputReceived.Invoke((int)vectorAction[2]);

            for (int i = 0; i < vectorAction.Length; i++)
            {
                if (vectorAction[i] != keys.keyNothing)
                {
                    AddReward(-0.0001f);
                }
            }
        }