Test für Eröffnungserkennung und kleine Änderungen

openingRecognition
Marius Gündel 2025-06-30 14:49:11 +02:00
parent 9995299331
commit 3a9084da0b
5 changed files with 40 additions and 4 deletions

View File

@ -26,7 +26,7 @@ public class App {
* @throws IOException
*/
public static void main(String[] args) throws IOException {
new MainFrame();
OpeningRecognizer.loadOpenings();
new MainFrame();
}
}

View File

@ -109,7 +109,11 @@ public class Game {
public void playMove(Move move) {
Piece removedPiece = board.getPiece(move.getTo());
if (removedPiece != Piece.NONE) {
int removedPiecesCount = removedPieces.size();
removedPieces.add(removedPiece);
if (removedPiecesCount + 1 < removedPieces.size()) {
removedPieces.removeLast();
}
}
this.board.doMove(move);
this.movelist.add(move);

View File

@ -273,6 +273,7 @@ public class SpielFrame extends JFrame {
}
}
@Deprecated
public void showWin(int player) {
JFrame frame = new JFrame("Result");
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);

View File

@ -3,7 +3,6 @@ package de.mannheim.th.chess.utl;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.spi.FileSystemProvider;
import java.util.ArrayList;
import java.util.List;

View File

@ -0,0 +1,32 @@
package de.mannheim.th.chess.utl;
import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import com.github.bhlangonijr.chesslib.Square;
import com.github.bhlangonijr.chesslib.move.Move;
import com.github.bhlangonijr.chesslib.move.MoveList;
class OpeningRecognizerTest {
@BeforeAll
static void prepareOpenings() throws IOException {
OpeningRecognizer.loadOpenings();
}
@Test
void test() {
Move m = new Move(Square.E2, Square.E4);
MoveList moves = new MoveList();
moves.add(m);
assertEquals(OpeningRecognizer.compareOpening(moves, "Unknown"), "King's pawn Opening");
}
}