Chess Game Finishing Rule

Chess game finishing rules are being set on game logic, ChessGame class. However, they can be modified for specific needs independently.

ChessGame class

This class has all the logic code for standard chess game finishing rule. The condition in which they will be triggered is exactly as described in introduction.

  • Checkmate

  • Stalemate

  • Fifty-Moves Rule

  • Threefold Repetition

  • SeventyFive-Moves Rule

  • Fivefold Repetition

  • Insufficient Material

Below sections are all chess logic classes that had their chess game finishing logic being modified from this base class.

ChessGameMoveVariant class

The modification includes the removal of threefold repetition and fifty-moves rule and the insufficient material condition had been changed to when only one-sided pieces color left on the board.

Since this game logic is mainly used by PGN scene and more towards analytic game mode purposes, it's illogical to let our chess logic having draw option or even forcing draw on threefolds repetition or fifty-moves rule.

ChessGamePuzzle class

This chess logic game finishing rule has only passed puzzle and failing puzzle, this is the reason why ChessPuzzle scene didn't shows any of the standard chess game finishing rule but only for when passing or failing the puzzle.

ChessPuzzleEditor class

Since this game logic is tailored to puzzle editing functionalities, the chess game finishing rule is minimalized, just to prevent the user from making puzzle level that's over what the standard chess game can do.

The chess game finishing rule includes checkmate, stalemate and insufficient material. The insufficient material condition is made to be the same as ChessGameMoveVariant, which is only happening when one side has empty pieces.

How to Modify Chess Game Finishing Rule

The chess game finishing rule logic is dictated by the _chessGameFinish variable while only the function _CheckIfGameHasFinished(ChessGameFinish) from chess game logic classes can modify the variable value. To modify the rule, head on to the aforementioned overriden function or override it if it's not already being overriden and copy and paste what's needed and remove what's not needed.

As long as there aren't any chances to set _chessGameFinish variable to threefolds repetition or fifty-moves rule in _CheckIfGameHasFinishedfunction, the GUI will never display an option UI asking for if player wanting to draw from threefolds repetition or fifty-moves rule. The draw button will also never work for threefolds repetition and fifty-moves rule any more, for GUI that uses the game logic.

There are several chess game finishing types already prepared

    public enum ChessGameFinishType
    {
        Surrender,
        Checkmate,

        Stalemate,
        ThreeFoldsRepetition,
        InsufficientMaterial,
        FiftyMoveRule,
        FiveFoldsRepetition,
        SeventyFiveMoveRule,
        MutualAgreement,

        PassPuzzle,
        FailedPuzzle
    }

All of the words up there are obvious while for the not very obvious one are :

Surrender - For when opponent surrender offer is accepted.

MutualAgreeemnt - For when both parties accepted to draw the game.

PassPuzzle/FailedPuzzle - Used by puzzle game, the ChessGamePuzzle chess logic class.

ChessGameFinish constructor accepts two parameters, the first one being the enum values shown above while the other is ChessGameResult. Only for when there's a winning or losing result the ChessGameResult class should be provided with a value. Otherwise, null means the type is draw.

_chessGameFinish = new ChessGameFinish(Checkmate, new ChessGameResult(winning color));
_chessGameFinish = new ChessGameFinish(OtherThanCheckmate, new ChessGameResult(null));

Last updated