TypeI AI

This page shows what can be and how to customize for TypeI AI.

TypeI AI Behaviour

On ChessAITypeIMechanism class, there are min max value that can be modified for a different AI behaviour. Min will increase the importance of the valuation of a function against others. Max will amplify the priority the function being taken into account first. For example, lowering the max value of ChessAIBoardRaterPawnProgression from 10.0 to 5.0 may reduce the chance AI rush their pawn to opponent side during early game. The change of AI behaviour from changing min value might not as obvious as of changing max value.

ChessAIBoardRaterCenterOwnership - Evaluate pieces that are getting closer to the center square D4,D5,E4,E5, this will make pieces wanting to get closer to the center tile.

ChessAIBoardRaterMobilityDominance - Evaluate The mobility of all pieces on the board for the chess board position, get and evaluate scores for each move of each piece available. This will make AI pick pieces that can move the most tile.

BoardRaterCenterMobilityDominance - Evaluate pieces that are getting closer to the center square D4,D5,E4,E5 while considering their movability. Like ChessAIBoardRaterCenterOwnership, but will consider the number of tiles needed for pieces to reach the center tile.

ChessAIBoardRaterPawnProgression - Evaluate pawn progression toward being promoted, this will encourage pawn to walk into promotion tile, but also make pawn more aggressive toward their progression.

ChessAIBoardRaterKingSurroundingPossession - Evaluate the attackable piece by the king surrounding the king and alliance piece of the king surrounding it. This will discourage king moving to tile that has potential threat while favoring move that keep it further away from opponent pieces and also getting closer to pieces that can protect it.

ChessAIBoardRaterCenterFourOccupation - Evaluate pieces that dominate the center square D4,D5,E4,E5, this will make pieces wanting to stay at the center tile.

ChessAIBoardRaterCountPieces - Evaluate the number of pieces on the board, by taking into account pieces valuation, like queen will have the highest valuation since it's the most useful piece. This will discourage AI throwing away their more important pieces.

ChessAIBoardRaterOpponentCheckMateOpportunity - Evaluate the tendency of checkmaking by opponent. This will straight away avoiding being checkmate.

ChessAIBoardRaterThreatenedPieces - Evaluate the tendency to protect own pieces & piece trade valuation. This will evaluate if trading pieces worthwhile.

ChessAIBoardRaterCastle - Evaluate castle move. This will force making castle move if there's one.

ChessAIBoardRaterEndGameForceCheckKing - Evaluate a checking move. This will encourage moves that can check king, only when during endgame, when pieces count for AI is less than 7.

ChessAIBoardRaterShouldFinishGame - Evaluate the tendency to finish a game. This will prioritize move that can checkmate opponent.

ChessAIBoardRaterStickToOpponentKing - Make king get closer to opponent king, for easier checkmate when pieces count on the board are getting lower.

Tips - It is also possible to add a new evaluating function by extending ChessAIBoardRater class, like all others evaluating functions from above did.

There is also a multiplier value in this class that can be changed to reflect the overall change to the strength of TypeI AI.

Adding new difficulty

Adding a new difficulty to TypeI AI has to be done manually in this ChessAITypeIMechanism class, first by adding a new enum value to Difficulty enum, in this case Eleven = 11.

Subsequently, add a new case to DrawToleranceLevel getter, like the code below

case Difficulty.Eleven:
    return DrawToleranceLevel.Two;

Also, on the multiplier getter, a new case is also needed for the overall strength for the new AI. The value 2.5 is an example only.

case Difficulty.Eleven:
    return 2.5; //elo ??? 

In the LoadScriptableObjects function, add the following new case. A new scriptable object named Difficulty11 needed for when AI reject draw comment.

case Difficulty.Eleven:
        drawCommentSO = Resources.Load<ChessAIDrawCommentSO>(resourceFilePath + "Difficulty11");

Go to path Resources/ScriptableObjects/ChessAI/DrawComments and create a new ChessAIDrawCommentSO scriptable object and named it Difficulty11 because the string from above code is refering to Difficulty11.

Finally, the last step is to add a new dropdown to TypeI AI Level In the AIUIs prefabs from the folder Prefabs/UIs/Others, it can be named whatever for the new dropdown. That's all, the new TypeI AI level is ready in scene with AI.

Last updated