@ -1,5 +1,4 @@
import einheit
import algorithm
import . / chess
import . / engine
@ -12,7 +11,7 @@ testSuite GameTest of TestSuite:
method setup ( ) =
self . game = initGame ( )
method testPieceEval ( ) =
method testPieceEval Stalemate ( ) =
self . game = initGame ( [
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , WKing , 0 , 0 , 0 , 0 ,
@ -37,10 +36,10 @@ testSuite GameTest of TestSuite:
0 , 0 , 0 , 0 , 0 , BKing , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
] , Color . Black )
var mTree = self . game . spanMoveTree ( 2 )
var mTree = self . game . spanMoveTree ( 1 )
self . check ( mTree . children = = [ ] )
method test ManualMiniMaxEval ( ) =
method test BestMoveProm ( ) =
self . game = initGame ( [
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , WKing , 0 , 0 , 0 , 0 ,
@ -48,15 +47,18 @@ testSuite GameTest of TestSuite:
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , WPawn , BKing , 0 , 0 ,
0 , 0 , 0 , WPawn , 0 , BKing , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
] , Color . Black )
var mTree = self . game . spanMoveTree ( 2 )
var evaluation = mTree . minimax ( )
self . check ( evaluation = = 0 )
] , Color . White )
var testBestMove = self . game . bestMove ( 2 )
self . check ( testBestMove . start ! = 0 )
self . check ( indToField ( testBestMove . start ) = = " e7 " )
self . check ( indToField ( testBestMove . dest ) = = " e8 " )
method testBestMove ( ) =
var testGame = initGame ( [
method testBestMoveStopProm ( ) =
self . game = initGame ( [
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , WKing , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
@ -66,10 +68,41 @@ testSuite GameTest of TestSuite:
0 , 0 , 0 , 0 , WPawn , BKing , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
] , Color . Black )
var testBestMove = testGame . bestMove ( 2 )
var testBestMove = self . game . bestMove ( 2 )
self . check ( testBestMove . start ! = 0 )
self . check ( indToField ( testBestMove . start ) = = " c7 " )
self . check ( indToField ( testBestMove . dest ) = = " d7 " )
method testBestMoveTacticBlack ( ) =
self . game = initGame ( [
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , WRook , 0 , WKing , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , WPawn , 0 , 0 , 0 , 0 , 0 ,
0 , BPawn , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , BRook , 0 , 0 , 0 , BKing , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
] , Color . Black )
var testBestMove = self . game . bestMove ( 2 )
self . check ( testBestMove . start ! = 0 )
self . check ( indToField ( testBestMove . start ) ! = " g5 " or indToField ( testBestMove . dest ) ! = " f4 " )
method testBestMoveTacticWhite ( ) =
self . game = initGame ( [
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , WRook , 0 , WKing , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , WPawn , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , BPawn , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , BRook , 0 , 0 , 0 , BKing , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
] , Color . White )
var testBestMove = self . game . bestMove ( 2 )
self . check ( testBestMove . start ! = 0 )
self . check ( indToField ( testBestMove . start ) ! = " g4 " or indToField ( testBestMove . dest ) ! = " f5 " )
when isMainModule :
einheit . runTests ( )