mirror of https://github.com/tiyn/yeschess
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.5 KiB
49 lines
1.5 KiB
4 years ago
|
import einheit
|
||
|
|
||
4 years ago
|
include chess
|
||
|
include engine
|
||
4 years ago
|
|
||
4 years ago
|
testSuite ChessTest of TestSuite:
|
||
4 years ago
|
|
||
|
var
|
||
4 years ago
|
chess: Chess
|
||
4 years ago
|
|
||
|
method setup() =
|
||
4 years ago
|
self.chess = initChess()
|
||
4 years ago
|
|
||
4 years ago
|
method testPieceEvalStalemate() =
|
||
4 years ago
|
self.chess = initChess("8/8/2k5/8/8/5K2/8/8 b - - 0 1")
|
||
|
var pieceEvaluation = self.chess.evaluate()
|
||
4 years ago
|
self.check(pieceEvaluation == 0)
|
||
|
|
||
4 years ago
|
method testBestMoveProm() =
|
||
4 years ago
|
self.chess = initChess("8/2k1P3/8/8/8/5K2/8/8 w - - 0 1")
|
||
4 years ago
|
var testBestMove = self.chess.bestMove(2)
|
||
4 years ago
|
self.check(testBestMove.start != 0)
|
||
|
self.check(indToField(testBestMove.start) == "e7")
|
||
|
self.check(indToField(testBestMove.dest) == "e8")
|
||
|
|
||
|
method testBestMoveStopProm() =
|
||
4 years ago
|
self.chess = initChess("8/2k1P3/8/8/8/5K2/8/8 b - - 0 1")
|
||
4 years ago
|
var testBestMove = self.chess.bestMove(2)
|
||
4 years ago
|
self.check(testBestMove.start != 0)
|
||
4 years ago
|
self.check(indToField(testBestMove.start) == "c7")
|
||
|
self.check(indToField(testBestMove.dest) == "d7")
|
||
|
|
||
4 years ago
|
method testBestMoveTacticBlack() =
|
||
4 years ago
|
self.chess = initChess("8/2k3r1/8/6p1/5P2/8/4K1R1/8 b - - 0 1")
|
||
4 years ago
|
var testBestMove = self.chess.bestMove(2)
|
||
4 years ago
|
self.check(testBestMove.start != 0)
|
||
4 years ago
|
self.check(indToField(testBestMove.start) != "g5" or indToField(
|
||
|
testBestMove.dest) != "f4")
|
||
4 years ago
|
|
||
|
method testBestMoveTacticWhite() =
|
||
4 years ago
|
self.chess = initChess("8/2k3r1/8/5p2/6P1/8/4K1R1/8 w - - 0 1")
|
||
4 years ago
|
var testBestMove = self.chess.bestMove(2)
|
||
4 years ago
|
self.check(testBestMove.start != 0)
|
||
4 years ago
|
self.check(indToField(testBestMove.start) != "g4" or indToField(
|
||
|
testBestMove.dest) != "f5")
|
||
4 years ago
|
|
||
4 years ago
|
when isMainModule:
|
||
|
einheit.runTests()
|