Skip to content

Latest commit

 

History

History
69 lines (56 loc) · 3.17 KB

README.md

File metadata and controls

69 lines (56 loc) · 3.17 KB

Chess engine support library for Android

This Android library offers a standardized way for app developers to

  • provide chess engines to other chess apps

  • use provided chess engines in other chess apps

Engine authors: how to provide a chess engine using this library:

<application
...
    >
    <activity
... >
        <intent-filter>
            <action android:name="intent.chess.provider.ENGINE" />
        </intent-filter>
        <meta-data
            android:name="chess.provider.engine.authority"
            android:value="your.package.name.YourEngineProvider" />
    </activity>

    <provider
        android:name="your.package.name.YourEngineProvider"
        android:authorities="your.package.name.YourEngineProvider"
        android:exported="true" />
</application>

Add YourEngineProvider.java to your project something like:

package your.package.name;

import com.kalab.chess.enginesupport.ChessEngineProvider;

public class YourEngineProvider extends ChessEngineProvider { } 

GUI authors: how to support the open exchange format

EngineResolver resolver = new EngineResolver(context); 
List<Engine> engines = resolver.resolveEngines();

Engines is now a list of ChessEngines for the current target.

You can use:

Engine firstEngine = engines.get(0); 
File copiedEngine = firstEngine.copyToFiles(this.getActivity().getContentResolver(), this.getActivity().getFilesDir()); 

...to copy the first engine to your app files directory.

The executable flag is already set. Save the engine file name, engine package name and engine version (see getters) in your preferences to check them later if they're current.

  • To check if the engine you're using is up-to-date use this method:
ChessEngineResolver resolver = new ChessEngineResolver(context); 
int newVersionCode = resolver.ensureEngineVersion(engineFileName, enginePackageName, currentVersionCode, this.getActivity().getFilesDir());