Example #1
0
        public void GAdder(TriggerArgs m73)
        {
            IObject obj = (IObject)m73.Sender;

            if (obj.GetBodyType() == BodyType.Dynamic && !(obj is IPlayer))
            {
                IObject                  obje = Game.CreateObject("BgWall00", obj.GetWorldPosition() + new Vector2(0, 800));
                IObjectPullJoint         pull = (IObjectPullJoint)Game.CreateObject("PullJoint", obj.GetWorldPosition() + new Vector2(0, 800));
                IObjectTargetObjectJoint targ = (IObjectTargetObjectJoint)Game.CreateObject("TargetObjectJoint", obj.GetWorldPosition());
                targ.SetTargetObject(obj);
                pull.SetTargetObjectJoint(targ);
                pull.SetTargetObject(obje);
                pull.SetForce(25.985459270084f * (float)obj.GetMass());
                GObjects.Add(new GObject(obj, pull, obje));
            }
        }
Example #2
0
    /// <summary>
    /// 初回起動時
    /// </summary>
    void Start()
    {
        // Brainの初期化
        if (LearningData != null)
        {
            // ランダムに初期化
            var originalBrain = NNBrain.Load(learningData);
            for (int i = 0; i < TotalPopulation; i++)
            {
                Brains.Add(new NNBrain(originalBrain));
            }
        }
        else
        {
            // ロードデータをそのままコピー
            for (int i = 0; i < TotalPopulation; i++)
            {
                Brains.Add(new NNBrain(InputSize, HiddenSize, HiddenLayers, OutputSize));
            }
        }

        // Agentの初期化
        for (int i = 0; i < NAgents; i++)
        {
            var obj = Instantiate(GObject, Vector3.forward * i * 15f, Quaternion.identity);
            obj.SetActive(true);
            var agent = obj.GetComponent <AirHockeyAgent>();
            if (i >= 5)
            {
                agent.NoRendering();
            }
            GObjects.Add(obj);
            Agents.Add(agent);
        }
        BestRecord = -9999;
        SetStartAgents();
    }