/// <summary> /// Gets the right top to left bottom diagnol analysis for attack. /// </summary> /// <returns>The right top to left bottom diagnol analysis for attack.</returns> /// <param name="lastUsedCellID">Last used cell I.</param> /// <param name="playerValue">Player value.</param> public GridAnalysisForAttack GetRightTopToLeftBottomDiagnolAnalysisForAttack(int lastUsedCellID, C.CellState playerValue) { GridAnalysisForAttack gridAnalysis = new GridAnalysisForAttack(); gridAnalysis.proposedCellID = -1; CheckRightTopToLeftBottomDiagnolForAttack(lastUsedCellID, playerValue, ref gridAnalysis); return(gridAnalysis); }
/// <summary> /// Gets the column analysis for attack. /// </summary> /// <returns>The column analysis for attack.</returns> /// <param name="lastUsedCellID">Last used cell I.</param> /// <param name="playerValue">Player value.</param> public GridAnalysisForAttack GetColumnAnalysisForAttack(int lastUsedCellID, C.CellState playerValue) { GridAnalysisForAttack gridAnalysis = new GridAnalysisForAttack(); gridAnalysis.proposedCellID = -1; CheckColumnForAttack(lastUsedCellID, playerValue, ref gridAnalysis); return(gridAnalysis); }
/// <summary> /// Checks the column for attack. /// </summary> /// <param name="cellID">Cell I.</param> /// <param name="playerValue">Player value.</param> /// <param name="gridAnalysisForAttack">Grid analysis for attack.</param> private void CheckColumnForAttack(int cellID, C.CellState playerValue, ref GridAnalysisForAttack gridAnalysisForAttack) { int colNumber = cellID % 3; int iterationCOunter = 0; int counter = 0; for (int i = colNumber; iterationCOunter < 3; i += 3, iterationCOunter++) { if (this.cells[i].CellState == C.CellState.None) { counter++; gridAnalysisForAttack.proposedCellID = i; } else if (this.cells[i].CellState == playerValue) { gridAnalysisForAttack.playerValueCounter += 1; } } gridAnalysisForAttack.isCellHasTwoEmptySpace = counter > 1; }
/// <summary> /// Checks the row for attack. /// </summary> /// <param name="cellID">Cell I.</param> /// <param name="playerValue">Player value.</param> /// <param name="gridAnalysisForAttack">Grid analysis for attack.</param> private void CheckRowForAttack(int cellID, C.CellState playerValue, ref GridAnalysisForAttack gridAnalysisForAttack) { int rowNumber = cellID / 3; int start = rowNumber * 3; int end = start + 3; int counter = 0; int playerValueCounter = 0; for (int i = start; i < end; i++) { if (this.cells[i].CellState == C.CellState.None) { counter++; gridAnalysisForAttack.proposedCellID = i; } else if (this.cells[i].CellState == playerValue) { gridAnalysisForAttack.playerValueCounter += 1; } } gridAnalysisForAttack.isCellHasTwoEmptySpace = counter > 1; }
/// <summary> /// Checks the left top to right bottom diagnol for attack. /// </summary> /// <param name="cellID">Cell I.</param> /// <param name="playerValue">Player value.</param> /// <param name="gridAnalysisForAttack">Grid analysis for attack.</param> private void CheckLeftTopToRightBottomDiagnolForAttack(int cellID, C.CellState playerValue, ref GridAnalysisForAttack gridAnalysisForAttack) { 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 == C.CellState.None) { counter++; gridAnalysisForAttack.proposedCellID = index; } else if (this.cells[index].CellState == playerValue) { gridAnalysisForAttack.playerValueCounter += 1; } } gridAnalysisForAttack.isCellHasTwoEmptySpace = counter > 1; }