Class OnnxEvaluator

java.lang.Object
com.fortemate.dicechess.bot.OnnxEvaluator
All Implemented Interfaces:
AutoCloseable

public class OnnxEvaluator extends Object implements AutoCloseable
Evaluates board positions using an ONNX value model or falls back to engine heuristics.
  • Constructor Summary

    Constructors
    Constructor
    Description
    OnnxEvaluator(String modelPath)
    Constructs a new ONNX evaluator for the given model file path.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    float
    evaluate(dicechess.engine.domain.GameState state, int color)
    Evaluates a GameState from the perspective of the specified color.
    boolean
    Indicates whether an ONNX model file was loaded and is active for evaluation.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OnnxEvaluator

      public OnnxEvaluator(String modelPath)
      Constructs a new ONNX evaluator for the given model file path.
      Parameters:
      modelPath - filesystem path to the ONNX model file (e.g. "models/baseline.onnx"). If null, blank, or file does not exist, the evaluator gracefully falls back to engine heuristic evaluation.
  • Method Details

    • isLoaded

      public boolean isLoaded()
      Indicates whether an ONNX model file was loaded and is active for evaluation.
      Returns:
      true if ONNX model is loaded; false if using engine heuristic fallback
    • evaluate

      public float evaluate(dicechess.engine.domain.GameState state, int color)
      Evaluates a GameState from the perspective of the specified color.
      Parameters:
      state - the board state to evaluate
      color - active player's color (0 for White, 1 for Black)
      Returns:
      score as a float value (higher is better for the specified color). Falls back to JvmApi.evaluate(GameState, int) engine heuristic evaluation if ONNX model is not loaded.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable