Skip to content

Commit

Permalink
Fixes Score not reset on new game + score is multiplied by 100
Browse files Browse the repository at this point in the history
  • Loading branch information
fathzer committed Feb 20, 2024
1 parent 7195acf commit 8f4a543
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ Java 11+ to run the application and mvn to build it.

# Known bugs
- Engine lists in player settings are not updated when variant changes.
- The displayed score is mutiplied per 100.
- The score + resign icon are not initialized at the same time as the board.
- The depth of internal engine is always set to 2
- The internal engine received a negative remaining time
- The time increment is never passed to UCI engine (see Game.EngineTurn class)

# TODO
- Allow engine settings to be defined in engines.json.
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/com/fathzer/jchess/swing/GameSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private void initGame() {
panel.setClock(game.getClock());
panel.getBoard().setBoard(game.getBoard());
panel.getBoard().setManualMoveEnabled(false);
setScore();
}

private Clock buildClock() {
Expand All @@ -135,7 +136,7 @@ public Engine getEngine(EngineSettings settings) {
return found.orElseThrow().getEngine();
}

private JChessEngine getEngine(int level, String evaluatorName) {
private JChessEngine getEngine(int level, String evaluatorName) { //TODO Remove
final Supplier<Evaluator<Move, Board<Move>>> evaluator = "simple".equals(evaluatorName) ? SimplifiedEvaluator::new : NaiveEvaluator::new;
final JChessEngine engine = new JChessEngine(evaluator, level);
final int threads;
Expand Down Expand Up @@ -234,12 +235,16 @@ private void onMove(Move move) {
// Game is ended
endOfGame(status);
} else {
final NaiveEvaluator ev = new NaiveEvaluator();
ev.init(game.getBoard());
panel.setScore(ev.evaluateAsWhite(game.getBoard()));
setScore();
nextMove();
}
}

private void setScore() {
final NaiveEvaluator ev = new NaiveEvaluator();
ev.init(game.getBoard());
panel.setScore(ev.evaluateAsWhite(game.getBoard())/100);
}

/** This method is called when clock emits a time up event.
* <br>Please note that this method could be invoked on a thread that is not the Swing event thread.
Expand Down

0 comments on commit 8f4a543

Please sign in to comment.