All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fathzer.games.ai.transposition.TranspositionTablePolicy Maven / Gradle / Ivy

The newest version!
package com.fathzer.games.ai.transposition;

import java.util.function.IntUnaryOperator;

import com.fathzer.games.MoveGenerator;

/** A class that decide if a transposition table entry should be replaced or not.
 * @param  The type of moves
 * @param  The type of move generator
 */
public interface TranspositionTablePolicy> {
    /** Processes a transposition table entry.
     * 
This method is called before iterating on possible moves to use entry data in order to speed up the Negamax algorithm. *
One can override it to customize how transposition table entries are used. *
The default behaviour is to return the value of entries with {@link EntryType#EXACT} type and depth >= the current negamax depth and ignore others. * @param entry The entry * @param depth The current depth * @param alpha The current alpha value * @param beta The current beta value * @param fromTTScoreConverter A function that will convert the value stored in the table to the value effectively returned in this method's result. *
This could seems strange because there's a lot of examples on the Internet that returns directly the stored value. * But, unfortunately, this strategy does not work with win/loose score and recursive deepening. The following text explains the problem. * @return The state that should be applied. If a value is set, the search is stopped and the value is returned. If alpha or beta value are changed in returned instance, they are copied in calling search function. */ AlphaBetaState accept(TranspositionTableEntry entry, int depth, int alpha, int beta, IntUnaryOperator fromTTScoreConverter); /** Updates the transposition table, if required, after iterating on possible moves. *
This method is responsible for deciding if something should be stored and what should be stored. *
It typically uses {@link TranspositionTable#store(long, EntryType, int, int, Object, java.util.function.Predicate)} method to store/update the entry * @param table The transposition table * @param key The key where to store data * @param state The state returned by {@link #accept(TranspositionTableEntry, int, int, int, IntUnaryOperator)} updated with alpha, beta and value * @param toTTScoreConverter A function that will convert the state value to the value effectively stored in the table. *
This could seems strange because there's a lot of examples on the Internet that stores directly the state value. * But, unfortunately, this strategy does not work with win/loose score and recursive deepening. The following text explains the problem. * @return true if state is stored, false if it is ignored * @see TranspositionTable#store(long, EntryType, int, int, Object, java.util.function.Predicate) */ boolean store(TranspositionTable table, long key, AlphaBetaState state, IntUnaryOperator toTTScoreConverter); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy