コード例 #1
0
 void OnApplicationQuit()
 {
     if (playDataLogger != null)
     {
         playDataLogger.Dispose();
     }
     if (s2ai != null)
     {
         s2ai.Dispose();
         s2ai = null;
     }
 }
コード例 #2
0
        public void TestStayOnStage()
        {
            var ai          = new S2AI(2, 1);
            var inp         = new AIInputManager();
            var keepWalking = new KeepWalking(0, inp);

            Strategy[] strategies =
            {
                new StayOnStage(0, inp),
                keepWalking
            };
            var player = new DummyPlayerSnapshotProvider();
            var env    = new AIEnvironment(
                new [] { 0 },
                new DummyGameSnapshotProvider(),
                new DummyStageSnapshotProvider(20),
                new [] { player }
                );

            ai.Ready(env, strategies);
            ai.BeginEvaluate();
            float min = 0, max = 0;

            for (int i = 0; i < 30; i++)
            {
                ai.ExecAndMoveNext();
                if (inp.IsControlActive(Control.Left))
                {
                    player.Move(-1);
                    keepWalking.direction = Control.Left;
                }
                else if (inp.IsControlActive(Control.Right))
                {
                    player.Move(1);
                    keepWalking.direction = Control.Right;
                }
                if (player.x < min)
                {
                    min = player.x;
                }
                if (player.x > max)
                {
                    max = player.x;
                }
                Thread.Sleep(25);
            }
            ai.Dispose();
            Debug.Assert(min <-7f && max> 7f);
        }
コード例 #3
0
 void InitS2()
 {
     s2ai = new S2AI(threads: 4, blockSize: 8);
 }