@@ -147,6 +147,24 @@ func TestFiveFoldRepetition(t *testing.T) {
147147 }
148148}
149149
150+ func TestFiveFoldRepetitionIgnored (t * testing.T ) {
151+ g := NewGame (IgnoreFivefoldRepetitionDraw ())
152+ moves := []string {
153+ "Nf3" , "Nf6" , "Ng1" , "Ng8" ,
154+ "Nf3" , "Nf6" , "Ng1" , "Ng8" ,
155+ "Nf3" , "Nf6" , "Ng1" , "Ng8" ,
156+ "Nf3" , "Nf6" , "Ng1" , "Ng8" ,
157+ }
158+ for _ , m := range moves {
159+ if err := g .PushMove (m , nil ); err != nil {
160+ t .Fatal (err )
161+ }
162+ }
163+ if g .Outcome () == Draw && g .Method () == FivefoldRepetition {
164+ t .Fatal ("automatically draw after five repetitions should be ignored" )
165+ }
166+ }
167+
150168func TestFiftyMoveRule (t * testing.T ) {
151169 fen , _ := FEN ("2r3k1/1q1nbppp/r3p3/3pP3/pPpP4/P1Q2N2/2RN1PPP/2R4K b - b3 100 60" )
152170 g := NewGame (fen )
@@ -174,6 +192,17 @@ func TestSeventyFiveMoveRule(t *testing.T) {
174192 }
175193}
176194
195+ func TestSeventyFiveMoveRuleIgnored (t * testing.T ) {
196+ fen , _ := FEN ("2r3k1/1q1nbppp/r3p3/3pP3/pPpP4/P1Q2N2/2RN1PPP/2R4K b - b3 149 80" )
197+ g := NewGame (fen , IgnoreSeventyFiveMoveRuleDraw ())
198+ if err := g .PushMove ("Kf8" , nil ); err != nil {
199+ t .Fatal (err )
200+ }
201+ if g .Outcome () == Draw && g .Method () == SeventyFiveMoveRule {
202+ t .Fatal ("automatically draw after seventy five moves w/ no pawn move or capture should be ignored" )
203+ }
204+ }
205+
177206func TestInsufficientMaterial (t * testing.T ) {
178207 fens := []string {
179208 "8/2k5/8/8/8/3K4/8/8 w - - 1 1" ,
@@ -195,6 +224,27 @@ func TestInsufficientMaterial(t *testing.T) {
195224 }
196225}
197226
227+ func TestInsufficientMaterialIgnored (t * testing.T ) {
228+ fens := []string {
229+ "8/2k5/8/8/8/3K4/8/8 w - - 1 1" ,
230+ "8/2k5/8/8/8/3K1N2/8/8 w - - 1 1" ,
231+ "8/2k5/8/8/8/3K1B2/8/8 w - - 1 1" ,
232+ "8/2k5/2b5/8/8/3K1B2/8/8 w - - 1 1" ,
233+ "4b3/2k5/2b5/8/8/3K1B2/8/8 w - - 1 1" ,
234+ }
235+ for _ , f := range fens {
236+ fen , err := FEN (f )
237+ if err != nil {
238+ t .Fatal (err )
239+ }
240+ g := NewGame (IgnoreInsufficientMaterialDraw (), fen )
241+ if g .Outcome () == Draw && g .Method () == InsufficientMaterial {
242+ log .Println (g .Position ().Board ().Draw ())
243+ t .Fatalf ("%s automatically draw by insufficient material should be ignored" , f )
244+ }
245+ }
246+ }
247+
198248func TestSufficientMaterial (t * testing.T ) {
199249 fens := []string {
200250 "8/2k5/8/8/8/3K1B2/4N3/8 w - - 1 1" ,
@@ -2190,3 +2240,24 @@ func TestPushNotationMoveVsUnsafePushNotationMovePerformance(t *testing.T) {
21902240 t .Logf ("Warning: UnsafePushNotationMove wasn't faster than PushNotationMove - this might be expected for simple positions" )
21912241 }
21922242}
2243+
2244+ func TestIgnoreFivefoldRepetitionDraw (t * testing.T ) {
2245+ g := NewGame (IgnoreFivefoldRepetitionDraw ())
2246+ if ! g .ignoreFivefoldRepetitionDraw {
2247+ t .Fatal ("ignoreFivefoldRepetitionDraw should be true after being ignored" )
2248+ }
2249+ }
2250+
2251+ func TestIgnoreSeventyFiveMoveRuleDraw (t * testing.T ) {
2252+ g := NewGame (IgnoreSeventyFiveMoveRuleDraw ())
2253+ if ! g .ignoreSeventyFiveMoveRuleDraw {
2254+ t .Fatal ("ignoreSeventyFiveMoveRuleDraw should be true after being ignored" )
2255+ }
2256+ }
2257+
2258+ func TestIgnoreInsufficientMaterialDraw (t * testing.T ) {
2259+ g := NewGame (IgnoreInsufficientMaterialDraw ())
2260+ if ! g .ignoreInsufficientMaterialDraw {
2261+ t .Fatal ("ignoreInsufficientMaterialDraw should be true after being ignored" )
2262+ }
2263+ }
0 commit comments