
com.fathzer.games.movelibrary.MoveLibrary Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of games-core Show documentation
Show all versions of games-core Show documentation
A core library to help implement two players games.
The newest version!
package com.fathzer.games.movelibrary;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import com.fathzer.games.ai.evaluation.EvaluatedMove;
/** A class that can choose a move from a database, without any tree search.
*
The typical usage is for Opening books or End game tablebases
* @param The type of moves
* @param The type of the keys that allow to retrieve the moves from the library (typically, the game board)
*/
public interface MoveLibrary extends Function>> {
/** Gets the moves for a position.
* @param board a position
* @return The moves available for the position in the library and their evaluations, or an empty list if it can't find any move.
*/
List> getMoves(B board);
/**
* Gets the move to play for a position.
* @param board a position
* @return an empty Optional if it can't find a move for the position, or the proposed move and its evaluation if one was found.
*/
@Override
Optional> apply(B board);
/**
* This method is called when a new game is started.
*
This allows to reset the library state. Typically, a library may stop searching after a number of moves are played.
* Calling this method should restart search.
*/
default void newGame() {
// Does nothing by default
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy