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.

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 The Chess Unity Asset Store asset package, support up to five major platform including Windows, MacOS, Android, WebGL and iOS

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

The Chess + Stockfish AI

The prepared scene for Stockfish

There is one scene made as a demonstration of using Stockfish with The Chess package named ChessWithStockfish. In order for this scene to work, Stockfish must be imported from my 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 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.

Last updated