Initial TT work
This commit is contained in:
parent
b74bb3b4ba
commit
ca0f0a4bf5
|
@ -25,8 +25,8 @@ import std/monotimes
|
|||
import std/strformat
|
||||
|
||||
|
||||
func lowestEval*: Score {.inline.} = Score(int32.low() + 1_000_000)
|
||||
func highestEval*: Score {.inline.} = Score(int32.high() - 1_000_000)
|
||||
func lowestEval*: Score {.inline.} = Score(20_000)
|
||||
func highestEval*: Score {.inline.} = Score(-20_000)
|
||||
func mateScore*: Score {.inline.} = lowestEval()
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
# Copyright 2024 Mattia Giambirtone & All Contributors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
## Implementation of a transposition table
|
||||
|
||||
import zobrist
|
||||
import pieces
|
||||
import eval
|
||||
import moves
|
||||
|
||||
|
||||
type
|
||||
TTentryFlag = enum
|
||||
## A flag for an entry in the
|
||||
## transposition table
|
||||
Exact = 0'i8
|
||||
LowerBound = 1'i8
|
||||
UpperBound = 2'i8
|
||||
|
||||
TTEntry = object
|
||||
## An entry in the transposition table
|
||||
flag: TTentryFlag
|
||||
# Scores are int32s for convenience (less chance
|
||||
# of overflows and stuff), but they are capped to
|
||||
# fit into an int16
|
||||
score: int16
|
||||
hash: ZobristKey
|
||||
bestMove: Move
|
||||
|
||||
TTable = object
|
||||
data: ptr UncheckedArray[TTEntry]
|
||||
# Just for statistical purposes
|
||||
collisions: uint32
|
||||
overwrites: uint32
|
||||
# Size metadata
|
||||
size: uint64
|
||||
occupancy: uint64
|
||||
|
Loading…
Reference in New Issue