Ejemplo n.º 1
0
        void Start()
        {
            StartPosistion = transform.position;
            _game          = FindObjectOfType <PongGame>();
            _ball          = FindObjectOfType <PongBall>();
            if (Side == Player.Player1)
            {
                _grid = new QGrid(16, transform,
                                  new GridSettings {
                    Offset = new Vector3(9.8f, 0, 0), ResolutionX = 1.28f, ResolutionY = 1.28f
                });
                _vect = Vector <float> .Build.Dense(new[] { 1f });

                QAIManager.InitAgent(this, new QOption {
                    LearningRate = 0.005f,
                    NetworkArgs  = new [] { new CNNArgs {
                                                FilterSize = 4, FilterCount = 1, PoolLayerSize = 2, Stride = 2
                                            } },
                    MaxPoolSize      = 2000,
                    BatchSize        = 2000,
                    EpsilonStart     = 0.5f,
                    EpsilonEnd       = 0.1f,
                    Discount         = 0.95f,
                    TrainingInterval = 20,
                    TrainingCycle    = 10,
                });

                if (QAIManager.CurrentMode == QAIMode.Learning || QAIManager.CurrentMode == QAIMode.Testing)
                {
                    Time.timeScale = 5f;
                }
            }
            StartCoroutine(Movement());
        }
Ejemplo n.º 2
0
        private void Start()
        {
            _grid = new QGrid(13, transform, new GridSettings {
                NormalAxis = Axis.Y
            });
            _linearState = Vector <float> .Build.Dense(2);

            _history = new LinkedList <QState>();
            QAIManager.InitAgent(this, new QOption {
                NetworkArgs = new [] { new CNNArgs {
                                           FilterCount = 1, FilterSize = 1, PoolLayerSize = 1, Stride = 1
                                       } }
            });
        }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        GetComponentInChildren <SpriteRenderer>().shadowCastingMode = ShadowCastingMode.On;
        _onTrack           = true;
        _distanceTravelled = StartPosition;
        Track.GetPointAtDistance(_distanceTravelled);
        _grid = new QGrid(16, transform, new GridSettings {
            Offset = Vector3.up * 5.2f
        });
        _vector = Vector <float> .Build.Dense(10, 0);

        _velocityBin = new Bin(0.01f, 0.25f, 0.5f, 75f);
        _forceBin    = new Bin(0.01f, 0.25f, 0.5f, 75f);

        var options = new QOption {
            Discretize       = false,
            MaxPoolSize      = 2000,
            BatchSize        = 2000,
            EpsilonStart     = 0.7f,
            Discount         = 0.8f,
            TrainingInterval = 50,
            NetworkArgs      = new [] { new CNNArgs {
                                            FilterSize = 4, FilterCount = 1, PoolLayerSize = 2, Stride = 2
                                        } }
        };

        options.Discretize = false;

//		if(AiControlled || QAIManager.CurrentMode == QAIMode.Imitating) {
        QAIManager.InitAgent(this, options);
        if (QAIManager.CurrentMode == QAIMode.Learning)
        {
            Time.timeScale = 2.0f;
        }
//		}
        StartCoroutine(Spas());
    }