Posts

Showing posts with the label FEN

Checkers for Android: Position Setup

Image
I finished a position setup feature for Checkers for Android, similar to what was already in Chess for Android. This feature allows users to copy interesting checker problems from textbooks or other sources and play from there to improve their game. In addition, I added an option to show the square labels to make playing out variants from textbooks a bit easier for players that are less familiar with the numbering scheme.

Since I recently also added a feature to export games as PDN, this implied I also had to implement FEN setup for games that do not start from the initial position. An example is shown below (note the FEN tag, and the empty first ply since it is white's move in the given position).

[Event "Checkers for Android Game"]
[Site "United States"]
[Date "2019.01.19"]
[White "Checkers for Android"]
[Black "Self"]
[Result "*"]
[PlyCount "0"]
[Setup "1"]
[FEN "W:W9,K32:B13,K1"]

1...  *


Viewing application/x-chess-pgn MIME type

Starting with v3.1, Chess for Android registers itself as a viewer for the application/x-chess-pgn MIME type. This implies that when other Android applications request viewing a game in PGN format, Chess for Android, or any other chess program that supports this type, will open the game.

I am new to this mechanism, but the following two ways of viewing a game seem to work well. To request viewing a game in PGN format that resides in a file (with proper permissions, so that other applications can read it), simply use the following code sequence:

Intent intent = new Intent(Intent.ACTION_VIEW);
File file = ... file in pgn format ....;
intent.setDataAndType(Uri.fromFile(file), "application/x-chess-pgn");
startActivity(intent);

Alternatively, to view a game in PGN format that resides in a String, use the following code sequence (in this case, avoid confusing characters such as ':' in the String format):


Intent intent = new Intent(Intent.ACTION_VIEW);
String data = ".... g…

Rebel ELO Test Corrections and Results

Image
Running tournaments on diverse test suites gave me more confidence in the correctness of my FEN and PGN parser. This time Chess for Android found bugs in the "Rebel ELO Test". Positions ELO 30, 121, 170 do not set the castling rights for either black or white properly, even though castling is the first given move (that is, the move the engine is supposed to find when used as a tactical test suite; when used as an opening suite, this move is obviously played right away).

The results of (mis)using the corrected test suite as an opening suite in a fast match between the built-in Java engine and Stockfish 2.1 on a Nexus One is shown below.                   

1 Stockfish 2.1    +421/  -4/=27 96.13%  434.5/452
2 Chess for Android  +4/-421/=27  3.87%   17.5/452

Here is one of the sparse victories of Chess for Android playing white from a very advantageous position. Nevertheless, I am happy that it found the right continuation as 1. Qc8+ (given in the suite) Kg7 2. Qf8+ Kg6 3. Qf7+ K…

Chess for Android 2.8

Image
I just released version 2.8 of Chess for Android, available from the Android Market or as direct download.

New features include:
full PGN support (clipboard import/export, file load/save)improved layout for xlarge screen sizes (api 9 and up)bug fix in draw detection after FEN importTo load a game from a file in PGN format, long press the notation window, select "Load Game from SD", and navigate to the file. This opens another window with the actual games in that file. Then select the desired game. Very large PGN files may take a while to download (or even run out of memory), but the idea is that future versions will be able to navigate quickly between successive games. I have tried to make the PGN parser reasonably robust (it accepts sloppy SAN for instance), but certain non-standard constructs are rejected. Please let me know if you encounter bugs though.