private void GetStoneInformations(ref ScoreInfomations infos) { var blocks = new byte[2]; var movePossibilits = new byte[2]; var twoCombis = new byte[2]; var threeCombis = new byte[2]; var checkedStones = new bool[m_board.Length]; for (int i = 0; i < m_board.Length; i++) { var color = m_board[i]; if (color == IController.NONE) { continue; } var isBlocked = true; var combi = 0; checkedStones[i] = true; for (int j = 0; j < MOVES[i].Length; j++) { var k = MOVES[i][j]; //Check if stone can move in this position if (m_board[k] == IController.NONE) { movePossibilits[color]++; isBlocked = false; } //Check if this position is the same color and we not already have checked it else if (!checkedStones[k] && m_board[k] == color) { if (!InMill(k, color)) { combi++; } checkedStones[k] = true; } } if (isBlocked) { blocks[color]++; } if (combi == 1) { twoCombis[color]++; } if (combi == 2) { threeCombis[color]++; } } infos.numOf2Combis = twoCombis; infos.numOf3Combis = threeCombis; infos.numOfMovePosibilities = movePossibilits; }
private void CheckMove() { var si = new ScoreInfomations(); GetStoneInformations(ref si); if (si.numOfMovePosibilities[0] == 0) { m_winner = 1; } else if (si.numOfMovePosibilities[1] == 0) { m_winner = 0; } }
private void GetMillInformations(ref ScoreInfomations infos) { byte[] horizontalStones = { 0, 3, 6, 9, 12, 15, 18, 21 }; byte[] verticalStones = { 0, 3, 6, 1, 16, 8, 5, 2 }; var mills = new byte[2]; var potentialOpenings = new byte[2]; var opponentPotentialMills = new byte[2]; foreach (var k in horizontalStones) { MillInfomation millInfo; if (CheckForMill(k, out millInfo, true)) { mills[millInfo.Color]++; potentialOpenings[millInfo.Color] += millInfo.FreePositions; } if (millInfo.PotMills) { opponentPotentialMills[State.OppositeColor(millInfo.Color)]++; } } foreach (var k in verticalStones) { MillInfomation millInfo; if (CheckForMill(k, out millInfo, false)) { mills[millInfo.Color]++; potentialOpenings[millInfo.Color] += millInfo.FreePositions; } if (millInfo.PotMills) { opponentPotentialMills[State.OppositeColor(millInfo.Color)]++; } } infos.numOfMills = mills; infos.numOfPosibileOpenMills = potentialOpenings; infos.opponentPotentailMills = opponentPotentialMills; }