The Coolest Chess
  • The Chess Documentation
    • Chess Game Introduction
    • Essential Prefabs
    • Components
  • Importing Stockfish AI
  • Controller
    • Base Controller
    • Two Player Controller
  • The UIs
    • Button Prefabs
    • UI Events
    • Enquiry
    • Replacing UI
    • Others
  • Scenes Details
    • ChessPGN
    • ChessPuzzleEditor
    • ChessPuzzle
    • ChessAI
  • Honorable Mentioned
    • ChessBoard class
    • GUI Classes
    • Game Logic Classes
    • The Architecture Notice
  • Customization
    • Time AI
    • AI Draw Game
    • TypeI AI
    • TypeII AI
    • Event Based Functions
    • Chess Game Finishing Rule
  • Unit Tests
Powered by GitBook
On this page
  • Customizing AI draw game logic
  • AI level to Their Draw Tolerence Level
  1. Customization

AI Draw Game

This page shows the potential of customizing AI to respond to draw game offer and also their own draw and resign game offering.

PreviousTime AINextTypeI AI

Last updated 5 months ago

Customizing AI draw game logic

There are three ascending levels of draw game functions in ChessGameAI class that are used by AI for decisions such as making draw offer and accepting draw offers. RequestByFirstToleranceLevel, RequestBySecondToleranceLevel and RequestByThirdToleranceLevel functions, all have the common variables as shown on the image above, which can be customized for different draw behaviour. All of the values of these variables are a benchmark to position score.

-margin -> The position score from within range 0 to +-margin at which draw offer will directly being rejected. For example, if margin is 100, when AI is white and position score is within 100 or -100 for black, they will never accept draw offer. It will send Reject Comment text in this case.

-optimism -> The confidence threshold AI had while the game position score was favoring their opponent by the optimism amount. This is related to The Optimistic Comment.

-surrenderMargin -> If AI' opponent has a leading position score beyond the surrenderMargin, AI will request for a resign offer.

-For Still Want To Play Comment, it is dependent on the pieces count on the board during early game. All three functions has the same condition for this particular case which is no more than 14 pieces in total and no less than 5 pieces for AI color.

RequestBySecondToleranceLevel and RequestByThirdToleranceLevel functions however, have surrender variable which the value is the position score for endgame when AI side has no major pieces left including rook and queen. When the condition is met and the position score is beyond the surrender value for AI' opponent, AI will resign.

AI level to Their Draw Tolerence Level

There are already enum prepared to easily assign which functions to call for which AI level. Check out ChessAITypeIIMechanism class and ChessAITypeIMechanism class for their getter DrawToleranceLevel. The enum value One indicate RequestByFirstToleranceLevel will be used for the AI level, Two beingRequestBySecondToleranceLevel and Three for RequestByThirdToleranceLevel.

-tooEarly -> When total moves made since the beginning of a chess game never reach beyond this threshold, draw offer will be rejected with .

Too Early Comment