Increase difficulty based on score What I'm trying to do is very straightforward and easy, but I am wondering whether there is a more elegant solution. 

Basically I have a game and I want the difficulty to increase the moment the score gets between 100 - 500, then increase once again when the score is between 500 - 1500, then again when the score is between 1500 - 3000. In total, the difficulty should increase 3 times.

I need to check:


Whether I am in one of those ranges. 
Whether I already increased the score when I got in that range. 


Here's what I've got.

bool Increased100500 = false;
bool Increased5001500 = false;
bool Increased15003000 = false;

void IncreaseScore()
{
    if (Score &gt;= 100 &amp;&amp; Score &lt;= 500 &amp;&amp; !Increased100500)
    {
        Increase();
        Increased100500 = true;
    } 
    else if (Score &gt;= 500 &amp;&amp; Score &lt; 1500 &amp;&amp; !Increased5001500)
    {
        Increase();
        Increased5001500 = true;
    } 
    else if (Score &gt;= 1500 &amp;&amp; !Increased15003000)
    {
        Increase();
        Increased15003000 = true;
    } 
}


LE: I should have mentioned that the method above is called multiple times per frame.
Be careful with your inequalities.  You've listed 500 twice: once as if (Score &lt;= 500) and again as else if (Score &gt;= 500).  That's confusing, as the first condition takes precedence.

I think that you would be better off with one state variable representing the current difficulty level.  The code would also be simpler if you determine NewDifficulty using a level-triggered rather than edge-triggered mechanism.

int Difficulty;

void IncreaseScore()
{
    int NewDifficulty = (Score &lt;   100) ? 0
                      : (Score &lt;=  500) ? 1
                      : (Score &lt;= 1500) ? 2
                                        : 3;
    // One-way ratchet: difficulty can only increase, even if the
    // score subsequently drops.
    if (NewDifficulty &lt; Difficulty)
    {
        Difficulty = NewDifficulty;
    }
}


If the score can never decrease in this game, then you can simplify it further:

void IncreaseScore()
{
    Difficulty = (Score &lt;   100) ? 0
               : (Score &lt;=  500) ? 1
               : (Score &lt;= 1500) ? 2
                                 : 3;
}