Skip to content
This repository was archived by the owner on Nov 27, 2021. It is now read-only.

Commit 8486f4a

Browse files
committed
1.1
1 parent 131d5ac commit 8486f4a

4 files changed

Lines changed: 3530 additions & 3434 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22

33
CompactChessOpenings is an open-source Java 7+ library which adds all ECO openings to CompactChess.
44

5+
The ECO openings are being sourced from [niklasf/eco](https://github.com/niklasf/eco).
6+
57
- [More information](https://compactchess.cc/openings)
68
- [Downloads](https://github.com/hell-sh/CompactChessOpenings/releases) (dependencies not included)

eco.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
foreach(json_decode(file_get_contents("eco.json")) as $opening)
33
{
44
$cfen = str_replace("/", "", $opening->f);
5-
echo "openings.add(new Opening(\"{$opening->c}\", \"{$opening->n}\", \"{$cfen}\"));\n";
5+
echo "openings.add(new Opening(\"{$opening->c}\", \"{$opening->n}\", \"{$cfen}\", \"{$opening->m}\"));\n";
66
}

src/Tests.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,36 @@
11
import org.junit.Test;
22
import sh.hell.compactchess.exceptions.ChessException;
33
import sh.hell.compactchess.game.Game;
4+
import sh.hell.compactchess.game.Move;
45
import sh.hell.compactchess.game.Opening;
56

7+
import java.util.ArrayList;
8+
69
import static junit.framework.TestCase.assertEquals;
10+
import static junit.framework.TestCase.assertFalse;
11+
import static junit.framework.TestCase.assertTrue;
712

813
public class Tests
914
{
1015
@Test(timeout = 3000L)
1116
public void openings() throws ChessException
1217
{
1318
System.out.println("Openings\n");
14-
final Game game = Game.fromPGN("1.e4 e5 2.Nf3 Nc6 3.Bb5 a6 4.Ba4 Nf6 5.O-O Be7 6.Re1 b5 7.Bb3 O-O 8.c3 d5 9.exd5 Nxd5 10.Nxe5 Nxe5 11.Rxe5 c6 12.d4 Bd6 13.Re1 Qh4 14.g3 Qh3 15.Be3 Bg4 16.Qd3 Rae8 17.Nd2 Re6 18.a4 Qh5 19. axb5").get(0);
19+
final Game game = Game.fromPGN("1.e4 e5 2.Nf3 Nc6 3.Bb5 a6 4.Ba4 Nf6 5.O-O Be7 6.Re1 b5 7.Bb3 O-O 8.c3 d5 9.exd5 Nxd5 10.Nxe5 Nxe5 11.Rxe5 c6 12.d4 Bd6 13.Re1 Qh4 14.g3 Qh3 15.Be3 Bg4 16.Qd3 Rae8 17.Nd2 Re6 18.a4").get(0);
20+
final ArrayList<Opening> continuations = Opening.getContinuations(game);
21+
assertEquals(1, continuations.size());
22+
final Opening opening = continuations.get(0);
23+
assertFalse(opening.isUsedIn(game));
24+
assertTrue(opening.canBeUsedIn(game));
25+
final Move nextMove = opening.getNextMove(game);
26+
assertEquals("h3h5", nextMove.toUCI());
27+
nextMove.commit();
28+
assertTrue(opening.isUsedIn(game));
29+
game.uciMove("a4b5").commit();
30+
assertTrue(opening.isUsedIn(game));
1531
Opening.insertInto(game, false, true);
1632
System.out.println(game.toPGN());
17-
assertEquals("Ruy Lopez: Marshall, Main Line, Spassky Variation", game.tags.get("Opening"));
33+
assertEquals("Ruy Lopez: Marshall, Main Line, Spassky Variation", game.tags.get("Opening")); // This is the longest opening with 36 plies.
1834
assertEquals("C89", game.tags.get("ECO"));
1935
int i = 0;
2036
assertEquals("B00 King's Pawn", game.moves.get(i++).getAnnotation());

0 commit comments

Comments
 (0)