Ejemplo n.º 1
0
    private void Neghbour(int cellIndex, NeighbourType type, DiskType attacker)
    {
        int           neghbourIndex = grid.GetCellNeghbourIndex(cellIndex, type);
        HashSet <int> flipPath      = new HashSet <int>();

        while (neghbourIndex >= 0 && tempBoard[neghbourIndex] != attacker && tempBoard[neghbourIndex] != DiskType.Default)
        {
            flipPath.Add(neghbourIndex);
            neghbourIndex = grid.GetCellNeghbourIndex(neghbourIndex, type);
        }
        if (neghbourIndex == -1 || tempBoard[neghbourIndex] == attacker || flipPath.Count < 1)
        {
            return;
        }

        if (ValidMoves.ContainsKey(neghbourIndex))
        {
            ValidMoves[neghbourIndex].UnionWith(flipPath);
        }
        else
        {
            ValidMoves.Add(neghbourIndex, flipPath);
        }
    }