Exemplo n.º 1
0
        /// <summary>
        /// Gets the row analysis.
        /// Information it will return is whether row/col/diagnol has empty space, has 2 cells which have player value and a proposed cell ID
        /// </summary>
        /// <returns>The row analysis.</returns>
        /// <param name="lastUsedCellID">Last used cell I.</param>
        /// <param name="opponentValue">Opponent value.</param>
        public GridAnalysisForDefence GetRowAnalysis(int lastUsedCellID, C.CellState opponentValue)
        {
            GridAnalysisForDefence gridAnalysis = new GridAnalysisForDefence();

            gridAnalysis.isCellHasEmptySpace = IsRowHasEmptySpace(lastUsedCellID);

            CheckRow(lastUsedCellID, opponentValue, ref gridAnalysis);

            return(gridAnalysis);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks the left top to right bottom diagnol.
        /// </summary>
        /// <param name="cellID">Cell I.</param>
        /// <param name="playerValue">Player value.</param>
        /// <param name="gridAnalysis">Grid analysis.</param>
        private void CheckLeftTopToRightBottomDiagnol(int cellID, C.CellState playerValue, ref GridAnalysisForDefence gridAnalysis)
        {
            int iterationCOunter = 0;

            int counter = 0;
            int index;

            for (int i = 0; iterationCOunter < 3; i++, iterationCOunter++)
            {
                index = (i * 3) + i;
                if (this.cells[index].CellState == playerValue)
                {
                    counter++;
                }
                else if (this.cells[index].CellState == C.CellState.None)
                {
                    gridAnalysis.proposedCellID = index;
                }
            }

            if (counter > 1)
            {
                gridAnalysis.isOpponentWinning = true;
                return;
            }
            gridAnalysis.isOpponentWinning = false;
        }