Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.

Commit

Permalink
Use dynamic treshold
Browse files Browse the repository at this point in the history
  • Loading branch information
mhib committed May 16, 2020
1 parent 0fdde8c commit 7fd4cfa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ func (t *thread) incNodes() {
}
}

func (t *thread) getNextMove(pos *backend.Position, height int) backend.Move {
return t.stack[height].GetNextMove(pos, &t.MoveHistory, height)
func (t *thread) getNextMove(pos *backend.Position, depth, height int) backend.Move {
return t.stack[height].GetNextMove(pos, &t.MoveHistory, depth, height)
}

func (pv *PV) clear() {
Expand Down
5 changes: 2 additions & 3 deletions engine/move_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ var mvvlvaScores = [None + 1]int32{10, 40, 45, 68, 145, 256, 0}

const badNoisyValue = -4096

const sortTreshold = (-16384 * 3) / 4

func mvvlva(move Move) int32 {
captureScore := mvvlvaScores[move.CapturedPiece()]
if move.IsPromotion() && move.PromotedPiece() == Queen {
Expand Down Expand Up @@ -93,7 +91,7 @@ func (mp *MoveProvider) dropNoisy(bestIdx int) {
mp.Moves[mp.noisySize], mp.Moves[bestIdx] = mp.Moves[bestIdx], mp.Moves[mp.noisySize]
}

func (mp *MoveProvider) GetNextMove(pos *Position, mh *MoveHistory, height int) Move {
func (mp *MoveProvider) GetNextMove(pos *Position, mh *MoveHistory, depth, height int) Move {
var move EvaledMove
var bestIdx int
switch mp.stage {
Expand Down Expand Up @@ -161,6 +159,7 @@ func (mp *MoveProvider) GetNextMove(pos *Position, mh *MoveHistory, height int)
mp.quietsSize = pos.GenerateQuiet(mp.Moves[mp.split:])
quietMoves := mp.Moves[mp.split : mp.split+mp.quietsSize]
mh.EvaluateQuiets(pos, quietMoves, height)
sortTreshold := -2000 * int32(depth)
// Partial Insertion sort
for i := len(quietMoves) - 2; i >= 0; i-- {
if quietMoves[i].Value > sortTreshold {
Expand Down
8 changes: 4 additions & 4 deletions engine/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (t *thread) quiescence(depth, alpha, beta, height int, inCheck bool) int {
}

for {
move := t.stack[height].GetNextMove(pos, &t.MoveHistory, height)
move := t.getNextMove(pos, 0, height)
if move == NullMove {
break
}
Expand Down Expand Up @@ -269,7 +269,7 @@ func (t *thread) alphaBeta(depth, alpha, beta, height int, inCheck bool) int {
probCutCount := 0
for probCutCount < 3 {

move := t.getNextMove(pos, height)
move := t.getNextMove(pos, depth, height)
if move == NullMove {
break
}
Expand Down Expand Up @@ -315,7 +315,7 @@ func (t *thread) alphaBeta(depth, alpha, beta, height int, inCheck bool) int {
t.stack[height].InitNormal(pos, &t.MoveHistory, height, hashMove)

for {
move := t.getNextMove(pos, height)
move := t.getNextMove(pos, depth, height)
if move == NullMove {
break
}
Expand Down Expand Up @@ -448,7 +448,7 @@ func (t *thread) isMoveSingular(depth, height int, hashMove Move, hashValue int)
quiets := 0
t.stack[height].InitSingular()
for {
move := t.getNextMove(pos, height)
move := t.getNextMove(pos, depth, height)
if move == NullMove || t.stack[height].GetMoveStage() >= BAD_NOISY {
break
}
Expand Down
2 changes: 1 addition & 1 deletion tuning/tuning.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (t *thread) quiescence(alpha, beta, height int, inCheck bool) int {
}

for i := range evaled {
move := t.stack[height].GetNextMove(pos, &moveHistory, height)
move := t.stack[height].GetNextMove(pos, &moveHistory, 128, height)
if move == NullMove {
break
}
Expand Down

0 comments on commit 7fd4cfa

Please sign in to comment.