Esempio n. 1
0
        private Piece ExtractCurrentPieceKnown(IScreenshot screenshot, Tetrimino tetrimino, int maxFallDistance)
        {
            var foundPiece = _tetrisExtractor.ExtractSpawnedPiece(screenshot, maxFallDistance);

            if (foundPiece != null && foundPiece.Tetrimino == tetrimino && foundPiece.IsUntouched)
            {
                return(foundPiece);
            }
            return(null);
        }
        public void RecognizeUnknownSpawnedPiece(string imageKey, IScreenshot screenshot, Piece currentPieceExpected)
        {
            _unknownSpawnedPiece++;

            var searchHeight = currentPieceExpected.FallHeight;
            var piece        = _extractor.ExtractSpawnedPiece(screenshot, searchHeight);

            Assert.NotNull(piece);
            Assert.AreEqual(currentPieceExpected, piece);

            _unknownSpawnedPieceRecognized++;
        }
Esempio n. 3
0
        public void ExtractPieceSpawnedFalled()
        {
            var extractor  = new TetrisExtractor(_config);
            var screenshot = new EmguScreenshot("Screenshots/tetris_play_2.png", DateTime.Now.Subtract(DateTime.MinValue));

            var piece = extractor.ExtractSpawnedPiece(screenshot, 5);

            Assert.Null(piece);

            piece = extractor.ExtractSpawnedPiece(screenshot, 6);

            Assert.NotNull(piece);
            Assert.AreEqual(Tetrimino.Z, piece.Tetrimino);
            Assert.AreEqual(0, piece.Orientation);
            Assert.AreEqual(0, piece.X);
            Assert.AreEqual(-6, piece.Y);
        }