[LIB-9] Separate chesshog-uci module
authorgotty <gotty@hedgecode.org>
Fri, 19 Apr 2019 01:55:06 +0000 (04:55 +0300)
committergotty <gotty@hedgecode.org>
Fri, 19 Apr 2019 01:55:07 +0000 (04:55 +0300)
57 files changed:
chesshog-uci/pom.xml [new file with mode: 0644]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/Acceptor.java [moved from src/main/java/org/hedgecode/chess/uci/Acceptor.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/AcceptorException.java [moved from src/main/java/org/hedgecode/chess/uci/AcceptorException.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/AcceptorRunner.java [moved from src/main/java/org/hedgecode/chess/uci/AcceptorRunner.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/AcceptorStub.java [moved from src/main/java/org/hedgecode/chess/uci/AcceptorStub.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/AcceptorStubRunner.java [moved from src/main/java/org/hedgecode/chess/uci/AcceptorStubRunner.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/CommandDescriptor.java [moved from src/main/java/org/hedgecode/chess/uci/CommandDescriptor.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/CommandEnvironment.java [moved from src/main/java/org/hedgecode/chess/uci/CommandEnvironment.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/CommandException.java [moved from src/main/java/org/hedgecode/chess/uci/CommandException.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/CommandExecutor.java [moved from src/main/java/org/hedgecode/chess/uci/CommandExecutor.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/ConsoleAcceptor.java [moved from src/main/java/org/hedgecode/chess/uci/ConsoleAcceptor.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/ConsoleAcceptorRunner.java [moved from src/main/java/org/hedgecode/chess/uci/ConsoleAcceptorRunner.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/DebugMode.java [moved from src/main/java/org/hedgecode/chess/uci/DebugMode.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/Engine.java [moved from src/main/java/org/hedgecode/chess/uci/Engine.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/EngineException.java [moved from src/main/java/org/hedgecode/chess/uci/EngineException.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/EngineRunner.java [moved from src/main/java/org/hedgecode/chess/uci/EngineRunner.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/ExternalEngine.java [moved from src/main/java/org/hedgecode/chess/uci/ExternalEngine.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/ExternalEngineRunner.java [moved from src/main/java/org/hedgecode/chess/uci/ExternalEngineRunner.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/ExternalEngineTransmitter.java [moved from src/main/java/org/hedgecode/chess/uci/ExternalEngineTransmitter.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/Runner.java [moved from src/main/java/org/hedgecode/chess/uci/Runner.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/SyncCommandExecutor.java [moved from src/main/java/org/hedgecode/chess/uci/SyncCommandExecutor.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/Transmitter.java [moved from src/main/java/org/hedgecode/chess/uci/Transmitter.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/UCICommand.java [moved from src/main/java/org/hedgecode/chess/uci/UCICommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/UCIConstants.java [moved from src/main/java/org/hedgecode/chess/uci/UCIConstants.java with 95% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/annotation/Command.java [moved from src/main/java/org/hedgecode/chess/uci/annotation/Command.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/annotation/CommandDirection.java [moved from src/main/java/org/hedgecode/chess/uci/annotation/CommandDirection.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/AbstractCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/AbstractCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/CommandParams.java [moved from src/main/java/org/hedgecode/chess/uci/command/CommandParams.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/GoParams.java [moved from src/main/java/org/hedgecode/chess/uci/command/GoParams.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/InfoParams.java [new file with mode: 0644]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/Move.java [moved from src/main/java/org/hedgecode/chess/uci/command/Move.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/OptionParams.java [moved from src/main/java/org/hedgecode/chess/uci/command/OptionParams.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/OptionType.java [moved from src/main/java/org/hedgecode/chess/uci/command/OptionType.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/from/BestMoveCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/from/BestMoveCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/from/CopyProtectionCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/from/CopyProtectionCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/from/IdCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/from/IdCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/from/InfoCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/from/InfoCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/from/OkCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/from/OkCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/from/OptionCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/from/OptionCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/from/ReadyOkCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/from/ReadyOkCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/from/RegistrationCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/from/RegistrationCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/from/TerminateCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/from/TerminateCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/to/DebugCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/to/DebugCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/to/GoCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/to/GoCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/to/InitCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/to/InitCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/to/IsReadyCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/to/IsReadyCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/to/NewGameCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/to/NewGameCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/to/PonderHitCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/to/PonderHitCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/to/PositionCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/to/PositionCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/to/QuitCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/to/QuitCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/to/RegisterCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/to/RegisterCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/to/SetOptionCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/to/SetOptionCommand.java with 100% similarity]
chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/to/StopCommand.java [moved from src/main/java/org/hedgecode/chess/uci/command/to/StopCommand.java with 100% similarity]
chesshog-uci/src/main/resources/org/hedgecode/chess/uci/LocalStrings.properties [moved from src/main/resources/org/hedgecode/chess/uci/LocalStrings.properties with 100% similarity]
chesshog-uci/src/main/resources/org/hedgecode/chess/uci/LocalStrings_ru.properties [moved from src/main/resources/org/hedgecode/chess/uci/LocalStrings_ru.properties with 100% similarity]
chesshog-uci/src/test/java/org/hedgecode/chess/uci/command/AbstractCommandTest.java [new file with mode: 0644]
src/main/java/org/hedgecode/chess/uci/command/InfoParams.java [deleted file]

diff --git a/chesshog-uci/pom.xml b/chesshog-uci/pom.xml
new file mode 100644 (file)
index 0000000..09bcb27
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Copyright (c) 2018. Developed by Hedgecode.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.hedgecode.chess</groupId>
+        <artifactId>chesshog</artifactId>
+        <version>0.1-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>chesshog-uci</artifactId>
+    <version>0.1-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <name>Hedgecode ChessHog UCI</name>
+    <description>
+        Hedgecode ChessHog UCI Module.
+    </description>
+
+    <properties>
+        <chessHogVersion>0.1-SNAPSHOT</chessHogVersion>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.hedgecode.chess</groupId>
+            <artifactId>chesshog</artifactId>
+            <version>${chessHogVersion}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hedgecode.chess</groupId>
+            <artifactId>chesshog-core</artifactId>
+            <version>${chessHogVersion}</version>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018. Developed by Hedgecode.
+ * Copyright (c) 2018-2019. Developed by Hedgecode.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@ public final class UCIConstants {
 
     private UCIConstants() {
         throw new AssertionError(
-                "No org.hedgecode.chess.uci.UCIConstants instances!"
+                "No UCIConstants instances!"
         );
     }
 
diff --git a/chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/InfoParams.java b/chesshog-uci/src/main/java/org/hedgecode/chess/uci/command/InfoParams.java
new file mode 100644 (file)
index 0000000..da3c5d8
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2018. Developed by Hedgecode.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hedgecode.chess.uci.command;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Container class for values of UCI command "info".
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public final class InfoParams {
+
+
+    private static final Pattern INFO_PATTERN =
+            Pattern.compile(
+                    String.format("^\\s*%s(.*)%s\\s+(%s)(.*)$" /*, ... */ )
+            );
+
+    private InfoParams() {
+
+    }
+
+/*
+
+    depth|seldepth|time|nodes|pv|multipv|score...|currmove|currmovenumber|hashfull|nps
+    tbhits|sbhits|cpuload|string|refutation|currline
+
+*/
+
+
+    public static final class Factory {
+
+        public static InfoParams parse(String option) {
+            Matcher matcher = INFO_PATTERN.matcher(option);
+            if (matcher.find()) {
+/*
+                return new InfoParams(
+                        matcher.group(1).trim(),
+                        matcher.group(2).trim(),
+                        matcher.group(3).trim()
+                );
+*/
+            }
+            return null;
+        }
+
+    }
+
+
+}
diff --git a/chesshog-uci/src/test/java/org/hedgecode/chess/uci/command/AbstractCommandTest.java b/chesshog-uci/src/test/java/org/hedgecode/chess/uci/command/AbstractCommandTest.java
new file mode 100644 (file)
index 0000000..3ca6fd5
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2018-2019. Developed by Hedgecode.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hedgecode.chess.uci.command;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import org.hedgecode.chess.uci.Acceptor;
+import org.hedgecode.chess.uci.Engine;
+
+/**
+ * Tests for {@link AbstractCommand}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class AbstractCommandTest extends Assert {
+
+    @Test
+    public void testParseMove() throws Exception {
+
+        String[] correctMoves = {"e2e4", "e7e5", "e1g1", "e7e8q", "0000"};
+        for (String correctMove : correctMoves) {
+            Move move = new AbstractCommand() {
+                @Override
+                public void exec(Engine engine, Acceptor acceptor, String params) {
+                    throw new RuntimeException("Don't supported in test class!");
+                }
+            }.parseMove(correctMove);
+
+            assertNotNull(move);
+        }
+
+        String[] incorrectMoves = {"00e2", "e0e5", "e1j1", "a1a9", "e7e8k"};
+        for (String incorrectMove : incorrectMoves) {
+            Move move = new AbstractCommand() {
+                @Override
+                public void exec(Engine engine, Acceptor acceptor, String params) {
+                    throw new RuntimeException("Don't supported in test class!");
+                }
+            }.parseMove(incorrectMove);
+
+            assertNull(move);
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/hedgecode/chess/uci/command/InfoParams.java b/src/main/java/org/hedgecode/chess/uci/command/InfoParams.java
deleted file mode 100644 (file)
index c4d67d4..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2018. Developed by Hedgecode.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.hedgecode.chess.uci.command;
-
-/**
- * Container class for values of UCI command "info".
- *
- * @author Dmitry Samoshin aka gotty
- */
-public final class InfoParams {
-
-
-}