Пример #1
0
 public void Init()
 {
     _matcher        = new MorphologyMatcher();
     _boardExtractor = new BoardExtractor(_matcher);
     _quantizer      = new MorphologyQuantizer(TestHelper.GetFakeConfig().Object);
     _initialBoard   = TestHelper.BuildBoard(new[]
     {
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
         0, 0, 1, 1, 1, 1, 1, 1, 0, 0,
         0, 0, 1, 1, 1, 1, 1, 1, 0, 0,
         0, 1, 1, 1, 0, 1, 1, 1, 1, 1,
         1, 1, 1, 1, 0, 1, 1, 1, 1, 1
     });
 }
Пример #2
0
        public void InitOnce()
        {
            _configMock = TestHelper.GetFakeConfig();
            _configMock.ConfigValue("Game.Tetris.Extractor.Samples", _numSamples);
            _configMock.ConfigValue("Game.Tetris.Timing.MoreTimeToAnalyze", 0);
            _configMock.ConfigValue("Game.Tetris.Timing.LessWaitTimeAfterDrop", 0);
            _configMock.ConfigValue("Game.Tetris.Timing.LessFallTimeBeforeDrop", 0);

            _quantizer       = new MorphologyQuantizer(_configMock.Object);
            _extractor       = new MorphologyExtractor(_configMock.Object);
            _boardExtractor  = new BoardExtractor(new MorphologyMatcher());
            _screenExtractor = new ScreenExtractor();
            _search          = new TwoPieceSearch(new YiyuanLeeHeuristic());

            _clockMock    = new Mock <IClock>();
            _executorMock = new Mock <IExecutor>();
        }
Пример #3
0
        public TetrisAgent(IConfig config, IClock clock, IQuantizer quantizer, IExecutor exceutor, IExtractor extractor, IBoardExtractor boardExtractor, IScreenExtractor screenExtractor, ISearch search)
        {
            Config          = config;
            Clock           = clock;
            Quantizer       = quantizer;
            Executor        = exceutor;
            Extractor       = extractor;
            BoardExtractor  = boardExtractor;
            ScreenExtractor = screenExtractor;
            Search          = search;

            _visualize = IsVisualize;

            // init timing config
            _hitTime               = TimeSpan.FromMilliseconds(Config.Read <int>("Robot.Actuator.Hit.Time"));
            _hitDelayAfter         = TimeSpan.FromMilliseconds(Config.Read <int>("Robot.Actuator.Hit.DelayAfter"));
            MoreTimeToAnalyze      = TimeSpan.FromMilliseconds(Config.Read <int>("Game.Tetris.Timing.MoreTimeToAnalyze"));
            LessFallTimeBeforeDrop = TimeSpan.FromMilliseconds(Config.Read <int>("Game.Tetris.Timing.LessFallTimeBeforeDrop"));
            LessWaitTimeAfterDrop  = TimeSpan.FromMilliseconds(Config.Read <int>("Game.Tetris.Timing.LessWaitTimeAfterDrop"));

            Init();
        }