import { SIZE , PLAYER , pos2idx } from '../common/define' ; import Move from '../common/Move' ; export default class HistoryHeuristic { private historyTable : Array < Array < number > > ; private targetBuff : Array < number > ; constructor ( ) { this . historyTable = Array . apply ( null , Array ( SIZE . files * SIZE . ranks ) ) . map ( ( ) => Array . apply ( null , Array ( SIZE . files * SIZE . ranks ) ) . map ( ( ) => 0 ) ) ; this . targetBuff = new Array ( ) ; } clear ( ) { this . historyTable . map ( ( row ) => row . map ( ( ) => 0 ) ) ; } get ( move ) { let from = pos2idx ( move . from . x , move . from . y ) , to = pos2idx ( move . to . x , move . to . y ) ; return this . historyTable [ from ] [ to ] ; } update ( move , depth ) { let from = pos2idx ( move . from . x , move . from . y ) , to = pos2idx ( move . to . x , move . to . y ) ; this . historyTable [ from ] [ to ] += 2 << depth ; } } ;