コード例 #1
0
ファイル: TetrisPieceList.cs プロジェクト: ortue/UWPLedMatrix
        /// <summary>
        /// CheckBottom
        /// </summary>
        /// <param name="pieces"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        private bool CheckBottom(TetrisPieceList pieces, int y)
        {
            if (pieces.Max(p => p.Y) + y >= 18)
            {
                return(true);
            }

            foreach (TetrisPiece tetrisPiece in pieces)
            {
                if (this.Any(p => p.X == tetrisPiece.X && p.Y == tetrisPiece.Y + y + 1))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
ファイル: TetrisPieceList.cs プロジェクト: ortue/UWPLedMatrix
        /// <summary>
        /// EffacerLigne
        /// </summary>
        /// <param name="y"></param>
        public TetrisPieceList EffacerLigne(int y)
        {
            TetrisPieceList tetrisPieces = new TetrisPieceList();

            for (int x = 2; x < 12; x++)
            {
                if (this.FirstOrDefault(p => p.X == x && p.Y == y) is TetrisPiece pieceRemove)
                {
                    tetrisPieces.Add(new TetrisPiece(pieceRemove));
                    Remove(pieceRemove);
                }

                foreach (TetrisPiece piece in this.Where(p => p.X == x && p.Y < y))
                {
                    piece.Y++;
                }
            }

            return(tetrisPieces);
        }
コード例 #3
0
ファイル: TetrisPieceList.cs プロジェクト: ortue/UWPLedMatrix
        /// <summary>
        /// GetAiScore
        /// </summary>
        /// <param name="pieces"></param>
        /// <returns></returns>
        public double GetAiScore(TetrisPieceList pieces)
        {
            int y = -3;

            while (!CheckBottom(pieces, y) && y < 19)
            {
                y++;
            }

            foreach (TetrisPiece tetrisPiece in pieces)
            {
                Add(new TetrisPiece(tetrisPiece, y, true));
            }

            double score = -WeightHeight * AggregateHeight + WeightLines * Lines - WeightHoles * Holes - WeightBumpiness * Bumpiness;

            RemoveTest();

            return(score);
        }