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

Commit

Permalink
Initial commit (1.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Speckhals committed Sep 2, 2018
0 parents commit 42ddadd
Show file tree
Hide file tree
Showing 6 changed files with 3,647 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
.idea/
out/
*.iml
eco.json
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Hellsh

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 6 additions & 0 deletions README.md
@@ -0,0 +1,6 @@
# CompactChessOpenings

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

- [More information](https://hell.sh/CompactChess/openings)
- [Downloads](https://github.com/hell-sh/CompactChessOpenings/releases) (dependencies not included)
6 changes: 6 additions & 0 deletions eco.php
@@ -0,0 +1,6 @@
<?php
foreach(json_decode(file_get_contents("eco.json")) as $opening)
{
$cfen = str_replace("/", "", $opening->f);
echo "openings.add(new Opening(\"{$opening->c}\", \"{$opening->n}\", \"{$cfen}\"));\n";
}
58 changes: 58 additions & 0 deletions src/Tests.java
@@ -0,0 +1,58 @@
import org.junit.Test;
import sh.hell.compactchess.exceptions.ChessException;
import sh.hell.compactchess.game.Game;
import sh.hell.compactchess.game.Opening;

import static junit.framework.TestCase.assertEquals;

public class Tests
{
@Test(timeout = 1000L)
public void openings() throws ChessException
{
System.out.println("Openings\n");
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);
Opening.insertInto(game, false, true);
System.out.println(game.toPGN());
assertEquals("Ruy Lopez: Marshall, Main Line, Spassky Variation", game.tags.get("Opening"));
assertEquals("C89", game.tags.get("ECO"));
int i = 0;
assertEquals("B00 King's Pawn", game.moves.get(i++).getAnnotation());
assertEquals("C20 King's Pawn Game", game.moves.get(i++).getAnnotation());
assertEquals("C40 King's Knight Opening", game.moves.get(i++).getAnnotation());
assertEquals("C44 King's Knight Opening: Normal Variation", game.moves.get(i++).getAnnotation());
assertEquals("C60 Ruy Lopez", game.moves.get(i++).getAnnotation());
assertEquals("C70 Ruy Lopez", game.moves.get(i++).getAnnotation());
assertEquals("C68 Ruy Lopez: Columbus Variation", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("C78 Ruy Lopez: Morphy Defense", game.moves.get(i++).getAnnotation());
assertEquals("C84 Ruy Lopez: Closed Variations", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("C88 Ruy Lopez: Closed", game.moves.get(i++).getAnnotation());
assertEquals("C88 Ruy Lopez: Closed, 7... O-O", game.moves.get(i++).getAnnotation());
assertEquals("C88 Ruy Lopez: Closed, 8. c3", game.moves.get(i++).getAnnotation());
assertEquals("C89 Ruy Lopez: Marshall Attack", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("C89 Ruy Lopez: Marshall Attack, Modern Variation", game.moves.get(i++).getAnnotation());
assertEquals("C89 Ruy Lopez: Marshall Attack, Main Line", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("C89 Ruy Lopez: Marshall Attack, Modern Main Line", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i++).getAnnotation());
assertEquals("C89 Ruy Lopez: Marshall, Main Line, Spassky Variation", game.moves.get(i++).getAnnotation());
assertEquals("", game.moves.get(i).getAnnotation());
}
}

0 comments on commit 42ddadd

Please sign in to comment.