Пример #1
0
        public void SimpleSearch(Tetrimino current, Tetrimino next)
        {
            var gameState = new GameState(current, next);

            var result = _twoPieceSearch.Search(gameState);

            _logger.Info(result.GoalGameState);
        }
Пример #2
0
        public void SimpleSearchFull(Tetrimino current, Tetrimino next)
        {
            var simpleSearchLocal = new TwoPieceSearch(new YiyuanLeeHeuristic());

            var gameState = new GameState(current, next);

            _logger.Info(gameState);

            var result = simpleSearchLocal.Search(gameState);

            _logger.Info(result.GoalGameState);

            Assert.AreEqual(3, result.Moves.Count());
            Assert.AreEqual(Move.RotateCounterclockwise, result.Moves.ToList()[0]);
            Assert.AreEqual(Move.RotateCounterclockwise, result.Moves.ToList()[1]);
            Assert.AreEqual(Move.Drop, result.Moves.ToList()[2]);
        }
Пример #3
0
        static TimeSpan MeasureSimpleSearch(int number)
        {
            var gamestates = Enumerable.Range(0, number)
                             .Select(x => new Board().Random())
                             .Select(x => new GameState(x, Tetriminos.GetRandom(), Tetriminos.GetRandom()))
                             .ToList();

            var heuristic = new YiyuanLeeHeuristic();
            var search    = new TwoPieceSearch(heuristic);

            var sw = new Stopwatch();

            sw.Start();

            foreach (var gamestate in gamestates)
            {
                var result = search.Search(gamestate);
            }

            sw.Stop();
            return(sw.Elapsed);
        }