user13544: So I played many games online where I am winning but then lose on time. Sometimes the game is drawn (when there is no sequence of legal moves that would produce checkmate) and sometimes I lose (when there is such a sequence). The decision the website takes happens instantly. I am wondering, how do they determine whether the game is a draw or not? If they use brute force, then the decision would take longer to arrive at.

user15296: This comes from python-chess:
def is_insufficient_material(self):
    """Checks for a draw due to insufficient mating material."""
    # Enough material to mate.
    if self.pawns or self.rooks or self.queens:
        return False

    # A single knight or a single bishop.
    if popcount(self.occupied) <= 3:
        return True

    # More than a single knight.
    if self.knights:
        return False

    # All bishops on the same color.
    if self.bishops & BB_DARK_SQUARES == 0:
        return True
    elif self.bishops & BB_LIGHT_SQUARES == 0:
        return True
    else:
        return False


user4393: As far as I know, every chess website simply looks at the opponents material to determine if they have mating material or not. It doesn't matter even if mate is possible.
The ruleset you are referring to are the FIDE rules, and for simplicity chess websites do not use these rules because the percentage of positions where self-mate is possible is too low.

13544: <p>So I played many games online where I am winning but then lose on time. Sometimes the game is drawn (when there is no sequence of legal moves that would produce checkmate) and sometimes I lose (when there is such a sequence). The decision the website takes happens instantly. I am wondering, how do they determine whether the game is a draw or not? If they use brute force, then the decision would take longer to arrive at.</p>
 15296: <p>This comes from python-chess:</p>

<pre><code>def is_insufficient_material(self):
    """Checks for a draw due to insufficient mating material."""
    # Enough material to mate.
    if self.pawns or self.rooks or self.queens:
        return False

    # A single knight or a single bishop.
    if popcount(self.occupied) &lt;= 3:
        return True

    # More than a single knight.
    if self.knights:
        return False

    # All bishops on the same color.
    if self.bishops &amp; BB_DARK_SQUARES == 0:
        return True
    elif self.bishops &amp; BB_LIGHT_SQUARES == 0:
        return True
    else:
        return False
</code></pre>
 4393: <p>As far as I know, every chess website simply looks at the opponents material to determine if they have mating material or not. It doesn't matter even if mate is possible.</p>

<p>The ruleset you are referring to are the FIDE rules, and for simplicity chess websites do not use these rules because the percentage of positions where self-mate is possible is too low.</p>
