Skip to content

Commit 62922d4

Browse files
committed
Threefold repetition rule
1 parent 9d26b0f commit 62922d4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

engine/search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (pv *pvSearch) alphaBeta(depth, alpha, beta int) int {
107107
}
108108

109109
// repetition
110-
if pv.board.ply > 0 && pv.board.repetitions() > 0 {
110+
if pv.board.ply > 0 && pv.board.repetitions() >= 3 {
111111
return scoreDraw
112112
}
113113

engine/search_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package engine
2+
3+
import "testing"
4+
5+
func TestBestMoveForEndgamePosition(t *testing.T) {
6+
7+
board := NewBoard("4k3/2R5/4p2b/4Pb1P/8/5K2/8/8 w - - 16 70")
8+
9+
best := Search(board)
10+
11+
if best.From == C7 && best.To == G7 {
12+
t.Errorf("Expected best move to not be: %s", best.String())
13+
}
14+
15+
}

0 commit comments

Comments
 (0)