Exemple #1
0
    //------------------------------------------------------------
    // checks whether the current transmitter is powered,
    // then reflects that in its neighbors recursively
    //------------------------------------------------------------
    static void AssessPower(Transmitter t)
    {
        t.updated = true;
        if (t.broken)
        {
            t.SetPower(false);
        }

        if (!t.powered)
        {
            return;
        }

        foreach (Transmitter next in t.FindNeighbors())
        {
            if (next.updated == true)
            {
                continue;
            }
            next.SetPower(true);
            AssessPower(next);
        }
        if (t.powered)
        {
            t.FindNearbyHouses();
        }
    }