Skip to content

Commit

Permalink
handle input
Browse files Browse the repository at this point in the history
  • Loading branch information
jalpp authored Feb 14, 2024
1 parent 7b2fd30 commit f5d7e60
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 51 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ quit (Quit the engine)
```
git clone LiseChessEngine
cd LiseChessEngine/engine/UCIStarter
cd LiseChessEngine/src/main/java/engine/UCIStarter
java -jar LISEBOT.jar
Expand Down
128 changes: 78 additions & 50 deletions src/main/java/engine/UCIProtocolRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,26 @@ public static void main(String[] args) {
break;
}
} else if (input.startsWith("position")) {
String fen = input.substring("position".length()).trim();
if(fen.contains("b")){
Board b = new Board();
b.setSideToMove(Side.BLACK);
b.loadFromFen(fen);
LiquidSearchEngine engineFEN = new LiquidSearchEngine(b);
System.out.println(engineFEN.findBestMoveBasedOnLevels(levels, b));
}else{
Board b = new Board();
b.setSideToMove(Side.WHITE);
b.loadFromFen(fen);
LiquidSearchEngine engineFEN = new LiquidSearchEngine(b);
System.out.println(engineFEN.findBestMoveBasedOnLevels(levels, b));
}
try{
String fen = input.substring("position".length()).trim();
if(fen.contains("b")){
Board b = new Board();
b.setSideToMove(Side.BLACK);
b.loadFromFen(fen);
LiquidSearchEngine engineFEN = new LiquidSearchEngine(b);
System.out.println(engineFEN.findBestMoveBasedOnLevels(levels, b));
}else{
Board b = new Board();
b.setSideToMove(Side.WHITE);
b.loadFromFen(fen);
LiquidSearchEngine engineFEN = new LiquidSearchEngine(b);
System.out.println(engineFEN.findBestMoveBasedOnLevels(levels, b));
}
}catch (Exception e){
System.out.println("Error! Command is position <FEN>");
System.out.println(engine.EngineInfo());
engine.EngineUCICommands();
}

}

Expand All @@ -59,24 +65,34 @@ else if (input.startsWith("level")){
}

else if (input.startsWith("eval")) {
String fen = input.substring("eval".length()).trim();
if(fen.contains("b")){
Board b = new Board();
b.loadFromFen(fen);
b.setSideToMove(Side.BLACK);
LiquidSearchEngine engineFEN = new LiquidSearchEngine(b);
System.out.println(engineFEN.evaluateBoard());
}else{
Board b = new Board();
b.loadFromFen(fen);
b.setSideToMove(Side.WHITE);
LiquidSearchEngine engineFEN = new LiquidSearchEngine(b);
System.out.println(engineFEN.evaluateBoard());
}
try{
String fen = input.substring("eval".length()).trim();
if(fen.contains("b")){
Board b = new Board();
b.loadFromFen(fen);
b.setSideToMove(Side.BLACK);
LiquidSearchEngine engineFEN = new LiquidSearchEngine(b);
System.out.println(engineFEN.evaluateBoard());
}else{
Board b = new Board();
b.loadFromFen(fen);
b.setSideToMove(Side.WHITE);
LiquidSearchEngine engineFEN = new LiquidSearchEngine(b);
System.out.println(engineFEN.evaluateBoard());
}
}catch (Exception e){
System.out.println("Error! Command Not Supported!");
System.out.println(engine.EngineInfo());
engine.EngineUCICommands();
}

} else if ("quit".equals(input)) {
System.out.println("Lise Engine is shut down");
break;
}else{
System.out.println("Error! Command Not Supported!");
System.out.println(engine.EngineInfo());
engine.EngineUCICommands();
}
}
scanner.close();
Expand All @@ -87,40 +103,52 @@ public static void ChangeLevel(Scanner scanner, LiquidSearchEngine engine){
System.out.println("Select Level [1 - 4] 1 = Beginner 4 = BEAST");
String level = scanner.nextLine();

int le = Integer.parseInt(level);
try{

switch (le){
case 1 -> {
levels = Liquid_Levels.BEGINNER;
System.out.println("Configured Lise Beginner Level!");
engine.EngineUCICommands();
int le = Integer.parseInt(level);

}
switch (le){
case 1 -> {
levels = Liquid_Levels.BEGINNER;
System.out.println("Configured Lise Beginner Level!");
engine.EngineUCICommands();

case 2 -> {
levels = Liquid_Levels.NOVICE;
System.out.println("Configured Lise Novice Level!");
engine.EngineUCICommands();
}

}
case 2 -> {
levels = Liquid_Levels.NOVICE;
System.out.println("Configured Lise Novice Level!");
engine.EngineUCICommands();

case 3 -> {
levels = Liquid_Levels.STRONG;
System.out.println("Configured Lise Strong Level!");
engine.EngineUCICommands();
}

}
case 3 -> {
levels = Liquid_Levels.STRONG;
System.out.println("Configured Lise Strong Level!");
engine.EngineUCICommands();

case 4 -> {
levels = Liquid_Levels.BEAST;
System.out.println("Configured Lise Beast Level!");
engine.EngineUCICommands();
}

}
case 4 -> {
levels = Liquid_Levels.BEAST;
System.out.println("Configured Lise Beast Level!");
engine.EngineUCICommands();

}

default -> {
System.out.println("Level not supported!");
ChangeLevel(scanner, engine);
}


}
}catch (Exception e){
System.out.println("Error! Please provide valid Level");
ChangeLevel(scanner, engine);
}


}


Expand Down
Binary file modified src/main/java/engine/UCIStarter/LISEBOT.jar
Binary file not shown.

0 comments on commit f5d7e60

Please sign in to comment.