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
  • The Coolest Chess + Stockfish AI
  • WebGL Setup
  • Tested Settings

Importing Stockfish AI

This section is for people who own The Coolest Chess Unity Asset Store asset who wish to introduced Stockfish AI into it.

PreviousComponentsNextController

Last updated 3 months ago

Stockfish is a very powerful chess position analytic chess engine, well-known by the chess community. I did make it as a plug and use AI Engine awhile ago on top of , it supports up to five major platform including Windows, MacOS, Android, WebGL and iOS

For those who do not own The Coolest Chess Asset Store package, it's reluctant to read this section. The can be found on the link.


The Coolest Chess + Stockfish AI

The prepared scene for Stockfish

There is one scene made as a demonstration of using Stockfish with The Coolest Chess package named ChessWithStockfish. In order for this scene to work, Stockfish must be imported from github page.

Instruction on how to import Stockfish to Unity

Go to Windows -> Package Manager. Then select + dropdown button and then select Add package from git URL as shown in the gif above. Copy and paste the Stockfish dependency url https://github.com/githubvickson/sf.git to the input field and click Add button, the dependency will be added to Packages folder automatically. The ChessWithStockfish scene is ready at this stage. However, for WebGL, there are a bit more work to be done.

If things go right, you will see these results.

WebGL Setup

1) Move WebGLTemplates folder to root folder, it is necessary for when building the index.html containing working Stockfish.

2) Copy files from the dependency installed into StreamingAssets folder

In folder Packages\Multiplatform ChessStockfish AI\jsfiles, copy all of the files inside the folder to Assets\StreamingAssets folder, do it by using copy and paste through Windows File Explorer, dragging into Unity Editor project tab won't work. Look at gif below for visualisation.

3) In order for build to show up the index.html from WebGLTemplates folder,

From Unity Editor Toolbar, select Edit -> Project Settings -> Player -> WebGL settings(the one with html 5 icon) -> Resolution and Presentation -> WebGL Template -> from Default switch to stockfish. Check gif below for visualisation. Everything is done at this stage, Stockfish in WebGL build will work just fine at this point.

Tested Settings

Tested Skill And Time Settings (Note that the purpose of skill is to enhance the AI to make moves without blunder while time is to allow it to see through future if the move are the best)

(skill : -20.0, time : 1.0) //500~600 ELO
(skill : 0.0, time : 20.0) //1350 ELO
(skill : 2.0, time : 20.0) //1550 ELO
(skill : 5.0, time : 20.0) //1650 ELO
(skill : 10.0, time : 20.0) //1750 ELO
(skill : 13.0, time : 20.0) //1820 ELO
(skill : 15.0, time : 20.0) //1870 ELO
(skill : 17.0, time : 20.0) //1920 ELO
(skill : 20.0, time : 20.0) //2050 ELO
(skill : 15.0, time : 100.0) //2150 ELO
(skill : 17.0, time : 100.0) //2300 ELO
(skill : 18.0, time : 100.0) //2400 ELO
(skill : 19.0, time : 100.0) //2500 ELO
(skill : 20.0, time : 100.0) //2600 ELO
(skill : 17.0, time : 1000.0) //2680 ELO
(skill : 18.0, time : 1000.0) //2780 ELO
(skill : 19.0, time : 1000.0) //2880 ELO
(skill : 20.0, time : 1000.0) //2980 ELO
(skill : 20.0, time : 3000.0) //3100 ELO

The Coolest Chess
official Stockfish website