evaluate method

int evaluate(
  1. List<int> pieceSquareInput
)

Implementation

int evaluate(List<int> pieceSquareInput) {
  pieceSquareInput =
      pieceSquareInput.map((x) => x.clamp(0, inputSize - 1)).toList();

  for (int i = 0; i < hiddenSize; i++) {
    hiddenLayer[i] = 0;
    for (int j = 0; j < pieceSquareInput.length; j++) {
      hiddenLayer[i] += W1[i * inputSize + pieceSquareInput[j]];
    }
    hiddenLayer[i] = max(0, hiddenLayer[i]); // ReLU activation
  }

  Int16List h1 = _reluMultiply(W2, hiddenLayer, interSize, hiddenSize);
  Int16List h2 = _reluMultiply(W3, h1, interSize, interSize);
  Int16List h3 = _reluMultiply(W4, h2, outputSize, interSize);

  return h3[0];
}