@ -1,5 +1,4 @@
import einheit
import einheit
import algorithm
import . / chess
import . / chess
import . / engine
import . / engine
@ -12,7 +11,7 @@ testSuite GameTest of TestSuite:
method setup ( ) =
method setup ( ) =
self . game = initGame ( )
self . game = initGame ( )
method testPieceEval ( ) =
method testPieceEval Stalemate ( ) =
self . game = initGame ( [
self . game = initGame ( [
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , WKing , 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 , BKing , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
] , Color . Black )
] , Color . Black )
var mTree = self . game . spanMoveTree ( 2 )
var mTree = self . game . spanMoveTree ( 1 )
self . check ( mTree . children = = [ ] )
self . check ( mTree . children = = [ ] )
method test ManualMiniMaxEval ( ) =
method test BestMoveProm ( ) =
self . game = initGame ( [
self . game = initGame ( [
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , WKing , 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 , 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
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
] , Color . Black )
] , Color . White )
var mTree = self . game . spanMoveTree ( 2 )
var testBestMove = self . game . bestMove ( 2 )
var evaluation = mTree . minimax ( )
self . check ( testBestMove . start ! = 0 )
self . check ( evaluation = = 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 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , WKing , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , WKing , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 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 , WPawn , BKing , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
] , Color . Black )
] , 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 . start ) = = " c7 " )
self . check ( indToField ( testBestMove . dest ) = = " d7 " )
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 :
when isMainModule :
einheit . runTests ( )
einheit . runTests ( )