RunicBoard.IsConnectedToCenter C# (CSharp) Method

IsConnectedToCenter() public method

Return if the position is connected to the center
public IsConnectedToCenter ( int position, List &explored, Rune>.Dictionary &board ) : bool
position int The position to test
explored List List of explored positions
board Rune>.Dictionary The board to test
return bool
    public bool IsConnectedToCenter(int position, ref List<int> explored, ref Dictionary<int, Rune> board)
    {
        if (position == 12)
        {
            return true;
        }

        if (explored == null)
        {
            explored = new List<int>();
        }

        explored.Add(position);
        List<int> positions = GetNeighboursPosition(position, board);

        for (int i = 0; i < positions.Count; i++)
        {
            if (!explored.Contains(positions[i]))
            {
                bool connected = IsConnectedToCenter(positions[i], ref explored, ref board);
                if (connected)
                    return true;
            }
        }

        return false;
    }